How can i plot Histogram for this??

How can i plot histogram for an image with 3 bins, where the bins holds the pixel values falling in the region 0-40, 41-90, 91-255. Also how can i write these stats, as in the number of pixels in each of those regions. Plz Help ?

 採用された回答

Image Analyst
Image Analyst 2015 年 7 月 21 日

0 投票

Try
edges = [0,41,91,255];
pixelCounts = histcounts(grayImage(:), edges);

4 件のコメント

dp sb
dp sb 2015 年 7 月 21 日
Thank You! I do get the pixel counts with that but now how can i get the histogram with the same 3 bins ??
Image Analyst
Image Analyst 2015 年 7 月 21 日
pixelCounts is the histogram. Or do you mean how to display it? Try the bar function
bar(pixelCounts, 'BarWidth', 1, 'FaceColor', 'b');
dp sb
dp sb 2015 年 7 月 21 日
It works. Thank You!
Steven Lord
Steven Lord 2015 年 7 月 21 日
Or call HISTOGRAM instead of HISTCOUNTS. If you want both the counts and the graphics object, call HISTOGRAM with an output argument and take a look at the properties of that graphics object.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2015 年 7 月 21 日

コメント済み:

2015 年 7 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by