Dear all,<br><br> 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 ? <br>
<br>This is the code I am using for the ITK transform function<br><br> typedef itk::ResampleImageFilter< enFaceImageType, enFaceImageType > ResampleFilterType;<br> // A resampling filter is created and the image is connected as its input:<br>
ResampleFilterType::Pointer resampler = ResampleFilterType::New();<br> resampler->SetInput( image );<br><br> // Set the transformation according to our input values:<br> typedef itk::Rigid2DTransform< double > TransformType;<br>
TransformType::Pointer transform = TransformType::New();<br><br> // Set the parameters of the transform by passing them in an array:<br> typedef TransformType::ParametersType ParametersType;<br> ParametersType manualParameters( transform->GetNumberOfParameters() );<br>
manualParameters[0] = dRad; // Angle<br> manualParameters[1] = xTrans; // Initial offset in mm along X<br> manualParameters[2] = yTrans; // Initial offset in mm along Y<br><br> transform->SetParameters( manualParameters );<br>
<br> TransformType::InputPointType center;<br> center[0] = centerX;<br> center[1] = centerY;<br> transform->SetCenter(center);<br><br> resampler->SetTransform( transform );<br> <br><br> // Take sizes from the fixed image, as that is what we are registering to:<br>
resampler->SetSize( image->GetLargestPossibleRegion().GetSize() );<br> resampler->SetOutputOrigin( image->GetOrigin() );<br> resampler->SetOutputSpacing( image->GetSpacing() );<br> resampler->SetDefaultPixelValue( 0.0 );<br>
<br> <br> if (interpolation==0)<br> {<br> typedef itk::NearestNeighborInterpolateImageFunction<enFaceImageType, double > InterpolatorType;<br> InterpolatorType::Pointer interpolator = InterpolatorType::New();<br>
resampler->SetInterpolator(interpolator);<br> }<br> if (interpolation==1)<br> {<br> typedef itk::LinearInterpolateImageFunction<enFaceImageType, double > InterpolatorType;<br> InterpolatorType::Pointer interpolator = InterpolatorType::New();<br>
resampler->SetInterpolator(interpolator);<br> }<br><br> resampler->Update();<br><br> iStatus = EXIT_SUCCESS; <br> return ( resampler->GetOutput() );<br><br><br>Thanks,<br>John<br>