Image intensity histogram - radial

9 Ansichten (letzte 30 Tage)
Johnathan Viernik
Johnathan Viernik am 17 Aug. 2016
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)

Akzeptierte Antwort

Image Analyst
Image Analyst am 17 Aug. 2016
Been there, done that, see attached demos.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by