Clear Filters
Clear Filters

Make values on y-axis in histogram to shrink.

1 view (last 30 days)
LOKESH
LOKESH on 22 Apr 2012
I have a Histogram of Binary Image. On y-axis I have values up to 2000. How can make it small so that the graph appears big. For example how can show only 1000 values on y-axis instead of 2000..
Thanks

Answers (2)

Walter Roberson
Walter Roberson on 22 Apr 2012
Change the number of bins in the histogram.

Image Analyst
Image Analyst on 22 Apr 2012
A binary image will have only two bins, one at 0 and one at 1, since there are only two values (false and true, or 0 and 1) in the image. One bin will have some number of counts, like 1500, and the other bin will contain a value equal to the number of pixels in the image minus the count in the other bin.
If you want to clip the y axis to some value, you can use ylim:
ylim([0 1000]);
If you want to compress the y scale, then you can plot the log of the y values (the count values) instead of using it linearly:
pixelCounts = imhist(binaryImage, 2);
bar(log(pixelCounts));
but be sure to adjust the y axis labels to be the original y values instead of the logged y values.

Community Treasure Hunt

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

Start Hunting!