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

Jakub Bican jakub.bican at matfyz.cz
Mon Jan 22 15:30:03 EST 2007


AAHH, zero ... i rather never approach it :)))

then it is better to do this:

 opoint[0] = sqrt( point[0] * point[0] + point[1] * point[1] );
 opoint[1] = atan2( point[1] , point[0] );

 //now adjust the range of angular coordinate from [-pi,pi] to [0,2pi]
 if( opoint[1] < 0 )
  {
  opoint[1] = 2 * vnl_math::pi + opoint[1];
  }
  return opoint;

What do you think about it?

And ... Is there some reason to have (r, theta) rather than (theta,
r)? (I simply selected the second...)

Thanks and bye,

       Jakub

2007/1/22, Ali - <saveez at hotmail.com>:
>
> 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.
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>
>


More information about the Insight-users mailing list