[ITK-users] Polar2Cartesian Behavior

Matt McCormick matt.mccormick at kitware.com
Sun Sep 11 21:47:28 EDT 2016


On Sun, Sep 11, 2016 at 9:19 PM, Somesh <someshsandbox at gmail.com> wrote:
> Thanks Matt. In step 3, I generate a polar image and in Step 4 I want to get
> the corresponding cartesian image. Since in Step 3, the maximum radius of my
> polar image is R=20 , so I have the cartesian image range from -R to R for
> both X and Y and I set the default pixel to 0. The pixels in the polar image
> have value equal to R. So I expected a circular image similar to step 1.
> However I get a distorted/cropped semi-circle.

It looks like your Transform is inheriting from itk::AffineTransform,
although it is not an AffineTransform. AffineTransform is a linear
transform, and the ResampleImageFilter takes advantage of that
property to optimize its computation:

  https://github.com/InsightSoftwareConsortium/ITK/blob/6ee10575445aa1c878797db4febf7d775a38f1f3/Modules/Filtering/ImageGrid/include/itkResampleImageFilter.hxx#L242-L249

So, your class need to override ->GetTransformCategory() to return
UnknownTransformCategory.


> The use case of this program is the following. I have a cylindrical image. I
> have to re-sample it at finer intervals in theta. Then I want to convert it
> to cartesian co-ordinates. Given a polar to cartesian transform, shouldn't
> the resample image filter be able to handle this ?

Yes, but the SpecialCoordinatesImage allows you to keep your data in
native form and it prevents abuse of "spacing", etc.


> Regarding the CurvilinearArraySpecialCoordinatesImage class. How can I use
> it to convert a cylindrical image to Cartesian image ? Since it is an
> "Image" class and not a "Transform" class, I am a little unclear on how to
> use it. Should I manually create the desired cartesian grid, find the
> co--responding polar co-ordinate using
> CurvilinearArraySpecialCoordinatesImage APIs and fill in the pixels. Also do
> have have to manually handle the interpolation ? Or can I still use the
> ResampleImageFileter to do these steps ?

Yes, you can use ResampleImageFilter and this class to perform the
desired operations. Here is an example:

 https://github.com/KitwareMedical/ITKUltrasound/blob/0cb92288333a9779da57511f779d0bde5ca35275/test/itkCurvilinearArraySpecialCoordinatesImageTest.cxx#L96-L110

HTH,
Matt


More information about the Insight-users mailing list