<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 style="font-family: times new roman,new york,times,serif; font-size: 12pt;">Hi,<br> <br> I am trying to read in a 3D deformationField.vtk file and apply it to a 3D image. To read the deformation field, I use ImageFileReader <deformafieldType> and then connect the output of this to the warper.<br><br>The code for this is available below. It seems to take forever to read the deformation field file. Even after 2 hours, the reading is not complete. What is going on ? Any clues ?<br><br>Thanks,<br>Emma<br><br><br>#if defined(_MSC_VER)<br>#pragma warning ( disable : 4786 )<br>#endif<br><br>#include "itkImageFileReader.h" <br>#include "itkImageFileWriter.h" <br><br>#include "itkImageRegionIterator.h"<br><br><br>#include "itkCastImageFilter.h"<br>#include
"itkWarpImageFilter.h"<br>#include "itkLinearInterpolateImageFunction.h"<br><br>#include "itkSquaredDifferenceImageFilter.h"<br>#include "itkCheckerBoardImageFilter.h"<br>#include "itkTimeProbe.h" <br><br>#include "itkImageRegionIteratorWithIndex.h"<br>#include "itkPointSet.h"<br>#include <fstream><br><br><br><br>int main( int argc, char *argv[] )<br>{<br> if( argc < 4 )<br> {<br> std::cerr << "Missing Parameters " << std::endl;<br> std::cerr << "Usage: " << argv[0];<br> std::cerr << " fixedImagefile movingImageFile deformField.vtk ";<br> std::cerr << " outputImageFile " << std::endl;<br> return 1;<br> }<br><br>
<br> const unsigned int Dimension = 3;<br> typedef unsigned char PixelType;<br><br><br> typedef itk::Image< PixelType, Dimension > FixedImageType;<br> typedef itk::ImageFileReader< FixedImageType > FixedImageReaderType;<br> FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New();<br> fixedImageReader->SetFileName( argv[1] );<br><br> <br> typedef itk::Image< PixelType, Dimension > MovingImageType;<br> typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;<br> MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();<br> movingImageReader->SetFileName( argv[2] );<br><br> typedef itk::Vector< float, Dimension
> VectorPixelType;<br> typedef itk::Image< VectorPixelType, Dimension > DeformationFieldType;<br><br> typedef itk::ImageFileReader< DeformationFieldType > FieldReaderType;<br> FieldReaderType::Pointer fieldReader = FieldReaderType::New();<br><br> fieldReader->SetFileName( argv[3] );<br><br> <br> try {<br><br> fieldReader->Update();<br> }<br><br> catch ( itk::ExceptionObject & err ) <br> {<br> std::cerr << "ExceptionObject caught !" << std::endl; <br> std::cerr << err << std::endl; <br> return -1;<br> } <br><br><br> <br> typedef itk::WarpImageFilter<MovingImageType, MovingImageType,DeformationFieldType
> WarperType;<br> typedef itk::LinearInterpolateImageFunction<MovingImageType, double > InterpolatorType;<br> WarperType::Pointer warper = WarperType::New();<br> InterpolatorType::Pointer interpolator = InterpolatorType::New();<br> FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput();<br><br> <br> warper->SetInput( movingImageReader->GetOutput() );<br> warper->SetInterpolator( interpolator );<br> warper->SetOutputSpacing( fixedImage->GetSpacing() );<br> warper->SetOutputOrigin( fixedImage->GetOrigin() );<br><br> warper->SetDeformationField( fieldReader->GetOutput() ); <br><br> <br> typedef unsigned char OutputPixelType;<br> typedef
itk::Image< OutputPixelType, Dimension > OutputImageType;<br> typedef itk::CastImageFilter< <br> MovingImageType,<br> OutputImageType > CastFilterType;<br> typedef itk::ImageFileWriter< OutputImageType > WriterType;<br><br> <br> WriterType::Pointer writer = WriterType::New();<br> CastFilterType::Pointer caster = CastFilterType::New();<br><br> writer->SetFileName( argv[4] );<br><br> <br> caster->SetInput( warper->GetOutput() );<br> writer->SetInput( caster->GetOutput() );<br> writer->Update();<br><br> <br> return 0;<br>}<br><br><br></div></div><br>
<hr size=1>Looking for last minute shopping deals? <a href="http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping">
Find them fast with Yahoo! Search.</a></body></html>