Image intensity histogram - radial

2 次查看(过去 30 天)
I have an image with (reasonable) radial symmetry. I would like to generate an intensity histogram as a function of distance from the origin, i.e. average the intensity over small "rings" and display the mean intensity of each ring.
I wrote the following code, but obviously it's very inefficient due to loop usage. Is there a more elegant solution for this problem, perhaps a built-in one? I haven't found on the web. Thanks.
x = 609; y = 513; % captured from snapshot
distmat = zeros(size(getsnapshot(vid1)));
[r,c] = size(distmat);
for i = 1:r
for j = 1:c
distmat(i,j) = sqrt((i-y)^2+(j-x)^2);
end
end
uni = unique(distmat);
rad = zeros(size(uni));
for i = 1:length(uni);
rad(i) = sum(avgim(distmat == uni(i))) / length(avgim(distmat == uni(i)));
end
bar(rad)

采纳的回答

Image Analyst
Image Analyst 2016-8-17
Been there, done that, see attached demos.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by