OVERLAY OF HISTOGRAMS error in variables

1 次查看(过去 30 天)
im trying to overlay to histograms in one graph, but i have this error taht i cant understand.
x = handles.grey;
y = handles.binaria
nbins = 50;
bound = 1;
bins = linspace(-bound,bound,nbins);
% %b = histeq(X);
% first histogram
y1 = hist(x, bins);
% second histogram
y2 = hist(y, bins);
% overlay histograms
bar(y1.');
hold on;
bar(y2.','r');
the error given is
Error using hist (line 48)
Input arguments must be numeric.
Error in untitled>histograma_Callback (line 112)
y2 = hist(y, bins);
y is a black and white image, binary, it was converted to double, however it doesnt work. thank you!

回答(1 个)

Image Analyst
Image Analyst 2017-6-20
编辑:Image Analyst 2017-6-20
What does this say
whos y
Also, maybe you can try imhist(), histogram(), or histcounts().
Anyway, it makes no sense to have 50 bins, or actually bin edges which is what you're passing in, for a binary image. You will have no counts except in the bins for 0 and 1.
  3 个评论
Image Analyst
Image Analyst 2017-6-20
Are you going to answer my question about "whos y", or not?
And, like I said, use imhist() and the problem should go away.
counts = imhist(y);
bar(counts, 'BarWidth', 1)

请先登录,再进行评论。

类别

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