Reputation: 153
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.
Upvotes: 1
Views: 317
Reputation: 2085
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:
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])
Upvotes: 1
Reputation: 153
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!
Upvotes: 1