[Insight-users] Upsampling with constant boundary condition

Jan Margeta jmargeta at gmail.com
Tue May 10 09:23:57 EDT 2011


Hi all,

Is there a way (in ITK 3.20) to upsample an image with constant boundary
condition using linear interpolator?
It happens that when I upsample, my last frame and/or last slice are set to
0 (or any other value that I specify with "SetDefaultPixelValue(0)"
in the resampler since it shoots out of the range of the input image).

As far as I could find, the WindowedSincInterpolateImageFunction is the only
one that has support for boundary conditions.
Since I have a 4D volume to rescale, I would prefer something faster than
windowed sinc, not necessarilly that accurate.

I would like to avoid having the values set to 0 and use either the nearest
voxel value or value corresponding to the expansion of the source image with

constant boundary.

Here is my piece of code:

    const unsigned int InputDimension = 4;
    typedef unsigned short PixelType;
    typedef itk::Image< PixelType, InputDimension >      InputImageType;
    typedef itk::IdentityTransform< double, InputDimension >
TransformType;
    typedef itk::LinearInterpolateImageFunction< InputImageType, double >
InterpolatorType;
    typedef itk::ResampleImageFilter< InputImageType, InputImageType >
ResampleFilterType;
    typedef itk::ImageSeriesWriter< InputImageType, OutputImageType >
SeriesWriterType;

    InterpolatorType::Pointer interpolator = InterpolatorType::New();

    TransformType::Pointer transform = TransformType::New();
    transform->SetIdentity();

    ResampleFilterType::Pointer resampler = ResampleFilterType::New();
    resampler->SetInput( reader->GetOutput() );
    resampler->SetTransform( transform );
    resampler->SetInterpolator( interpolator );
    resampler->SetOutputOrigin( reader->GetOutput()->GetOrigin());
    resampler->SetOutputSpacing( outputSpacing );
    resampler->SetOutputDirection( reader->GetOutput()->GetDirection());
    resampler->SetSize( outputSize );
    resampler->Update();


The reader is just an instance of itk::ImageSeriesReader<InputImageType>.


Cheers,

Jan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110510/7078e9e6/attachment.htm>


More information about the Insight-users mailing list