Thanks so much.
That's very helpful.
Post by Yaniv, Ziv Rafael (NIH/NLM/LHC) [C]Hello Tony,
Short answer is yes.
To shrink a volume using integral sizes, use the BinShrinkImageFilter (
https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_
1BinShrinkImageFilter.html).
Using the procedural interface to shrink an image by 4 in x, by 4 in y and
bShrinkImage = sitk.BinShrink(img, [4,4,2])
The BinShrink filter also averages the neighborhood, so it deals to some
extent with potential aliasing. Donât use this filter if your volume
represents a discrete set of labels (i.e. segmentation).
For truly arbitrary resizing use the ResampleImageFilter (https://itk.org/
SimpleITKDoxygen/html/classitk_1_1simple_1_1ResampleImageFilter.html).
new_x_size = 700 #upsample
new_y_size = 64 #downsample
new_z_size = 5 #downsample
new_size = [new_x_size, new_y_size, new_z_size]
new_spacing = [old_sz*old_spc/new_sz for old_sz, old_spc, new_sz in
zip(img.GetSize(), img.GetSpacing(), new_size)]
interpolator_type = sitk.sitkLinear
new_img = sitk.Resample(img, new_size, sitk.Transform(),
interpolator_type, img.GetOrigin(), new_spacing, img.GetDirection(), 0.0,
img.GetPixelIDValue())
The ResampleImageFilter does not deal with aliasing, so if you are
downsampling it is recommended to blur prior to resampling. If you are
resampling a volume with discrete labels you would use the
sitk.sitkNearestNeighbor
interpolator type.
hope this helps
Ziv
*Date: *Monday, July 17, 2017 at 6:52 PM
*Subject: *[ITK] [ITK-users] Resizing DICOM images
I've seen in pydicom and opencv how to resize a DICOM image to an
arbitrary pixel resolution (e.g. going from 512x512 down to 128x128).
Does SimpleITK have a way to do this for 3D image volumes (i.e. rescale
height, width, and slice at the same time?
I'm looking to have a method to make my DICOM volumes uniform in shape.
Thanks.
-Tony