[Insight-users] Re: Cartesian to polar filter in ITK

Ali - saveez at hotmail.com
Mon Jan 22 10:56:57 EST 2007


Jakub,
 
There is one slight problem for when r = 0, this causes the crash.
The following fixes the crash and also gives a full circular area.
Note that I used (r, theta) and NOT (theta, r) as the output coordinate.
 
in function TransformPoint:
 
OutputPointType opoint(point);
opoint[0] = sqrt( point[0] * point[0] + point[1] * point[1] );
if(point[0] != 0)
{
opoint[1] = acos( point[0] / opoint[0] );
}
else
{
opoint[1] = 0;
}
if(point[0] < 0 || point[1] < 0 )
{
opoint[1] = 2 * vnl_math::pi - opoint[1];
}
return opoint;
 
-----
 Hi.

I checked the code and the paper and i found some typos in the paper.
The code was good. You can compute the  angle as acos(x/r), same as
atan(y/x) (better atan2(y,x)). These options are mathematically
equivalent. I modulate negative angle values, so that the angle is
always in [0,360]

I had typo in the paper so that there was acos(x/y) instead of
acos(x/r), but in the code it was correct.

By definition, polar transform is located in the center of cartesian
coordinate system. In the ITK transform layout, geometrical transforms
do not know anything about images so it is not possible to determine
the center of the image. The solution is (as you wrote) to set the
origin to -1*Size*Spacing*0.5 in each dimension. In this way, you can
also set the center to any aother point of the image. I am sure that
this will not crash as i am using the same code in my experiments...

Regards,

        Jakub
_________________________________________________________________
Be one of the first to try Windows Live Mail.
http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070122/b28e6e6f/attachment.html


More information about the Insight-users mailing list