<html><body bgcolor="#FFFFFF"><div>I guess the problem you are talking about is that you want to pass the resampled image as out parameter InternalFilter of your IsotropicResample function, isn't it? But you're actually not doing what you want to. Use TInternalFilter::Pointer& as type for your out parameter InternalFilter and you will be able to use the result of the resampling after calling IsotropicResample in your main function.</div><div><br></div><div>--</div><div>regards</div><div>Andreas</div><div><br>Am 02.03.2009 um 17:48 schrieb Andreas Schuh <<a href="mailto:andreas.schuh.84@googlemail.com">andreas.schuh.84@googlemail.com</a>>:<br><br></div><div></div><blockquote type="cite"><div><div>Hi Baoyun,</div><div><br></div><div>your code is somehow confusing.</div><div><br></div><div>Why do you instanciate inputimage in your main function at all? This isn't necessary as you later set the pointer to the image object create by the ImageFileReader filter.</div><div><br></div><div>Why do you instanciate an output image object in the main function and pass it to your IsotropicResample() template function where the parameter InternalFilter is set to the output of the ResampleFilter instance?</div><div><br></div><div>Moreover, there is the part missing where you compute the size that you set as OutputSize of the resample filter.</div><div><br></div><div>BTW To make your code more readable, you shouldn't name image types or image parameters using the postfix 'Filter'. Moreover, names of parameters or variables should start with a lower case letter for convenience. Upper case identifiers usually name types or functions/methods.<br><br></div><div>--</div><div>regards</div><div>Andreas</div><div><br>Am 02.03.2009 um 17:09 schrieb Baoyun Li <<a href="mailto:baoyun_li123@yahoo.com"><a href="mailto:baoyun_li123@yahoo.com">baoyun_li123@yahoo.com</a></a>>:<br><br></div><div></div><blockquote type="cite"><div><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div><br></div>
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><font face="Times New Roman">Dear All:</font></div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><font face="Times New Roman"></font> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><font face="Times New Roman">I am trying to do some resampling of image throuth template function. Below is example of my main program.</font></div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><font face="Times New Roman"></font> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><font face="Times New Roman">In the main program, I read an image and give inputimage=reader->GetOutput().</font></div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><font face="Times New Roman">I decalare another image pointer,</font><font face="Arial">OutputImageType::Pointer image_high=OutputImageType::New();</font></div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><font face="Times New Roman">both image pass to the tempalte functin as below</font></div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><font face="Times New Roman"></font> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> IsotropicResample <3,InputImageType,OutputImageType,double> (inputimage,image_high,scale);</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">{ my template fucntion delcared as:</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> template <unsigned int Dim,class TInputFilter, class TInternalFilter, class TScale>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">void IsotropicResample( TInputFilter* InputFilter, TInternalFilter* InternalFilter, TScale scale)<br></div></div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">}</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">In the template function, I got the reampled image as following :</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> resampler->Update();<br> InternalFilter=resampler->GetOutput();<br> writer->SetFileName("../data/out_test.hdr");<br> writer->SetInput(InternalFilter);<br> try<br> {<br> writer->Update();<br> }<br> catch( itk::ExceptionObject & excep )<br> {<br> std::cerr << "Exception caught !" << std::endl;<br> std::cerr << excep << std::endl;<br> }</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">I checked the result, the resampled image by the above writer is correct.</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">but I got empty image when I tried to write image_high defined in the main function. </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">Can somebody tell me what will be the probolem</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">Baoyun<br></div></div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><font face="Times New Roman">////code in the main program</font></div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><font face="Times New Roman"></font> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> reader->SetFileName(argv[1]);</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> InputImageType::Pointer inputimage=InputImageType::New();<br> OutputImageType::Pointer image_high=OutputImageType::New();</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> InputImageType::Pointer inputimage=InputImageType::New();<br> OutputImageType::Pointer image_high=OutputImageType::New();</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><br> try <br> {<br> reader->Update();<br> }<br> catch( itk::ExceptionObject & excep )<br> {<br> std::cerr << "Exception caught!" << std::endl;<br> std::cerr << excep << std::endl;<br> }</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">inputimage=reader->GetOutput();</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> IsotropicResample <3,InputImageType,OutputImageType,double> (inputimage,image_high,scale);</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">////template function<br><br>#ifndef _IsotropicResample_H_<br>#define _IsotropicResample_H_</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><br>#if defined(_MSC_VER)<br>#pragma warning ( disable : 4786 )<br>#endif</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">#ifdef __BORLANDC__<br>#define ITK_LEAN_AND_MEAN<br>#endif</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><br>#include "itkImage.h"<br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">// Software Guide : BeginCodeSnippet<br>#include "itkResampleImageFilter.h"<br>#include "itkRecursiveGaussianImageFilter.h"<br>// Software Guide : EndCodeSnippet</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><br>// Software Guide : BeginCodeSnippet<br>#include "itkIdentityTransform.h"<br>#include "itkLinearInterpolateImageFunction.h"<br>#include "itkAffineTransform.h"<br>// Software Guide : EndCodeSnippet</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">// Software Guide : BeginCodeSnippet<br>#include "itkIntensityWindowingImageFilter.h"<br>#include "itkCastImageFilter.h"<br>#include <itkWindowedSincInterpolateImageFunction.h> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">#include "itkBSplineInterpolateImageFunction.h"</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><br>// Software Guide : EndCodeSnippet</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><br>//template <class TInputFilter, class TInternalFilter, class TScale></div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">//void IsotropicResample( TInputFilter* InputFilter, TInternalFilter* InternalFilter, TScale scale);</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><br>template <unsigned int Dim,class TInputFilter, class TInternalFilter, class TScale></div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">void IsotropicResample( TInputFilter* InputFilter, TInternalFilter* InternalFilter, TScale scale)<br>{<br> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> typedef TInputFilter InputImageType;<br> typedef TInternalFilter OutputImageType;<br> typedef float InternalPixelType;<br> typedef itk::Image< InternalPixelType, Dim > InternalImageType;</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><br> typename InputImageType::ConstPointer inputImage = InputFilter;<br></div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> typename InputImageType::SpacingType inputSpacing= inputImage->GetSpacing();<br></div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">///// do reampling</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> <br> resampler->SetSize( size );<br> resampler->Update();<br> InternalFilter=resampler->GetOutput();<br> writer->SetFileName("../data/out_test.hdr");<br> writer->SetInput(InternalFilter);<br> try<br> {<br> writer->Update();<br> }<br> catch( itk::ExceptionObject & excep )<br> {<br> std::cerr << "Exception caught !" << std::endl;<br> std::cerr << excep << std::endl;<br> }<br> <br>// </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><br>};</div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"> </div>
<div style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">#endif<br></div></div></div><br>
</div></blockquote><blockquote type="cite"><div><span>_____________________________________</span><br><span>Powered by <a href="http://www.kitware.com"></a><a href="http://www.kitware.com"><a href="http://www.kitware.com">www.kitware.com</a></a></span><br><span></span><br><span>Visit other Kitware open-source projects at</span><br><span><a href="http://www.kitware.com/opensource/opensource.html"><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a></a></span><br><span></span><br><span>Please keep messages on-topic and check the ITK FAQ at: <a href="http://www.itk.org/Wiki/ITK_FAQ"></a><a href="http://www.itk.org/Wiki/ITK_FAQ"><a href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a></a></span><br><span></span><br><span>Follow this link to subscribe/unsubscribe:</span><br><span><a href="http://www.itk.org/mailman/listinfo/insight-users"><a href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a></a></span><br></div></blockquote></div></blockquote></body></html>