[Insight-users] reducing the resolution of a 3D image

Dan Mueller dan.muel at gmail.com
Tue Oct 5 15:51:59 EDT 2010


Hi Ramón,

I think you want to use ResampleImageFilter with IdentityTransform.
Here are some useful examples:
    Examples/Filtering/ResampleImageFilter.cxx
    Examples/Filtering/ResampleImageFilter2.cxx
    Examples/Filtering/ResampleImageFilter3.cxx
    Examples/Filtering/ResampleImageFilter4.cxx
    Examples/Filtering/ResampleImageFilter5.cxx
    Examples/Filtering/ResampleImageFilter6.cxx
    Examples/Filtering/ResampleImageFilter7.cxx
    Examples/Filtering/ResampleImageFilter8.cxx
    Examples/Filtering/ResampleImageFilter9.cxx

Here's the IronPython script I use for downsampling, it's not C++ but
you should be able to get the general gist:
    # Create transform
    transform = itkIdentityTransform.New( self.Input.Dimension )

    # Create interpolator
    CoordTypeDouble = itkPixelType.D;
    interpolator = None
    if String.Compare(self.Interpolator, "Linear", False) == 0:
        interpolator = itkLinearInterpolateImageFunction.New(
self.Input, CoordTypeDouble )
    elif String.Compare(self.Interpolator, "Nearest", False) == 0:
        interpolator = itkNearestNeighborInterpolateImageFunction.New(
self.Input, CoordTypeDouble )
    elif String.Compare(self.Interpolator, "BSpline", False) == 0:
        interpolator = itkBSplineInterpolateImageFunction.New(
self.Input, CoordTypeDouble )
    elif String.Compare(self.Interpolator, "WindowedSinc", False) == 0:
        radius = itkRadius( 4 )
        if String.Compare(self.WindowFunction, "Cosine", False) == 0:
            interpolator =
itkCosineWindowedSincInterpolateImageFunction.New( self.Input, radius
)
        elif String.Compare(self.WindowFunction, "Hamming", False) == 0:
            interpolator =
itkHammingWindowedSincInterpolateImageFunction.New( self.Input, radius
)
        elif String.Compare(self.WindowFunction, "Lanczos", False) == 0:
            interpolator =
itkLanczosWindowedSincInterpolateImageFunction.New( self.Input, radius
)
        elif String.Compare(self.WindowFunction, "Welch", False) == 0:
            interpolator =
itkWelchWindowedSincInterpolateImageFunction.New( self.Input, radius )

    # Compute new spacing
    self.OutputSpacing = itkSpacing( self.OutputSize.Dimension )
    for i in range( self.OutputSize.Dimension ):
        inputSize = System.Double( self.Input.Size[i] )
        outputSize = System.Double( self.OutputSize[i] )
        self.OutputSpacing[i] = self.Input.Spacing[i] * (inputSize / outputSize)

    # Do actual work
    filterResample = itkResampleImageFilter.New( self.Input, self.Output )
    filterResample.SetInput( self.Input )
    filterResample.OutputSize = self.OutputSize
    filterResample.OutputSpacing = self.OutputSpacing
    filterResample.SetTransform( transform )
    filterResample.SetInterpolator( interpolator )
    filterResample.UpdateLargestPossibleRegion()
    filterResample.GetOutput( self.Output )

HTH

Cheers, Dan

2010/10/5 Ramón Casero Cañas <rcasero at gmail.com>:
>
> Hi,
>
> I have done some searching on how to reduce the resolution of a 3D image by
> non integer factors in ITK, and I thought it would be very easy to find an
> example, but I couldn't.
>
> For example, if I have an image with size (103, 304, 573) voxels, and I want
> to make it (100, 280, 300), without changing the real world coordinates
> size.
>
> Apart from a low pass filter to avoid aliasing, what needs to be used?
>
> If I understand well, using something like
> itk::MultiResolutionPyramidImageFilter doesn't work, because the size
> reduction factor has to be an integer.
>
> If I use itk::ScaleTransform, then the image changes it's size, but not the
> resolution values.
>
> Something that looks like a candidate is itk::ChangeInformationImageFilter,
> but could somebody provide some hints on how to do this?
>
> Best regards,
>
> Ramon.
>
> --
> Dr. Ramón Casero Cañas
>
> Computational Biology
> Computing Laboratory
> University of Oxford
> Wolfson Building, Parks Rd
> Oxford OX1 3QD
>
> tlf     +44 (0) 1865 283575
> web     http://web.comlab.ox.ac.uk/people/Ramon.CaseroCanas
> photos  http://www.flickr.com/photos/rcasero/
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list