Contrast adjustment/pixel adjustment

10 views (last 30 days)
kemi
kemi on 29 May 2014
Commented: kemi on 30 May 2014
Please I am still learning, I have a gray scale image with the intensity values ranges from 0 to 255. If I plot the histogram of the images, I was having some noises at both ends of the histogram. I like to refine the image pixels by ignoring the pixels that are below certain thresholds in order to have new minimum and maximum intensity values and of course to get rid of those noises at both ends. I also like to define my threshold as a function of the image size if possible. Can somebody please help me with the code? Thanks in advance.

Accepted Answer

Image Analyst
Image Analyst on 29 May 2014
See my salt and pepper noise removal demos, attached. Of course they can easily be adapted to get rid of noise above and below thresholds instead of just exactly at 0 and 255.
  3 Comments
Image Analyst
Image Analyst on 29 May 2014
If you have noise at both ends of the intensity range and just want to get rid of bins with those values of intensity from the histogram but not from the image, you can just set the counts equal to zero. I often do this to see the histogram more clearly when there is a huge spike at some bin, like the zero bin because I've masked the image
[pixelCounts, grayLevels] = imhist(grayImage, 256);
% Suppress huge bin at zero
pixelCounts(1) = 0;
% Plot
bar(grayLevels, pixelCounts);
You can also set ranges of bins equal to zero
pixelCounts(1:30) = 0;
This will get rid of counts from the histogram but doesn't get rid of the noise from the image . To do that you'd need to do something like I attached originally, but you say you don't want to do that.
kemi
kemi on 30 May 2014
Thanks very much for your helps. This really helps.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!