Hi all:<br>I want to Interpolate two image to n images.<br>Where is my error? Thx.<br><br>#include "itkImage.h"<br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br>#include "
itkInterpolateImageFilter.h"<br><br>#include <stdio.h><br><br><br>int main( int argc, char * argv[] )<br>{<br> if( argc < 5 ) <br> { <br> std::cerr << "Usage: " << std::endl;<br>
std::cerr << argv[0] << " inputImageFile1 intputImageFile2 outputImageFileBase numberOfSlices" << std::endl;<br> return EXIT_FAILURE;<br> }<br><br> <br> typedef float InputPixelType;
<br> typedef float OutputPixelType;<br> typedef itk::Image< InputPixelType, 2 > InputImageType;<br> typedef itk::Image< OutputPixelType, 2 > OutputImageType;<br><br><br> typedef itk::ImageFileReader< InputImageType > ReaderType;
<br><br> <br><br> typedef itk::InterpolateImageFilter<<br> InputImageType, OutputImageType > FilterType;<br><br><br><br><br> ReaderType::Pointer reader1 = ReaderType::New();<br> reader1->SetFileName( argv[1] );
<br><br> ReaderType::Pointer reader2 = ReaderType::New();<br> reader2->SetFileName( argv[2] );<br><br><br><br> FilterType::Pointer inter = FilterType::New();<br><br> <br> inter->SetInput1(reader1->GetOutput() );
<br><br> inter->SetInput2(reader2->GetOutput() );<br><br> <br> inter->SetDistance( 0.2 );<br><br> inter->Update();<br><br><br> typedef itk::ImageFileWriter< OutputImageType > WriterType;<br><br> WriterType::Pointer writer = WriterType::New();
<br><br><br><br> writer->SetInput( inter->GetOutput() );<br><br> <br> char filename[2000];<br><br> int numberOfSlices = atoi(argv[4]);<br> for( int slice=0; slice < numberOfSlices; slice++ )<br> {<br> sprintf( filename, "%s%03d.png", argv[2], slice );
<br><br> writer->SetFileName( filename );<br><br> <br> writer->Update();<br> }<br> <br> <br><br><br> return EXIT_SUCCESS;<br>}<br>