I don't understand why the last line is wrong
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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);
1 Kommentar
Antworten (2)
Rik
am 30 Mai 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 Kommentare
Image Analyst
am 30 Mai 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 Kommentare
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!