[Insight-users] Is it silly to attempt this ?
Luis Ibanez
luis.ibanez at kitware.com
Sat Feb 23 20:00:34 EST 2008
Hi Emma,
The source code that you posted seems to be reasonable.
However, a duration of 2 hours for warping an image
sounds like an excesive time.
1) How big is your image ?
pixels along X
pixels along Y
pixels along Z
2) How much RAM do you have ?
3) Have you checked if your computer
is not swapping memory ?
(you can check this on Windows by looking
at the Task Manager, or in Linux by using
the top tool, or the system information tool.)
Please let us know,
Thanks
Luis
----------------
Emma Ryan wrote:
> Hi,
>
> 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.
>
> 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 ?
>
> Thanks,
> Emma
>
>
> #if defined(_MSC_VER)
> #pragma warning ( disable : 4786 )
> #endif
>
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
>
> #include "itkImageRegionIterator.h"
>
>
> #include "itkCastImageFilter.h"
> #include "itkWarpImageFilter.h"
> #include "itkLinearInterpolateImageFunction.h"
>
> #include "itkSquaredDifferenceImageFilter.h"
> #include "itkCheckerBoardImageFilter.h"
> #include "itkTimeProbe.h"
>
> #include "itkImageRegionIteratorWithIndex.h"
> #include "itkPointSet.h"
> #include <fstream>
>
>
>
> int main( int argc, char *argv[] )
> {
> if( argc < 4 )
> {
> std::cerr << "Missing Parameters " << std::endl;
> std::cerr << "Usage: " << argv[0];
> std::cerr << " fixedImagefile movingImageFile deformField.vtk ";
> std::cerr << " outputImageFile " << std::endl;
> return 1;
> }
>
>
> const unsigned int Dimension = 3;
> typedef unsigned char PixelType;
>
>
> typedef itk::Image< PixelType, Dimension > FixedImageType;
> typedef itk::ImageFileReader< FixedImageType > FixedImageReaderType;
> FixedImageReaderType::Pointer fixedImageReader =
> FixedImageReaderType::New();
> fixedImageReader->SetFileName( argv[1] );
>
>
> typedef itk::Image< PixelType, Dimension > MovingImageType;
> typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;
> MovingImageReaderType::Pointer movingImageReader =
> MovingImageReaderType::New();
> movingImageReader->SetFileName( argv[2] );
>
> typedef itk::Vector< float, Dimension > VectorPixelType;
> typedef itk::Image< VectorPixelType, Dimension > DeformationFieldType;
>
> typedef itk::ImageFileReader< DeformationFieldType > FieldReaderType;
> FieldReaderType::Pointer fieldReader = FieldReaderType::New();
>
> fieldReader->SetFileName( argv[3] );
>
>
> try {
>
> fieldReader->Update();
> }
>
> catch ( itk::ExceptionObject & err )
> {
> std::cerr << "ExceptionObject caught !" << std::endl;
> std::cerr << err << std::endl;
> return -1;
> }
>
>
>
> typedef itk::WarpImageFilter<MovingImageType,
> MovingImageType,DeformationFieldType > WarperType;
> typedef itk::LinearInterpolateImageFunction<MovingImageType, double
> > InterpolatorType;
> WarperType::Pointer warper = WarperType::New();
> InterpolatorType::Pointer interpolator = InterpolatorType::New();
> FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput();
>
>
> warper->SetInput( movingImageReader->GetOutput() );
> warper->SetInterpolator( interpolator );
> warper->SetOutputSpacing( fixedImage->GetSpacing() );
> warper->SetOutputOrigin( fixedImage->GetOrigin() );
>
> warper->SetDeformationField( fieldReader->GetOutput() );
>
>
> typedef unsigned char OutputPixelType;
> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
> typedef itk::CastImageFilter<
> MovingImageType,
> OutputImageType > CastFilterType;
> typedef itk::ImageFileWriter< OutputImageType > WriterType;
>
>
> WriterType::Pointer writer = WriterType::New();
> CastFilterType::Pointer caster = CastFilterType::New();
>
> writer->SetFileName( argv[4] );
>
>
> caster->SetInput( warper->GetOutput() );
> writer->SetInput( caster->GetOutput() );
> writer->Update();
>
>
> return 0;
> }
>
>
>
> ------------------------------------------------------------------------
> Looking for last minute shopping deals? Find them fast with Yahoo!
> Search.
> <http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list