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

Vaaksiainen vaaksiainen at gmail.com
Wed Sep 25 04:02:47 EDT 2013


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() );
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130925/cbb54351/attachment.htm>


More information about the Insight-users mailing list