I don't understand why the last line is wrong
1 view (last 30 days)
Show older comments
sz = size(img);
out_sz = size(gray);
BinEdges = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];
r = 377;
%ben trai
for ca=0:197
a = randn(r, ca);
end
figure
q = histogram(a);
%ben phai
for cb = 198:394
b = randn(r, cb);
end
figure
w = histogram(b);
figure
e = abs(q-w);
Answers (2)
Rik
on 30 May 2023
Your syntax is confusing. I don't think this code does what you think it does. The a and B variables are overwritten every iteration, so only the last is used.
The underlying cause is probably that you don't explicitly use the same bins for the two histograms, so the chance they happen to be the same is slim.
0 Comments
Image Analyst
on 30 May 2023
Not sure what your goal is, but you can't subtract histogram objects. Perhaps you want to use histcounts() or get a property of your histogram objects. But you need to make sure the arrays are the same size (histograms have the same numbers of bins). So you might need to send in the 'Edges' array to histogram to make sure of that.
img = imread('cameraman.tif');
sz = size(img);
out_sz = size(gray);
BinEdges = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];
r = 377;
%ben trai
for ca=0:197
a = randn(r, ca);
end
figure
q = histogram(a)
%ben phai
for cb = 198:394
b = randn(r, cb);
end
figure
w = histogram(b)
figure
e = abs(q-w);
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!