Skip to content
Snippets Groups Projects
Commit 3caf51f3 authored by sundar's avatar sundar
Browse files

Median filter helper function

parent dda0e646
No related branches found
No related tags found
No related merge requests found
function imageOut = Medianfilter(image1,Neighborhood,device,useMatlab)
% NeighborhoodX, NeighborhoodY, and NeighborhoodZ are the directions and area to look for a given pixel.
if (~exist('device','var') || isempty(device))
device = 1;
end
if (~exist('useMatlab','var') || isempty(useMatlab))
useMatlab = false;
end
if (~useMatlab)
[numCudaDevices, memoryStats] = CudaMex('DeviceCount');
if (numCudaDevices < 1)
useMatlab = true;
elseif (device > numCudaDevices)
device = numCudaDevices;
end
% do something smart here if there is not enough memory...
end
%Use same neighborhood for all 3 dimensions - Hack
NeighborhoodX = Neighborhood;
NeighborhoodY = Neighborhood;
NeighborhoodZ = Neighborhood;
if (useMatlab)
imageOut = immedian(image1,NeighborhoodX,NeighborhoodY,NeighborhoodZ);
else
imageOut = CudaMex('MedianFilter',image1,[NeighborhoodX,NeighborhoodY,NeighborhoodZ],device);
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment