Expressing every point of my image in polar coordinates, where the origin is a point that was chosen from the image
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(1 个)
Image Analyst
2017-7-24
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!