[Insight-users] ITK Rigid2DTransform - introduces shearing ?

John D john.dz.eis at gmail.com
Wed Jan 27 00:27:38 EST 2010


Dear all,

  When using Rigid2DTransform to transform an image, I seem to be getting a
shearing of the result. I was actually trying to compare the results between
an ITK prototype and an IPP implementation of an algorithm when I started
noticing the difference. Please see the attached images. I drew in a grid
into the image to see what was causing the difference and it seems like the
image I obtain by transforming using the Rigid2DTransform has a shear in it
while the IPP one does not have the shear as expected. All I am trying to do
here is to rotate the image by 30 degrees around the center of the image.
Any thoughts on what could be going wrong ?

This is the code I am using for the ITK transform function

    typedef itk::ResampleImageFilter< enFaceImageType, enFaceImageType >
ResampleFilterType;
    // A resampling filter is created and the image is connected as its
input:
    ResampleFilterType::Pointer resampler = ResampleFilterType::New();
    resampler->SetInput( image );

    // Set the transformation according to our input values:
    typedef itk::Rigid2DTransform< double > TransformType;
    TransformType::Pointer transform = TransformType::New();

    // Set the parameters of the transform by passing them in an array:
    typedef TransformType::ParametersType ParametersType;
    ParametersType manualParameters( transform->GetNumberOfParameters() );
    manualParameters[0] = dRad;        // Angle
    manualParameters[1] = xTrans;    // Initial offset in mm along X
    manualParameters[2] = yTrans;    // Initial offset in mm along Y

    transform->SetParameters( manualParameters );

    TransformType::InputPointType center;
    center[0] = centerX;
    center[1] = centerY;
    transform->SetCenter(center);

    resampler->SetTransform( transform );


    // Take sizes from the fixed image, as that is what we are registering
to:
    resampler->SetSize( image->GetLargestPossibleRegion().GetSize() );
    resampler->SetOutputOrigin( image->GetOrigin() );
    resampler->SetOutputSpacing( image->GetSpacing() );
    resampler->SetDefaultPixelValue( 0.0 );


    if (interpolation==0)
    {
        typedef
itk::NearestNeighborInterpolateImageFunction<enFaceImageType, double >
InterpolatorType;
        InterpolatorType::Pointer interpolator = InterpolatorType::New();
        resampler->SetInterpolator(interpolator);
    }
    if (interpolation==1)
    {
        typedef itk::LinearInterpolateImageFunction<enFaceImageType, double
>  InterpolatorType;
        InterpolatorType::Pointer interpolator = InterpolatorType::New();
        resampler->SetInterpolator(interpolator);
    }

    resampler->Update();

    iStatus = EXIT_SUCCESS;
    return ( resampler->GetOutput() );


Thanks,
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100126/2eb5ee87/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: original.png
Type: image/png
Size: 16686 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100126/2eb5ee87/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: itk-rigid-transformed.png
Type: image/png
Size: 16793 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100126/2eb5ee87/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ipp-rigid-transformed.png
Type: image/png
Size: 16848 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100126/2eb5ee87/attachment-0005.png>


More information about the Insight-users mailing list