How to display the y axis of the grayscale image histogram as a percentage of pixel numbers?
4 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
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
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.
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!