[Insight-users] problem with itkInterpolateImageFilter
HBK
hatakeshi at gmail.com
Fri Apr 7 04:09:34 EDT 2006
Hi all:
I want to Interpolate two image to n images.
Where is my error? Thx.
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkInterpolateImageFilter.h"
#include <stdio.h>
int main( int argc, char * argv[] )
{
if( argc < 5 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile1 intputImageFile2
outputImageFileBase numberOfSlices" << std::endl;
return EXIT_FAILURE;
}
typedef float InputPixelType;
typedef float OutputPixelType;
typedef itk::Image< InputPixelType, 2 > InputImageType;
typedef itk::Image< OutputPixelType, 2 > OutputImageType;
typedef itk::ImageFileReader< InputImageType > ReaderType;
typedef itk::InterpolateImageFilter<
InputImageType, OutputImageType > FilterType;
ReaderType::Pointer reader1 = ReaderType::New();
reader1->SetFileName( argv[1] );
ReaderType::Pointer reader2 = ReaderType::New();
reader2->SetFileName( argv[2] );
FilterType::Pointer inter = FilterType::New();
inter->SetInput1(reader1->GetOutput() );
inter->SetInput2(reader2->GetOutput() );
inter->SetDistance( 0.2 );
inter->Update();
typedef itk::ImageFileWriter< OutputImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetInput( inter->GetOutput() );
char filename[2000];
int numberOfSlices = atoi(argv[4]);
for( int slice=0; slice < numberOfSlices; slice++ )
{
sprintf( filename, "%s%03d.png", argv[2], slice );
writer->SetFileName( filename );
writer->Update();
}
return EXIT_SUCCESS;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060407/85404285/attachment.html
More information about the Insight-users
mailing list