[ITK-users] [ITK] Resizing DICOM images
G Reina
greina at eng.ucsd.edu
Tue Jul 18 12:34:20 EDT 2017
Thanks so much.
That's very helpful.
Tony
On Jul 18, 2017 8:09 AM, "Yaniv, Ziv Rafael (NIH/NLM/LHC) [C]" <
zivrafael.yaniv at nih.gov> wrote:
> 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
> by 2 in z would be:
>
> 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).
>
>
>
>
>
> Longer answer:
>
>
>
> For truly arbitrary resizing use the ResampleImageFilter (https://itk.org/
> SimpleITKDoxygen/html/classitk_1_1simple_1_1ResampleImageFilter.html).
>
>
>
> Using the procedural interface to modify the original (style is verbose
> for clarity):
>
>
>
> 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
>
>
>
>
>
>
>
>
>
> *From: *G Reina <greina at eng.ucsd.edu>
> *Date: *Monday, July 17, 2017 at 6:52 PM
> *To: *"insight-users at itk.org" <insight-users at itk.org>
> *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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20170718/47272fd1/attachment.html>
More information about the Insight-users
mailing list