[Insight-users] Need help for writting an image

Yankam Njiwa Josiane Adrienne njiwa at biomed.ee.ethz.ch
Tue Sep 2 09:46:44 EDT 2008


 
Dear all,
 
I used the iterative closestPoint.cxx and after registration i would like to use the computed tranform and apply on an image and then write this image in a file. I have an error that the application requested a runtime to terminate in an unusual way and that i should contact the application's support team for more explanation.
 
Please here the source code i wrote for that should somebody help me please?
 
Thanks,
 
Josiane.
 
 
#include "itkImage.h"

#include "itkImageFileReader.h"

#include "itkResampleImageFilter.h"

#include "itkCastImageFilter.h"

#include "itkImageFileWriter.h"

 
typedef unsigned short PixelType;

typedef itk::Image< PixelType, Dimension > ImageType;

typedef itk::ImageFileReader< ImageType > ImageReaderType;

ImageReaderType::Pointer ImageReader = ImageReaderType::New();

ImageReader->SetFileName( argv[4] );

ImageReader->Update();

typedef itk::ResampleImageFilter< 

ImageType, 

ImageType > ResampleFilterType;

ResampleFilterType::Pointer resampler = ResampleFilterType::New();

resampler->SetInput( ImageReader->GetOutput() );

resampler->SetTransform( registration->GetTransform() );

ImageType::Pointer Image = ImageReader->GetOutput();

resampler->SetSize( Image->GetLargestPossibleRegion().GetSize() );

resampler->SetOutputOrigin( Image->GetOrigin() );

resampler->SetOutputSpacing( Image->GetSpacing() );

typedef itk::CastImageFilter< 

ImageType,

ImageType > CastFilterType;

typedef itk::ImageFileWriter< ImageType > WriterType;

WriterType::Pointer writer = WriterType::New();

CastFilterType::Pointer caster = CastFilterType::New();

writer->SetFileName( argv[5] );

caster->SetInput( resampler->GetOutput());

writer->SetInput( caster->GetOutput() );

writer->Update();

 

 

resampler->SetOutputDirection( Image->GetDirection() );

resampler->SetDefaultPixelValue( 100 );



More information about the Insight-users mailing list