MATLAB: Expressing every point of the image in polar coordinates, where the origin is a point that was chosen from the image

image processing; polar coordinates;

Hi guys. I have an image with a circle at the centre of it. Now, I want to express every point in my image in terms of polar coordinates ( I am more interested in evaluating the angles ) the origin being the centre of the circle. So far I've done this:
if true
I = imread ( Image );
I1 = size ( I );
R = ( I1 ( 1 ) ) ;
C = ( I1 ( 2 ) ) ;
[ Rv , Cv ] = ndgrid ( 1:R , 1:C ) ;
% I've already calculated the location of the circle using imfindcircles
Rv_transla = Rv - centres ( 2 );
Cv_transla = Cv - centres ( 1 );
% and then this horrible loop to account for all the cases
for c = 1:C ;
for r = 1:R ;
if Cv_transla ( r , c ) > 0;
angle ( r , c ) = atand ( Rv_transla ( r , c ) / Cv_transla ( r , c ));
else if ( Cv_transla ( r , c ) < 0 & Rv_transla ( r , c ) < 0 );
angle ( r , c ) = atand ( (Rv_transla ( r , c ) / Cv_transla ( r , c )) - 180 );
else if ( Cv_transla ( r , c ) == 0 & Rv_transla > 0 );
angle ( r , c ) = 90;
else if ( Cv_transla ( r , c ) == 0 & Rv_transla < 0 );
angle ( r , c ) = -90;
else if ( Cv_transla ( r , c ) == 0 & Rv_transla == 0 );
angle ( r , c ) = 'undefined'
end
end
end
end
end
end
end
% which does not give me the expected results. I know it's really messy, but any help would be much appreciated. I've attached the image just to give you a better idea.
Thanks.

Best Answer

You can use cart2pol command to achieve that. You can refer to its documentation here