<div dir="ltr"><div><div><div>Thanks Matt,<br><br></div>Your observations were indeed helpful. Grafting the output at all associated filters (especially the one in between resamplers) solved my issue. <br><br></div>Talking about grafting and pipelines, I have two additional questions:<br>
<br></div><div>(1) Is it ok to use grafting if minipipeline filters are constructed at GenerateData() -scope (vs. class members as suggested in the (old) manual). It seems to be.<br><br></div><div>(2) Are both codes below valid alternatives? Latter is not used as is (naturally), but in analogue after some processing of 'in.Get()' values.<br>
<br></div><div>Thanks in advance,<br></div><div>-Vaaksiainen<br></div><div><br>void ::GenerateDataA() // AwesomeImageToImageFilter<TImg,TImg><br>{<br> itk::MyPrivateImageToImageFilter<TImg,TImg> FilterType;<br>
FilterType::Pointer filter = FilterType::New();<br> filter->SetInput( this->GetInput() );<br> filter->GraftOutput( this->GetOutput() );<br> filter->Update();<br> this->GraftOutput( filter->GetOutput() );<br>
}<br></div><div><br>void ::GenerateDataB() // AwesomeImageToImageFilter<TImg,TImg><br>{<br> itk::MyPrivateImageToImageFilter<TImg,TImg> FilterType;<br> FilterType::Pointer filter = FilterType::New();<br>
filter->SetInput( this->GetInput() );<br> filter->Update();<br> <br> typename TImg::RegionType region = this->GetOutput()->GetRequestedRegion();<br> this->GetOutput()->SetBufferedRegion( region );<br>
this->Allocate();<br> <br> itk::ImageRegionIterator<TImg> out( this->GetOutput(), region );<br> itk::ImageRegionConstIterator<TImg> in( filter->GetOutput(), region );<br> <br> for (; !out.IsAtEnd(); ++out, ++in )<br>
{<br> out.Set( in.Get() );<br> }<br>}<br><br><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/9/25 Matt McCormick <span dir="ltr"><<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Vaaksianinen,<br>
<br>
Two observations may be useful.<br>
<br>
- The resampler is being told to use the reference image but the<br>
parameters of the output image are also being set at the same time.<br>
One or the other should be used -- in this case the reference image<br>
should not be used.<br>
- When writing a composite filter, it is important to use the Graft<br>
methods. -- see the Software Guide on writing a composite filter.<br>
<br>
Hope this helps,<br>
Matt<br>
<div><div class="h5"><br>
On Wed, Sep 25, 2013 at 8:02 AM, Vaaksiainen <<a href="mailto:vaaksiainen@gmail.com">vaaksiainen@gmail.com</a>> wrote:<br>
> Hello yall<br>
><br>
> I'm suffering with ResampleImageFilter. In particular, upsampling an image<br>
> produces all zero image (or whatever defaultpixelvalue happens to be) and I<br>
> just can't figure out why?<br>
><br>
> Basically, I'm writing a composite filter, which downsamples the image for<br>
> some internal purpose as follows (purposely using linear interpolation, not<br>
> Gaussian):<br>
><br>
> Some times I explicitly added IdentityTransform and<br>
> LinearInterpolateImageFunction, but as far as I know, they are defaults so I<br>
> left them out. If I comment out pyramid up (preprocessor if statement), then<br>
> I get the actual downsampled image from my filter as output. So the only<br>
> problem is upsampling.<br>
><br>
> I have examined the output from 'filter' and it has spacing as expected<br>
> (twice the size of original input), origin at zero, directions following<br>
> cartesian axes and image size half the original. So nothing there... As you<br>
> see, have tried have tried multiple combinations for pyrup parameters, none<br>
> seems working.<br>
><br>
> Help appreciated.<br>
><br>
> Best<br>
> -Vaaksiainen<br>
><br>
> BTW, using ITK 4.4.1, Visual Studio 9, Windows 7 x64.<br>
><br>
> ******<br>
><br>
> typedef itk::ResampleImageFilter<<br>
> TImage, TImage, float > ResamplerType;<br>
> typedef MyOwnImageToImageFilter<TImage,TImage><br>
> MyOwnImageToImageFilter;<br>
><br>
> typename TImage::SpacingType spacing = this->GetInput()->GetSpacing();<br>
> typename TImage::SizeType size =<br>
> 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() );<br>
><br>
</div></div>> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
</blockquote></div><br></div>