scaling is reducing size of image

I am using an AffineTransform only with scaling parameters and scaling an image. When the scale factor is set to 2, after resampling the image and comparing with the original one in an external viewer, I see that the scaled image is halved in size. Shouldn’t it get doubled after scaling by 2? What is the reasoning behind such behaviour? The 3x3 matrix is set using SetMatrix method and translation is 0.

The matrix I used is

  array([[2., 0., 0., 0.],
           [0., 2., 0., 0.],
           [0., 0., 2., 0.],
           [0., 0., 0., 1.]])

Direct transform maps points in the moving image to the points in the fixed image. This is the opposite of how I (and many others it seems) usually think of transforms. So you should invert the transform you are using.

Hello @prms,

Please see reply to your related question.

I suspect you are confusing things between number of pixels and physical size of an image. The resampling code below doesn’t change the size of the image, it just maps the voxels from [x,y,z] to [2x,2y,2z] so the image looks smaller but the whole image remained the same size.

import SimpleITK as sitk

img = sitk.GaussianSource()
sitk.Show(img, 'original image')

tx = sitk.AffineTransform(3)

resampled_img = sitk.Resample(img,tx,defaultPixelValue=255)
sitk.Show(resampled_img, 'resampled image')