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

1 visualización (últimos 30 días)
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.

Respuesta aceptada

Pratik Anand
Pratik Anand el 24 de Jul. de 2017
Editada: Pratik Anand el 24 de Jul. de 2017
You can use cart2pol command to achieve that. You can refer to its documentation here

Más respuestas (1)

Image Analyst
Image Analyst el 24 de Jul. de 2017
Why do you have all these cases? Simply scan the image pixel-by-pixel computing the radius and angle (using the atan2d function) of each pixel from the circle center.

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by