# scaling is reducing size of image

**URL:** <https://discourse.itk.org/t/scaling-is-reducing-size-of-image/3591>\
**Category:** Algorithms\
**Tags:** simpleitk, python\
**Created:** [November 3, 2020, 9:39am UTC](https://discourse.itk.org/t/scaling-is-reducing-size-of-image/3591 "2020-11-03T09:39:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![prms](https://discourse.itk.org/user_avatar/discourse.itk.org/prms/32/1526_2.png) [@prms](https://discourse.itk.org/u/prms)\
**Post date:** [November 3, 2020, 9:39am UTC](https://discourse.itk.org/t/scaling-is-reducing-size-of-image/3591/1 "2020-11-03T09:39:45Z")

</div>

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.]])
```

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [November 3, 2020, 2:57pm UTC](https://discourse.itk.org/t/scaling-is-reducing-size-of-image/3591/2 "2020-11-03T14:57:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)\
**Post date:** [November 3, 2020, 3:10pm UTC](https://discourse.itk.org/t/scaling-is-reducing-size-of-image/3591/3 "2020-11-03T15:10:25Z")

</div>

Hello @prms,

Please see reply to your [related question](https://discourse.itk.org/t/help-in-applying-rotation-using-affinematrix/3592/2).

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.

```auto
import SimpleITK as sitk

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

tx = sitk.AffineTransform(3)
tx.SetMatrix([2,0,0,0,2,0,0,0,2])

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

```
