[Insight-users] On ReSampleImageFilter ...

Luis Ibanez luis . ibanez at kitware . com
Tue, 06 Aug 2002 09:00:53 -0400


Hi cspl,

ITK is not using homogenous coordinates.

The Affine Transform in N-D is expecting

1) a NxN matrix "M"
2) a Nx1 vector "T"

A typical point "P" is mapped through this
transform by the operation

     P' =  M.P + T

The matrix "M" contains the rotational
components (+ shearing) of the transform,
while the vector "T" contains the translational
components of the transform.

You probably defined your 4x4 matrix as

      | M  T |
      | 0  1 |

In the Doxygen manual page of the Affine Transform

http://www.itk.org/Insight/Doxygen/html/classitk_1_1AffineTransform.html

you will find the two methods

   void SetOffset (const OffsetType &offset)
   void SetMatrix (const MatrixType &matrix)


BTW is also more convenient to take advantage of the
typedefs already decleared in the Transform itself.
For example, instead of declaring a

     itk::Matrix<double,4,4>    myMatrix;

you may use

     myTransformType::MatrixType   myMatrix;

--

Please let us know if you encouter any problem
setting up the affine transform.

   Thanks

     Luis


================================================
cspl wrote:
> Dear Friends,
>  I am having 4X4 matrix(output of some other function),I want to apply 
> this on Image/Volume.I used the class ResampleImagefilter available in 
> ITK to do this task.I found that AffineTranformation is the default 
> Transformation type it takes.
> In the AffineTranformation class I found one method SetMatrix();As I 
> want to transform a volume (3D) image I tried to set 4X4 matrix for the 
> setMatrix() function.But,It is accepting only 3X3 matrix.Plese give me 
> suggestions in doing my task.I am enclosing the code and error also.
> 
>  
> 
> //code
> 
>  
> 
>    typedef itk::Matrix<double,4,4> matrixdef;
>    matrixdef  mat; 
>    ImageType::Pointer InputImage=NULL;//ImageType::New();
>    InputImage=BufferToImage(pIctal);
>    typedef itk::ResampleImageFilter<ImageType,ImageType>    ResampleFilter;
>    ResampleFilter::Pointer Resample=ResampleFilter::New();
>    typedef itk::AffineTransform<double,3> AffineDef;
>    AffineDef::Pointer Affine=AffineDef::New();
>    Affine->SetMatrix(mat);  //mat is  the matrix of 4X4
>  
>     Resample->SetTransform(Affine);
>     itk::Size<3> size = {pIctal->height,pIctal->width,pIctal->depth };
>     Resample->SetInput(InputImage);
>     Resample->SetSize(size);
>     double values[3];
>     values[0]=1.62;
>     values[1]=1.62;
>     values[2]=1.0;
>     Resample->SetOutputSpacing(values);
>     Resample->Update();
> 
>  
> 
>  //error
> 
>  
> 
> e:\ipservercspl9\ipserverdoc.cpp(996) : error C2664: 'SetMatrix' : 
> cannot convert parameter 1 from 'class itk::Matrix<double,4,4>' to 
> 'const class itk::Matrix<double,3,3> &'
>         Reason: cannot convert from 'class itk::Matrix<double,4,4>' to 
> 'const class itk::Matrix<double,3,3>'
>         No constructor could take the source type, or constructor 
> overload resolution was ambiguous
> Error executing cl.exe.
> 
>  
> 
> Regards,
> CSPL
>