<DIV>Hello,</DIV>  <DIV>&nbsp;</DIV>  <DIV>I am having problem in resampling an image. The code is given below and appreciate if somebody help me out:</DIV>  <DIV>&nbsp;</DIV>  <DIV>#if defined(_MSC_VER)<BR>#pragma warning ( disable : 4786 )<BR>#endif</DIV>  <DIV>#include "itkImage.h"<BR>#include "itkImageFileReader.h"<BR>#include "itkImageFileWriter.h"<BR>#include "itkResampleImageFilter.h"<BR>#include "itkAffineTransform.h"<BR>#include "itkNearestNeighborInterpolateImageFunction.h"</DIV>  <DIV><BR>int main( int argc, char * argv[] )<BR>{<BR>&nbsp; if( argc &lt; 3 )<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Usage: " &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; argv[0] &lt;&lt; "&nbsp; inputImageFile&nbsp; outputImageFile";<BR>&nbsp;&nbsp; std::cerr &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<BR>&nbsp;&nbsp;&nbsp; }</DIV>  <DIV>&nbsp; const&nbsp;&nbsp;&nbsp;&nbsp; unsigned int&nbsp;&nbsp; Dimension = 3;<BR>&nbsp;
 typedef&nbsp;&nbsp; unsigned char&nbsp; InputPixelType;<BR>&nbsp; typedef&nbsp;&nbsp; unsigned char&nbsp; OutputPixelType;</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp; typedef itk::Image&lt; InputPixelType,&nbsp; Dimension &gt;&nbsp;&nbsp; InputImageType;<BR>&nbsp; typedef itk::Image&lt; OutputPixelType, Dimension &gt;&nbsp;&nbsp; OutputImageType;</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp; typedef itk::ImageFileReader&lt; InputImageType&nbsp; &gt;&nbsp; ReaderType;<BR>&nbsp; typedef itk::ImageFileWriter&lt; OutputImageType &gt;&nbsp; WriterType;</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp; ReaderType::Pointer reader = ReaderType::New();<BR>&nbsp; WriterType::Pointer writer = WriterType::New();</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp; reader-&gt;SetFileName( argv[1] );<BR>&nbsp; writer-&gt;SetFileName( argv[2] );</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp; typedef itk::ResampleImageFilter&lt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 InputImageType, OutputImageType &gt;&nbsp; FilterType;<BR>&nbsp; FilterType::Pointer filter = FilterType::New();<BR>&nbsp; <BR>&nbsp; typedef itk::AffineTransform&lt; double, Dimension &gt;&nbsp; TransformType;<BR>&nbsp; TransformType::Pointer transform = TransformType::New();<BR>&nbsp; transform-&gt;SetIdentity();<BR>&nbsp; filter-&gt;SetTransform( transform );<BR>&nbsp;&nbsp;<BR>&nbsp; typedef itk::NearestNeighborInterpolateImageFunction&lt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InputImageType, double &gt;&nbsp; InterpolatorType;<BR>&nbsp; InterpolatorType::Pointer interpolator = InterpolatorType::New();</DIV>  <DIV>&nbsp; filter-&gt;SetInterpolator( interpolator );</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp; filter-&gt;SetOutputOrigin(reader-&gt;GetOutput()-&gt;GetOrigin());<BR>&nbsp;<BR>&nbsp; double spacing[ Dimension ];<BR>&nbsp; spacing[0] = 0.5; // pixel spacing in
 millimeters along X<BR>&nbsp; spacing[1] = 0.5; // pixel spacing in millimeters along Y<BR>&nbsp; spacing[2] = 0.5; // pixel spacing in millimeters along Z<BR>&nbsp; filter-&gt;SetOutputSpacing( spacing );</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp; InputImageType::SizeType&nbsp;&nbsp; size;<BR>&nbsp; size[0] = 80;&nbsp; // number of pixels along X<BR>&nbsp; size[1] = 128;&nbsp; // number of pixels along Y<BR>&nbsp; size[2] = 128;&nbsp; // number of pixels along Z<BR>&nbsp; filter-&gt;SetSize( size );</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp; filter-&gt;SetInput( reader-&gt;GetOutput() );<BR>&nbsp; writer-&gt;SetInput( filter-&gt;GetOutput() );</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp; filter-&gt;SetDefaultPixelValue( 0 );</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp; try <BR>&nbsp; { <BR>&nbsp;&nbsp; writer-&gt;Update();<BR>&nbsp; } <BR>&nbsp;&nbsp;<BR>&nbsp; catch( itk::ExceptionObject &amp; err ) <BR>&nbsp; { <BR>&nbsp;&nbsp; std::cout &lt;&lt; "ExceptionObject caught !" &lt;&lt; std::endl;
 <BR>&nbsp;&nbsp; std::cout &lt;&lt; err &lt;&lt; std::endl; <BR>&nbsp;&nbsp; system("pause");<BR>&nbsp;&nbsp; return EXIT_FAILURE;<BR>&nbsp; }<BR>&nbsp; <BR>&nbsp; return EXIT_SUCCESS;<BR>}</DIV>  <DIV>&nbsp;</DIV>  <DIV>Thanks<BR>Shahab</DIV><p>&#32;
                <hr size=1><a href="http://us.rd.yahoo.com/evt=43256/*http://advision.webevents.yahoo.com/mailbeta"> All-new Yahoo! Mail </a>- Fire up a more powerful email and get things done faster.