[Insight-users] [Community] Resampling: defining the output size at 'runtime' (Update-time) relative to the input size

Matt McCormick matt.mccormick at kitware.com
Wed Oct 16 10:56:30 EDT 2013


Hi Vaaksiainen,

The filter should implement a GenerateOutputInformation() [1] method
that does the size calculation there and assigns it to the output
ImageRegion's.

Hope this helps,
Matt

[1] http://www.itk.org/Doxygen/html/classitk_1_1ProcessObject.html#abe61fb6b7de8c443e7af1561bd722736

On Wed, Oct 16, 2013 at 2:42 PM, Vaaksiainen <vaaksiainen at gmail.com> wrote:
> Thanks for your quick reply, really appreciate.
>
> I could well be using itk::ScaleTransform but I use simply resampling over
> hand written spacing. I think my problem is in fact in pipelining:
>
> void ResampleImageFilterEx<TInputImage,TOutputImage>::GenerateData()
> {
>     //....
>     typename TInputImage::RegionType roi =
> this->GetOutput()->GetRequestedRegion();
>     typename TInputImage::SpacingType spacing =
> this->GetInput()->GetSpacing();
>     typename TInputImage::SizeType size = roi.GetSize();
>
>     for ( unsigned int i = 0; i < TInputImage::ImageDimension; ++i)
>     {
>         spacing[i] /= m_Decimation;
>         size[i] = (unsigned int)( (double)size[i] * m_Decimation );
>     }
>     itk::ResampleImageFilter<TInputImage,TOutputImage>::Pointer resampler =
>         itk::ResampleImageFilter<TInputImage,TOutputImage>::New();
>
>     resampler->SetOutputSpacing( inputSpacing );
>     resampler->SetSize( inputSize );
>     resampler->SetInput( this->GetInput() );
>
>     resampler->GraftOutput( this->GetOutput() );
>     resampler->Update();
>     resampler->GraftOutput( pyrup->GetOutput() );
> }
>
> but if m_Decimation (or scale parameter) is given as parameter and input yet
> unknown, I can't get regions propagating correctly. Because eventually I
> want to call Update only for the tail filter.
>
> Best,
> -Vaaksiainen
>
>
>
> 2013/10/16 Mike Chinander <chinander at gmail.com>
>>
>> Check out the following example:
>> http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/ScaleTransform
>>
>>
>> On Wed, Oct 16, 2013 at 9:10 AM, Vaaksiainen <vaaksiainen at gmail.com>
>> wrote:
>>>
>>> Hi folks,
>>>
>>> itk::ResampleImageFilter requires size being set before Update() so far
>>> that I've understood it.
>>>
>>> That being said, I'd wish to implement resize image filter (derivative
>>> for before mentioned) which samples the image based on scaling parameter
>>> relative to its input size e.g.
>>>
>>> newWidth = scaling * oldWidth
>>>
>>> which I figure out at GenerateData() and yet, I'd wish to be able to put
>>> this filter in the pipeline not knowing the size of the input image, e.g.
>>>
>>> Reader -> Filter#1 -> ResampleImageFilterEx -> Filter#2 -> Writer
>>>
>>> How PropagateRequestedRegion() works and how its implemented in
>>> itk::ResampleImageFilter I'm not sure if I can do this at all.
>>>
>>> Please, any advice?
>>>
>>> Best,
>>> -Vaaksiainen
>>>
>>>
>>>
>>>
>>>
>>> _____________________________________
>>> 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
>>>
>>
>>
>> _____________________________________
>> 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
>>
>
>
> _____________________________________
> 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
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/cgi-bin/mailman/listinfo/community
>


More information about the Insight-users mailing list