[Insight-users] Using ScaleTransform to stretch an image
Dan Mueller
dan.muel at gmail.com
Tue Nov 8 14:43:46 EST 2011
Hi David,
I think you forgot to set the center of the transform. Try something
like the following:
typedef itk::ScaleTransform<double, 2> TransformType;
TransformType::Pointer scaleTransform = TransformType::New();
itk::FixedArray<float, 2> scale;
scale[0] = 1.5;
scale[1] = 1.5;
scaleTransform->SetScale(scale);
TransformType::PointType center;
// NOTE: The below code assumes no offset/origin and unity spacing
center[0] = image->GetLargestPossibleRegion().GetSize()[0] / 2;
center[1] = image->GetLargestPossibleRegion().GetSize()[1] / 2;
scaleTransform->SetCenter(center);
HTH
Cheers, Dan
On 9 November 2011 03:38, David Doria <daviddoria at gmail.com> wrote:
> I am trying to use itkScaleTransform along with itkResampleImageFilter
> to stretch or compress an image by a non-integer amount. E.g. make an
> image 1.5x larger than it was.
>
> Here is my attempt:
> http://www.itk.org/Wiki/ITK/Examples/WishList/ImageProcessing/ScaleTransform
>
> The example creates a 100x100 black image with a white square in the
> middle. It then attempts to scale the image by 1.5x in both
> dimensions.
>
> The problem is that the size of the output image is correct (in this
> case 150x150), but the square has seemed to stay at the same
> coordinates, rather than staying centered in the new, larger image.
>
> Can anyone see what I have done wrong?
>
> Thanks,
>
> David
More information about the Insight-users
mailing list