[Insight-users] arbitrary warp filter

Luis Ibanez luis.ibanez at kitware.com
Wed, 14 Apr 2004 16:16:38 -0400


Hi Rahul,

You are right,
Generating the full vector field is also an easy way of
implementing your transform. The WrapImageFilter will
take that deformation field and resample your image.

Just make sure that the deformation field has the same
extent (initial index,  number of pixels, physical origin
and pixel spacing) as the image that you want obtain
*after* resampling.

It may still be worth for you to try implementing the ITK
Transform. You are in the lucky situation where you only
need to implement a single method (TransformPoint()).



   Regards,


      Luis



---------------------
Rahul Chander wrote:

> Hi Luis,
> Thanks for your email.  I just thought of another solution that may 
> be used to solve the same problem.  Basically I would create a 
> deformation field according to a given tranformation over the set of 
> possible co-ordinates.  And then I would use the warp image filter, 
> and apply this field to the original image.   
> Thanks.
> Rahul.
> 
> On April 14, 2004 10:28 am, you wrote:
> 
>>Hi Rahul,
>>
>>Writing a new ITK Transform is quite simple specially
>>if you only want to use it for resampling an image.
>>
>>Things are a bit more difficult if you want to use the
>>transform inside the Image Registration framework,
>>because in that case you should provide Jacobians with
>>it and make sure that you encode the transform parameters
>>in an array of doubles.
>>
>>
>>In your case you could simply take a basic transform
>>such as the itkTranslationTransform
>>
>>http://www.itk.org/Insight/Doxygen/html/classitk_1_1TranslationTra
>>nsform.html
>>
>>Rename it and implement your transformation process
>>in the method:
>>
>>             TransformPoint();
>>
>>Note that ITK is not restricted to use transforms that
>>can be represented with a matrix (as you would expect from
>>graphics software packages). You can directly implement
>>your Transform in ITK by making "{a,b,c,d,e,f}"  be
>>(private) member variables of the Transform. Please create
>>Set/Get methods for them using the itkGet/Set macros, and
>>then write your transformation equation directly into the
>>TransformPoint() method.
>>
>>Once you have a prototype of your transform you can use it
>>for resampling images by pluging this transform into the
>>itk::ResampleImageFilter.
>>http://www.itk.org/Insight/Doxygen/html/classitk_1_1ResampleImageF
>>ilter.html
>>
>>You are *strongly* encouraged to read the section about
>>resampling in the SoftwareGuide.
>>
>>      http://www.itk.org/ItkSoftwareGuide.pdf
>>
>>Section 6.7.1, pdf-page 199. Note that there are multiple
>>source code example associated with this text into the
>>Insight/Examples/Filtering directory.
>>
>>Studying this section will help you a lot in the process of
>>understanding how resampling works and how to interpret its
>>results.It is common for first users to have trouble with
>>the interpretation of the forward or backward transform.
>>
>>
>>
>>Regards,
>>
>>
>>    Luis
>>
>>
>>
>>--
>>
>>Just FYI, you fill find the entire list of ITK transforms
>>in the 'groups' section of Doxygen documentation:
>>http://www.itk.org/Insight/Doxygen/html/group__Transforms.html
>>
>>
>>
>>
>>
>>--------------------
>>
>>Rahul Chander wrote:
>>
>>>Hello itk developers,
>>>I need to implement an arbitrary transform which is non-linear
>>>in nature.
>>>The transform acting on physical co-ordinates (x0,y0) produces
>>>(x1,y1) and can look something like this for 2D:
>>>[x1;y1]'=[g(x0,y0);h(x0,y0)]',  where g, h are arbitrary
>>>functions.
>>>
>>>e.g.
>>>[x1;y1] = [ax^2+by^3+c; d xy+ e y^2+f]
>>>
>>>for x=x0, y=y1
>>>and constants a,b,c,d,e,f.
>>>
>>>I was thinking of starting off with a simple 2D transform's .txx
>>>and .h files to implement my own transform according to the
>>>above function.  At this point I do not know where in the itk
>>>code the transform matrix gets multiplied with a point's
>>>co-ordinates to result in the new set of co-ordinates.
>>>
>>>ie.  [x1;y1]' = [some function of (x,y)] * [x0;y0]'   <--- where
>>>in itk does this multiplication operation occur?
>>>
>>>Secondly, which transform's code would be the easiest to modify
>>>for my needs. And last of all, is there a way around all this
>>>without going into low level implementation?
>>>
>>>Thanks in advance.
>>>Rahul.
> 
>