필터 지우기
필터 지우기

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

조회 수: 7 (최근 30일)
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 CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by