[Insight-developers] Removing PhysicalPoitnToIndex() from itkImage ?

Luis Ibanez luis.ibanez@kitware.com
Thu, 21 Feb 2002 17:56:33 -0500


Hi Damion,



Damion Shelton wrote:

> This is no longer true... right? (quoting from a previous email)
>
> ---
> 4) itk::Image no longer has an AffineTransform but rather
>   a SmartPointer to a generic itk::Transform. That allows to plug
>   any kind of transform into an image. By default an Affine
>   transform is plugged in but it can be replaced by any other
>   transform after the image has been constructed.


The image transform is now (not checked in yet..) of type itkTransform<>
but the PhysicalPointToIndex methods are instantiating AffineTransforms
directly.  The idea of the helper classes is to remove the hardcoded 
AffineTransforms
from the Image and delegate the taks of converting Indexes to Points to 
another
class.  This is already done this way in the ImageFunction classes.

In other words, this is one of the last places we need to modify in 
order to have
a generic transform on the image.

>> Does anybody see a disadvantage in outsourcing
>> these conversions from the itkImage    ?
>
>
> Yes. Transforming from indices to points is a very common operation. 
> Outsourcing the conversion would require several extra operations each 
> time the conversion occurs. For a given function that requires 
> coordinate conversion:
>
> ConverterType::Pointer converter = 
> itkOutsourceCoordinateConverter::New();
> converter->SetTransform(myImage->GetTransform() );
> converter.Map(index,point);
>
> Rather than the current implementation:
>
> ImagePointer->TransformPhysicalPointToIndex(point, index)


You're right,
The conversion requires more lines of code if we are mapping a single point.
I was assuming implicitly that when we map points they come in numbers of
thousands. In that case, the creation of the helper class is factorized, 
something
like:

IndexImageFunction::Pointer converter = IndexImageFunction::New()
converter->SetInputImage( myImage );  // the transform is cached here
for all my points
  {
   IndexType  index  = converter->Evaluate( point[i] );
   }

>
> Given that we now (apparently) can plug in pointers to arbitrary 
> transforms, what's the advantage of adding an extra 2 lines of code 
> every time you want to transform coordinates?


Well,
so far is useless to plug an arbitrary Transform if these methods 
instantiate
an AffineTransforms.

Can we just remove the creation of the AffineTransforms  and assume that
there will always be a valid transform plugged into the pointer ?



Luis