I don't understand why the last line is wrong
1 次查看(过去 30 天)
显示 更早的评论
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);
回答(2 个)
Rik
2023-5-30
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 个评论
Image Analyst
2023-5-30
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!