[Insight-users] ResampleImageFilter : blank result from upsampling x2

Matt McCormick matt.mccormick at kitware.com
Wed Sep 25 10:51:38 EDT 2013


Hi Vaaksianinen,

Two observations may be useful.

  - The resampler is being told to use the reference image but the
parameters of the output image are also being set at the same time.
One or the other should be used -- in this case the reference image
should not be used.
  - When writing a composite filter, it is important to use the Graft
methods. -- see the Software Guide on writing a composite filter.

Hope this helps,
Matt

On Wed, Sep 25, 2013 at 8:02 AM, Vaaksiainen <vaaksiainen at gmail.com> wrote:
> Hello yall
>
> I'm suffering with ResampleImageFilter. In particular, upsampling an image
> produces all zero image (or whatever defaultpixelvalue happens to be) and I
> just can't figure out why?
>
> Basically, I'm writing a composite filter, which downsamples the image for
> some internal purpose as follows (purposely using linear interpolation, not
> Gaussian):
>
> Some times I explicitly added IdentityTransform and
> LinearInterpolateImageFunction, but as far as I know, they are defaults so I
> left them out. If I comment out pyramid up (preprocessor if statement), then
> I get the actual downsampled image from my filter as output. So the only
> problem is upsampling.
>
> I have examined the output from 'filter' and it has spacing as expected
> (twice the size of original input), origin at zero, directions following
> cartesian axes and image size half the original. So nothing there... As you
> see, have tried have tried multiple combinations for pyrup parameters, none
> seems working.
>
> Help appreciated.
>
> Best
> -Vaaksiainen
>
> BTW, using ITK 4.4.1, Visual Studio 9, Windows 7 x64.
>
> ******
>
> typedef itk::ResampleImageFilter<
> TImage, TImage, float >        ResamplerType;
> typedef MyOwnImageToImageFilter<TImage,TImage>
> MyOwnImageToImageFilter;
>
> typename TImage::SpacingType spacing = this->GetInput()->GetSpacing();
> typename TImage::SizeType size =
> this->GetOutput()->GetRequestedRegion().GetSize();
>
> // e.g. m_Decimation = .5
> for ( unsigned int i = 0; i < TImage::ImageDimension; ++i)
> {
>     spacing[i] /= m_Decimation;
>     size[i] = (unsigned int)( (double)size[i] * m_Decimation );
> }
>
> ResamplerType::Pointer pyrdown = ResamplerType::New();
> pyrdown->SetOutputSpacing( spacing );
> pyrdown->SetSize( size );
> pyrdown->SetInput( this->GetInput() );
>
> MyOwnImageToImageFilter::Pointer filter = MyOwnImageToImageFilter::New();
> // set filter parameters
> filter->SetInput( pyrdown->GetOutput() );
>
> #if 1
> ResamplerType::Pointer pyrup = ResamplerType::New();
> //pyrup->SetOutputSpacing( this->GetInput()->GetSpacing() );
> pyrup->SetUseReferenceImage( 1 );
> pyrup->SetReferenceImage( this->GetInput() );
> //pyrup->SetOutputStartIndex( roi.GetIndex() );
> //pyrup->SetSize( this->GetOutput()->GetRequestedRegion().GetSize() );
> pyrup->SetInput( filter->GetOutput() );
> pyrup->SetDefaultPixelValue( 14.0f );
> #else
> MyOwnImageToImageFilter::Pointer pyrup = filter;
> #endif
>
> pyrup->Update();
>
> this->SetNthOutput( 0, pyrup->GetOutput() );
>
> _____________________________________
> 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.php
>
> 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