[Insight-users] transform inverse?
Lars Hegenbart
Lars.Hegenbart at hs.fzk.de
Tue Oct 7 03:28:30 EDT 2008
Thank you for clarifying this!
I am still confused about this. Is there a reason, why ITK does it
this way?
And how about a transform, determined by registration?
Will it give me the appropriate transform for backward warping with
ResampleImageFilter or do I have to invert the matrix somehow to apply
the transform to my moving image, in order that it aligns with my
fixed image?
Thanks in advance for your hints!
Lars
Am 06.10.2008 um 17:55 schrieb Aviv Hurvitz:
> Hi,
>
> If I understand correctly, you expected your transform to be applied
> to the input image. This is called "forwards warping".
>
> In ITK, the ResampleImageFilter does "backwards warping": it uses
> the transform to go from the OUTPUT image to the INPUT image. In
> your case, the output pixel at 1,1,1 takes its color from 2,2,2, the
> output pixel at 2,2,2 takes its color from 4,4,4, etc. Your affine
> transform gives you a half-sized image.
>
> Hope that explains it.
>
> - Aviv
>
>
>
> On Mon, Oct 6, 2008 at 4:39 PM, Hegenbart, Lars <Lars.Hegenbart at hs.fzk.de
> > wrote:
> Dear ITK-community,
>
> I am defining an affine transform with [2, 0, 0, 0, 2, 0, 0, 0, 2,
> 0, 0, 0], basically a stretch of factor 2 in all 3 dimensions. I
> want to
> apply it to an input image to create an output image with same
> parameters (spacing, etc.). I end up getting an output which is scaled
> by a factor of 0.5 instead of 2. If I choose 0.5 in the diagonal of
> the
> matrix of the affine transform, I end up with the wanted result.
> It seems somehow to be inverted. What's wrong or is that normal?
>
> Thanks for any hints.
>
> Best regards
> Lars
>
> PS: here some relevant code parts:
>
> typedef itk::Image< unsigned char, Dimension > InputImageType;
> typedef itk::Image< unsigned char, Dimension > OutputImageType;
> InputImageType::Pointer i_image;
> OutputImageType::Pointer o_image;
>
> InputImageType::SpacingType spacing;
> spacing[0] = 6; //spacing along x
> spacing[1] = 6; //spacing along y
> spacing[2] = 6; //spacing along z
> i_image->SetSpacing(spacing);
> InputImageType::PointType origin;
> origin[0] = 0;
> origin[1] = 0;
> origin[2] = 0;
> i_image->SetOrigin(origin);
> InputImageType::SizeType size;
> size[0] = 100; // size along x
> size[1] = 100; // size along y
> size[2] = 100; // size along z
>
> typedef itk::AffineTransform< double, Dimension >
>
> TransformType;
> TransformType::Pointer transform;
>
> typedef TransformType::ParametersType ParametersType;
> const unsigned int numberOfParameters = transform-
> >GetNumberOfParameters();
> ParametersType parameters( numberOfParameters );
> parameters_affine[ 0]= 2;
> parameters_affine[ 1]= 0;
> parameters_affine[ 2]= 0;
> parameters_affine[ 3]= 0;
> parameters_affine[ 4]= 2;
> parameters_affine[ 5]= 0;
> parameters_affine[ 6]= 0;
> parameters_affine[ 7]= 0;
> parameters_affine[ 8]= 2;
> parameters_affine[ 9]= 0;
> parameters_affine[10]= 0;
> parameters_affine[11]= 0;
> transform->SetParameters( parameters);
>
> typedef itk::ResampleImageFilter< InputImageType,
> OutputImageType >
> FilterType;
> FilterType::Pointer filter = FilterType::New();
> filter->SetTransform(transform);
>
> typedef itk::NearestNeighborInterpolateImageFunction<
> InputImageType, double > InterpolatorType;
> InterpolatorType::Pointer interpolator =
> InterpolatorType::New();
> filter->SetInterpolator(interpolator);
> filter->SetDefaultPixelValue(0);
>
> filter->SetOutputSpacing(i_image->GetSpacing()); // same
> spacing
> like InputImage
> filter->SetOutputOrigin(i_image->GetOrigin()); // same like
> InputImage
> filter->SetSize(size); // same like InputImage
> filter->SetInput(i_image);
>
> o_image = filter->GetOutput();
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------------------------------------
Dipl.-Ing. (FH) Lars Hegenbart
Forschungszentrum Karlsruhe GmbH
in der Helmholtz-Gemeinschaft
Abteilung HS/KES
Hermann-von-Helmholtz-Platz 1
76344 Eggenstein-Leopoldshafen
Germany
Tel. +49-7247-82-3419
lars.hegenbart at kit.edu
http://www.hs-kes.de
More information about the Insight-users
mailing list