Asked by Kevin Wang
on 4 Feb 2016

I am looking to compute a radial average of a 2-d tif microscopy image.

I want to start from a given pixel as the center, go progressively radially and record the intensities of all the pixels lying on the locus of the circle of that radius. Out of all these, I want to compute a graph of radius vs. Intensity.

Any ideas? I am looking to create a .m file to do this. Thank you!

Answer by Image Analyst
on 4 Feb 2016

Edited by Image Analyst
on 12 Sep 2019

Accepted Answer

Sign in to comment.

Answer by Image Analyst
on 4 Feb 2016

Edited by Image Analyst
on 12 Sep 2019

Sign in to comment.

Answer by Hugo Trentesaux
on 7 Feb 2019

Edited by Hugo Trentesaux
on 11 Sep 2019

My version of the function :

function profile = radialAverage(IMG, cx, cy, w)

% computes the radial average of the image IMG around the cx,cy point

% w is the vector of radii starting from zero

[a,b] = size(IMG);

[Y, X] = meshgrid( (1:a)-cx, (1:b)-cy);

R = sqrt(X.^2 + Y.^2);

profile = [];

for i = w % radius of the circle

mask = (i-1<R & R<i+1); % smooth 1 px around the radius

values = (1-abs(R(mask)-i)) .* double(IMG(mask)); % smooth based on distance to ring

% values = IMG(mask); % without smooth

profile(end+1) = mean( values(:) );

end

end

Stefan Weichert
on 11 Sep 2019

there is one error in your code:

You have to switch around X and Y. Otherwise you end up with complete nonsense.

Hugo Trentesaux
on 11 Sep 2019

You're right.

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.