Skip to content
Snippets Groups Projects
Commit 985da167 authored by sundar's avatar sundar
Browse files

OtsuThresholdFilter implementation

parent df9032d2
No related branches found
No related tags found
No related merge requests found
function imageOut = OtsuThresholdFilter(image1,device,useMatlab)
% This will set each pixel/voxel to the min value of the neighborhood defined by the given kernel.
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
if (useMatlab)
threshold = graythresh(image1);
imageOut = image1 > threshold;
imageOut = im2uint8(imageOut);
else
imageOut = CudaMex('OtsuThresholdFilter',image1,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