<div dir="ltr"><div>Hello yall<br><br>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?<br>
<br>Basically, I'm writing a composite filter, which downsamples the
image for some internal purpose as follows (purposely using linear
interpolation, not Gaussian):<br><br>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.<br>
<br></div><div>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.<br>
</div><div><br>Help appreciated.<br><br></div>Best<br>-Vaaksiainen<br><br>BTW, using ITK 4.4.1, Visual Studio 9, Windows 7 x64.<br><br>******<br><br>typedef itk::ResampleImageFilter<<div>TImage, TImage, float > ResamplerType;<br>
typedef MyOwnImageToImageFilter<TImage,TImage> MyOwnImageToImageFilter;<br><br>typename TImage::SpacingType spacing = this->GetInput()->GetSpacing();<br>typename TImage::SizeType size = this->GetOutput()->GetRequestedRegion().GetSize();<br>
<br>// e.g. m_Decimation = .5<br>for ( unsigned int i = 0; i < TImage::ImageDimension; ++i)<br>{<br> spacing[i] /= m_Decimation;<br> size[i] = (unsigned int)( (double)size[i] * m_Decimation );<br>}<br><br>ResamplerType::Pointer pyrdown = ResamplerType::New();<br>
pyrdown->SetOutputSpacing( spacing );<br>pyrdown->SetSize( size );<br>pyrdown->SetInput( this->GetInput() );<br><br>MyOwnImageToImageFilter::Pointer filter = MyOwnImageToImageFilter::New();<br>// set filter parameters<br>
filter->SetInput( pyrdown->GetOutput() );<br><br>#if 1<br>ResamplerType::Pointer pyrup = ResamplerType::New();<br>//pyrup->SetOutputSpacing( this->GetInput()->GetSpacing() );<br>pyrup->SetUseReferenceImage( 1 );<br>
pyrup->SetReferenceImage( this->GetInput() );<br>//pyrup->SetOutputStartIndex( roi.GetIndex() );<br>//pyrup->SetSize( this->GetOutput()->GetRequestedRegion().GetSize() );<br>pyrup->SetInput( filter->GetOutput() );<br>
pyrup->SetDefaultPixelValue( 14.0f );<br>#else<br>MyOwnImageToImageFilter::Pointer pyrup = filter;<br>#endif<br><br>pyrup->Update();<br><br>this->SetNthOutput( 0, pyrup->GetOutput() );</div></div>