フィルターのクリア

how to remove a bar from histogram which drawn using 'hist' function?

7 ビュー (過去 30 日間)
Nermeen alami
Nermeen alami 2013 年 2 月 22 日
hi can anyone help me to remove zeros bar in histogram this is a part of the code . i'm new in matlab so pleas help me
[hCount, hValues] = hist(h(:), 6);
[sCount, sValues] = hist(s(:), 6);
[vCount, vValues] = hist(v(:), 6);
% Plot histograms.
subplot(3, 4, 6);
bar(hValues, hCount);
title('Hue Histogram');
subplot(3, 4, 7);
bar(sValues, sCount);
title('Saturation Histogram');
subplot(3, 4, 8);
bar(vValues, vCount);
title('Value Histogram');

採用された回答

Tom Lane
Tom Lane 2013 年 2 月 22 日
If you want to omit zeros from the bar calculations:
hist(h(h~=0), 6)
Depending on your data, this may omit the bar that contains zero.
If you want to omit bars that have zero height, well, when I try this I don't see anything at those spots. Maybe you could explain some more.

その他の回答 (1 件)

Image Analyst
Image Analyst 2013 年 2 月 22 日
Sometimes your counts have one bar that you want to get rid of, for example the bar for the v bin representing a v value of 0 is so tall that when you display it you can't see the other bars because they're so short. To do that, I typically just set that counts value to zero before plotting.
[vCount, vValues] = hist(v(:), 6);
% Let's say the first bin is way, way taller than the other bins
% so you can't see the shape of the histogram of the other bins.
% You can set the bin = 0
vCount(1) = 0;
% Then plot it
bar(vValues, vCount, 'BarWidth', 1.0);
Alternatively you can take the log of the counts to compress the tall bins:
bar(vValues, log(vCount), 'BarWidth', 1.0);

カテゴリ

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