1

I have 2 SimpleITK images, and I want to use their package's ExpandImageFilter to upsample one of my images to match the other.

Does anyone have any idea on how to use this?

I took a look at their documentation (https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1ExpandImageFilter.html) and I don't really understand it... and I couldn't find any examples of it either.

Icy Lemons
  • 143
  • 7

2 Answers2

1

The ExpandImageFilter will expand the size of an image in integer multiples. For instance you can expand a 100x100 image to 200x200. The new dimensions must be an integer multiple of the original. If that is not the case for your two images, then Expand will not work for you.

In the case of a non-integer change in dimensions you need to use the ResampleImageFilter. You can read about resampling in the following notebook:

http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/Python_html/21_Transforms_and_Resampling.html

Update: It sounds like you figured it out, but just for completeness, here's an example of how to use the ExpandImageFilter

import SimpleITK as sitk

img = sitk.Image(100,100,sitk.sitkUInt8)
expand = sitk.ExpandImageFilter()
expand.SetExpandFactors([2,2])
big_img = expand.Execute(img)

Also there is the procedural version, which I prefer:

another_big_img = sitk.Expand(img, [2,2])
Dave Chen
  • 1,905
  • 1
  • 12
  • 18
  • 1
    That is the case of my 2 images, and I want to expand my first image by a factor of 2. Do you have an example of how to use this? What's the syntax? The docs didn't give anything – Icy Lemons Jul 27 '20 at 16:23
1

So it turns out I was looking at the wrong thing - ExpandImageFilter is actually a class, while the execute function actually does the operation. Instead of using the ExpandImageFilter class, you can directly access the image.Expand() function and input a vector representing the integer factors you want to expand the dimensions by (ie. factor of 2 in all directions is [2,2,2].

Thanks to @Dave Chen for the help!

Icy Lemons
  • 143
  • 7