I don't understand why the last line is wrong
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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);
Réponses (2)
Rik
le 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 commentaires
Image Analyst
le 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 commentaires
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!