Skip to content
Snippets Groups Projects
Commit 9ea7a85c authored by sundar's avatar sundar
Browse files

NormalizedHistogram implementation

parent e3917d78
No related branches found
No related tags found
No related merge requests found
function histo = NormalizedHistogram(ImageIn,numBins,device,useMatlab)
% Creates a normalized histogram array with numBins bins between min/max values.
% If min/max is not provided, the min/max of the type is used.
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
sz = size(ImageIn);
ImageIn_matlab = reshape(ImageIn,sz(1)*sz(2)*sz(3),1);
if (useMatlab)
if(numBins == 0 )
histo = imhist(ImageIn_matlab) ./ sum(imhist(ImageIn_matlab));
else
histo = imhist(ImageIn_matlab,numBins) ./ sum(imhist(ImageIn_matlab,numBins));
end
%figure, plot(histo), title('Normalized Histogram Output from Matlab');
else
histo = CudaMex('NormalizedHistogram',ImageIn,numBins,device);
%figure, plot(histo), title('Histogram Output from Cuda');
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