How to display the y axis of the grayscale image histogram as a percentage of pixel numbers?

4 views (last 30 days)
I have the histogram of a grayscale dicom image where each bin contains a large no. of pixels. What should I do, if I want to display the histogram of the image as a probability histogram or as a percentage of pixels in y axis, instead of displaying raw no.of pixels?
Thanks for the help in advance

Answers (1)

Image Analyst
Image Analyst on 24 Jan 2016
Try this:
[counts, binLocations] = imhist(grayImage);
% Convert to a percentage in the range 0-100.
thePDF = 100 * counts / numel(grayImage);
% Plot
bar(binLocations, thePDF);
grid on;
xlabel('Gray Level', 'FontSize', 15);
ylabel('Percentage', 'FontSize', 15);
title('PDF', 'FontSize', 15);
  3 Comments
Image Analyst
Image Analyst on 24 Jan 2016
If you're talking about this File Exchange entry then you're going to have to figure out what bin to suppress and pass that in. Also, it just has counts or log(counts) on the y axis, not percentages, which is not really needed to interactively decide upon a threshold.
Ruhul Amin
Ruhul Amin on 24 Jan 2016
Dear Image Analyst ,
Thanks for the reply. Yes , I know the y axis just has the counts. I thought to display the percentage of pixels because I think if I draw a few pixels as percentage , selecting the gray value position of the threshold will be much easier , as it might have a clear valley between two types of tissue pixels. Typically , there are slight differences in their gray levels.
Displaying many pixels in histogram as counts , shows the histogram with overlapped regions , because of overlapped pixels.
I guess , if I draw the percentage of pixels , where each pixel (percentage) will be the representative of each bin , the histogram would show clear valley between two types of tissue pixels. So , I can choose the threshold easily.
What is your opinion ? Please help . thanks a lot

Sign in to comment.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!