[ITK] [ITK-users] Apply rigid transform by changing image information

Hammond, Emily M emily-hammond at uiowa.edu
Fri Feb 19 16:43:31 EST 2016


Hello,

Context: I am applying a rigid registration process to align two images. The transform allows for anisotropic scaling, a translation, and a versor rotation. I have perform the registration and checked my results by loading the resulting transform into 3D Slicer and applying it to the moving image.

Problem: I am trying to apply the transform to the moving image without resampling, so just changing the image information. Essentially, I want to perform the equivalent of "Harden Transform" in Slicer. I have been following this example (http://www.itk.org/Doxygen/html/Examples_2RegistrationITKv3_2ChangeInformationImageFilter_8cxx-example.html#_a3) to change my image information.

To apply the scaling, I simply multiplied the spacing by the corresponding scale factor. For translation, I added the translation to the origin. For applying the rotation, the example shows to multiply the image direction matrix by the versor rotation matrix. The new spacing, origin, and direction matrix are then input into the new change information image filter.

I have done this, however, when using Slicer to load in the final image, the transform does not show to have been applied correctly. I have been saving my images as MetaImage files (.mhd) so the image information is saved in the header file. Can anyone please give me some advice on how to perform this task appropriately?

Here is my code:

// get image properties
            ImageType::PointType origin = image->GetOrigin();
            ImageType::SpacingType spacing = image->GetSpacing();
            ImageType::DirectionType direction = image->GetDirection();

            // get transform parameters
            TransformType::TranslationType translation = transform->GetTranslation();
            TransformType::ScaleVectorType scale = transform->GetScale();
            TransformType::VersorType versor = transform->GetVersor();

            // apply scaling and translation parameters to image
            for( int i = 0; i < 3; i++ )
            {
                  spacing[i] *= scale[i];
                  origin[i] += translation[i];
            }

            // apply rotation to image
            ImageType::DirectionType newDirection = direction*versor.GetMatrix();

            // allocate hardening filter
            typedef itk::ChangeInformationImageFilter< ImageType > HardenTransformFilter;
            HardenTransformFilter::Pointer harden = HardenTransformFilter::New();
            harden->SetInput( image );

            // set new parameters
            harden->SetOutputSpacing( spacing );
            harden->SetOutputOrigin( origin );
            harden->SetOutputDirection( newDirection );

            // turn change flags on
            harden->ChangeSpacingOn();
            harden->ChangeOriginOn();
            harden->ChangeDirectionOn();

            harden->Update();

Thanks in advance!
Emily Hammond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20160219/bfdfda82/attachment.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list