Dear Krzysztof,<br>you are actually generating a circular loop. <br><br>You may want to use the DisconnectPipeline method for the first output you are getting so that your data objects gets disconnected from the upstream pipeline. Then, plugging this input to the filter should do the trick, if I&#39;m not wrong.<br>
<br>Anyway, using two separate filters for your program is a completely acceptable solution.<br><br>Kind regards,<br>JON HAITZ<br><br>
<br><br><div class="gmail_quote">On 8 November 2012 04:54, Krzysztof J. Rechowicz <span dir="ltr">&lt;<a href="mailto:k.rechowicz@gmail.com" target="_blank">k.rechowicz@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
<br>
In the piece of code I am working on I want to reuse ResampleFilter.<br>
The first use downscale the image to low resolution (which is<br>
performed correctly) and then the output is used to be upscaled using<br>
bicubic interpolation. After this operation, the resulting image is<br>
identical as the image that was read in (the original image before<br>
applying any filters) instead of being blurred. Using another instance<br>
of the filter for the second part works well and produces the right<br>
output. How to correctly reuse a filter (in this case ResampleFilter)?<br>
<br>
Thank you in advance,<br>
<br>
Krzysztof<br>
<br>
// Instantiate the transform and specify it should be the id transform.<br>
TransformType::Pointer _pTransform = TransformType::New();<br>
  _pTransform-&gt;SetIdentity();<br>
// Instantiate the b-spline interpolator and set it as the third order<br>
// for bicubic.<br>
InterpolatorType::Pointer _pInterpolator = InterpolatorType::New();<br>
_pInterpolator-&gt;SetSplineOrder(3);<br>
<br>
// Instantiate the resampler. Wire in the transform and the interpolator.<br>
ResampleFilterType::Pointer _pResizeFilter = ResampleFilterType::New();<br>
_pResizeFilter-&gt;SetTransform(_pTransform);<br>
_pResizeFilter-&gt;SetInterpolator(_pInterpolator);<br>
<br>
const double vfOutputOrigin[2] = { 0.0, 0.0 };<br>
_pResizeFilter-&gt;SetOutputOrigin(vfOutputOrigin);<br>
<br>
// Fetch original image size.<br>
const ImageType::RegionType&amp; inputRegion = image-&gt;GetLargestPossibleRegion();<br>
const ImageType::SizeType&amp; vnInputSize = inputRegion.GetSize();<br>
unsigned int nOldWidth = vnInputSize[0];<br>
unsigned int nOldHeight = vnInputSize[1];<br>
<br>
unsigned int nNewWidth = vnInputSize[0]/scale;<br>
unsigned int nNewHeight = vnInputSize[1]/scale;<br>
<br>
// Fetch original image spacing.<br>
const ImageType::SpacingType&amp; vfInputSpacing = image-&gt;GetSpacing();<br>
<br>
double vfOutputSpacing[2];<br>
vfOutputSpacing[0] = vfInputSpacing[0] * (double) nOldWidth / (double)<br>
nNewWidth;<br>
vfOutputSpacing[1] = vfInputSpacing[1] * (double) nOldHeight /<br>
(double) nNewHeight;<br>
<br>
_pResizeFilter-&gt;SetOutputSpacing(vfOutputSpacing);<br>
itk::Size&lt;2&gt; vnOutputSize = { {nNewWidth, nNewHeight} };<br>
_pResizeFilter-&gt;SetSize(vnOutputSize);<br>
_pResizeFilter-&gt;SetInput(image);<br>
_pResizeFilter-&gt;Update();<br>
ImageType::Pointer lores = _pResizeFilter-&gt;GetOutput();<br>
_pResizeFilter-&gt;UpdateLargestPossibleRegion();<br>
<br>
<br>
                const ImageType::RegionType&amp; inputRegion2 = lores-&gt;GetLargestPossibleRegion();<br>
                const ImageType::SizeType&amp; vnInputSize2 = inputRegion2.GetSize();<br>
                nOldWidth = vnInputSize2[0];<br>
                nOldHeight = vnInputSize2[1];<br>
                //<br>
                nNewWidth = vnInputSize2[0]*scale;<br>
                nNewHeight = vnInputSize2[1]*scale;<br>
                const ImageType::SpacingType&amp; vfInputSpacingLow = lores-&gt;GetSpacing();<br>
                vfOutputSpacing[0] = vfInputSpacingLow[0] * (double) nOldWidth /<br>
(double) nNewWidth;<br>
                vfOutputSpacing[1] = vfInputSpacingLow[1] * (double) nOldHeight /<br>
(double) nNewHeight;<br>
<br>
                _pResizeFilter-&gt;SetTransform(_pTransform);<br>
                _pResizeFilter-&gt;SetInterpolator(_pInterpolator);<br>
                _pResizeFilter-&gt;SetOutputOrigin(vfOutputOrigin);<br>
                _pResizeFilter-&gt;SetOutputSpacing(vfOutputSpacing);<br>
                vnOutputSize[0] = nNewWidth;<br>
                vnOutputSize[1] = nNewHeight;<br>
                _pResizeFilter-&gt;SetSize(vnOutputSize);<br>
                _pResizeFilter-&gt;UpdateLargestPossibleRegion();<br>
                _pResizeFilter-&gt;SetInput(lores);<br>
                _pResizeFilter-&gt;Modified();<br>
                _pResizeFilter-&gt;Update();<br>
_____________________________________<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>
</blockquote></div><br>