Expressing every point of my image in polar coordinates, where the origin is a point that was chosen from the image
    3 views (last 30 days)
  
       Show older comments
    
    Damian Wierzbicki
 on 20 Jul 2017
  
    
    
    
    
    Answered: Image Analyst
      
      
 on 24 Jul 2017
            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.
0 Comments
Accepted Answer
More Answers (1)
  Image Analyst
      
      
 on 24 Jul 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.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!