<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><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>
</body></html>