Clear Filters
Clear Filters

OVERLAY OF HISTOGRAMS error in variables

1 view (last 30 days)
sofia cirne
sofia cirne on 20 Jun 2017
Commented: aditya sahu on 4 Oct 2017
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!

Answers (1)

Image Analyst
Image Analyst on 20 Jun 2017
Edited: Image Analyst on 20 Jun 2017
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 Comments
Image Analyst
Image Analyst on 20 Jun 2017
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)
aditya sahu
aditya sahu on 4 Oct 2017
are you trying for pdh analysis

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!