Skip to content
Snippets Groups Projects
Commit 374aff3c authored by sundar's avatar sundar
Browse files

ThresholdFilter implementation

parent 240b11ce
No related branches found
No related tags found
No related merge requests found
function imageOut = ThresholdFilter(image1,threshold,device,useMatlab)
% Maps any value >= thresh to the max value of the image space. All other values will be set at the minimum of the image space.
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)
bw_logical = image1 > threshold;
type = class(image1);
if (strcmp(type , 'uint8'))
imageOut = uint8(zeros(size(image1)));
imageOut(bw_logical) = 255;
end
if (strcmp(type , 'double') || strcmp(type , 'logical'))
imageOut = uint8(zeros(size(image1)));
imageOut(bw_logical) = 1;
end
else
imageOut = CudaMex('ThresholdFilter',image1,threshold,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