[Insight-users] ITK Rigid2DTransform - introduces shearing ?

Luis Ibanez luis.ibanez at kitware.com
Thu Jan 28 11:44:01 EST 2010


Hi John,

Thanks for letting us know that
you found the solution to the problem.

     Regards,

           Luis


---------------------------------------------------
On Wed, Jan 27, 2010 at 3:58 PM, John D <john.dz.eis at gmail.com> wrote:
> Thank you Luis. Yes..I have anisotropic pixels and that was causing the
> appearance of shear.
>
> Regards,
> John
>
> On Wed, Jan 27, 2010 at 11:35 AM, Luis Ibanez <luis.ibanez at kitware.com>
> wrote:
>>
>> Hi John,
>>
>> What is the pixel spacing (along X and Y) of the original image ?
>>
>>
>> The appearance of shearing may be the result of using PNG files to store
>> the output images. PNG doesn't carry along the pixel information of your
>> image.  Therefore, when you display it with naive viewers, the proportions
>> of the image may get distorted, an a appearance of shearing may be
>> observed.
>>
>> You may want to make sure that you use both
>>
>>   (A)   a file format   and
>>   (B)   an image viewing program
>>
>> that supports (takes into account) image spacing.
>>
>> Common combinations are:
>>
>>
>>   (A)  MetaImage
>>   (B)  The ImageViewer tool in InsightApplications
>>
>>
>> Regards,
>>
>>
>>         Luis
>>
>>
>>
>> -----------------------------------------------------------------------------------------------
>> On Wed, Jan 27, 2010 at 12:27 AM, John D <john.dz.eis at gmail.com> wrote:
>> > 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
>> >
>> > _____________________________________
>> > 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.html
>> >
>> > 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://www.itk.org/mailman/listinfo/insight-users
>> >
>> >
>
>


More information about the Insight-users mailing list