MATLAB: Removing Values from Histogram

histogram

I want to remove gray levels of particular range from Histogram of an Image. Anyone Know how to do?

Best Answer

Let's say you had a masked image where a huge number of pixels were black and this produced a big spike in the histogram at zero. You can suppress this by setting that bin to zero.
[pixelCount, grayLevels] = imhist(grayImage, 256);
% Suppress zero bin:
pixelCount(1) = 0;
% Now plot:
bar(grayLevels, pixelCount);