フィルターのクリア

histogram plot is emplty

5 ビュー (過去 30 日間)
Selina Loh
Selina Loh 2017 年 7 月 1 日
コメント済み: Star Strider 2017 年 7 月 1 日
I have errors in displaying the histogram for a matrix (3648x5472). The histogram displayed is blank. The matrix value is in uint8.

採用された回答

Image Analyst
Image Analyst 2017 年 7 月 1 日
You can use imhist, or you can also use histogram(). They will both work. What is probably happening is that your V is having every one of its pixels replaced by true or false (1 or 0). So there are only two bins. Now one of them, the zero bin, is so high, and it's at the very left of the chart that it looks like the Y axis. If you use imhist() you will have 256 bins and the 0 and 1 bin will be so small and at the edge of the chart box that you probably don't notice them. If you use histogram, you should see two fat bars - one at 0 and one at 1.

その他の回答 (1 件)

Star Strider
Star Strider 2017 年 7 月 1 日
You probably need to use the imhist function, since your uint8 array may be an image.
This works for me:
M = randi(intmax('uint8'), 3648, 5472, 'uint8'); % Create Matrix
H = imhist(M);
figure(1)
bar(H)
  2 件のコメント
Selina Loh
Selina Loh 2017 年 7 月 1 日
V(I3>254) = 255; V(I3<=254) = 0; V = uint8(reshape(V,[3648,5472]));
imhist(V)
I am trying to display a historgram for a black and white image. I cannot directly use the imhist function?
Star Strider
Star Strider 2017 年 7 月 1 日
Knowing it was a binary image would have helped. If you want to know the number of true or ‘1’ values, you do not need a histogram. Simply count the ‘1’ values, and if you want the fraction that are ‘1’, divide by the total number of elements in the binary image:
BinaryImage = randi([0 1], 3648, 5472, 'uint8'); % Create Binary Image
NrEq_1 = nnz(BinaryImage); % Number Of ‘1’ Values
Frac_1 = NrEq_1/numel(BinaryImage); % Fraction Of Total That Are ‘1’ Values

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

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by