[Insight-users] (no subject)

Emma Ryan eryanvtk at yahoo.com
Thu Aug 2 16:19:43 EDT 2007


Hi,

 Could anyone tell me the difference between the following two sections of code ? As far as my understanding goes, the first segment of code writes out the deformation field to a file such "field.vtk".  The second segment also writes out the vector (after converting 2D information to 3D) representative of the deformation field to another file, which could be called "vectorImage.vtk" 

Are the two files not the same ?

The code segments are taken from the deformableRegistration2.cxx.  (Demons Registration). The ITK software guide does not describe the reason for the second segment.


Thank you in advance.
Emma
Segment 1

  if( argc > 4 ) // if a fourth line argument has been provided...
    {

      typedef itk::ImageFileWriter< DeformationFieldType > FieldWriterType;
      FieldWriterType::Pointer fieldWriter = FieldWriterType::New();
      fieldWriter->SetFileName( argv[4] );
      fieldWriter->SetInput( filter->GetOutput() );

      fieldWriter->Update();
   }




Segment 2

  if( argc > 5 ) 
    {

      typedef DeformationFieldType  VectorImage2DType;
      typedef DeformationFieldType::PixelType Vector2DType;

      VectorImage2DType::ConstPointer vectorImage2D = filter->GetOutput();

      VectorImage2DType::RegionType  region2D = vectorImage2D->GetBufferedRegion();
      VectorImage2DType::IndexType   index2D  = region2D.GetIndex();
      VectorImage2DType::SizeType    size2D   = region2D.GetSize(); 


      typedef itk::Vector< float,       3 >  Vector3DType;
      typedef itk::Image< Vector3DType, 3 >  VectorImage3DType;

      typedef itk::ImageFileWriter< VectorImage3DType > WriterType;

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

      VectorImage3DType::Pointer vectorImage3D = VectorImage3DType::New();
  
      VectorImage3DType::RegionType  region3D;
      VectorImage3DType::IndexType   index3D;
      VectorImage3DType::SizeType    size3D;

      index3D[0] = index2D[0];
      index3D[1] = index2D[1];
      index3D[2] = 0;
  
      size3D[0]  = size2D[0];
      size3D[1]  = size2D[1];
      size3D[2]  = 1;

      region3D.SetSize( size3D );
      region3D.SetIndex( index3D );

      vectorImage3D->SetRegions( region3D );
      vectorImage3D->Allocate();
  
      typedef itk::ImageRegionConstIterator< VectorImage2DType > Iterator2DType;

      typedef itk::ImageRegionIterator< VectorImage3DType > Iterator3DType;

      Iterator2DType  it2( vectorImage2D, region2D );
      Iterator3DType  it3( vectorImage3D, region3D );

      it2.GoToBegin();
      it3.GoToBegin();

      Vector2DType vector2D;
      Vector3DType vector3D;

      vector3D[2] = 0; // set Z component to zero.

      while( !it2.IsAtEnd() )
        {
            vector2D = it2.Get();
            vector3D[0] = vector2D[0];  
            vector3D[1] = vector2D[1];  
            it3.Set( vector3D );
            ++it2;
            ++it3;
        }


      writer3D->SetInput( vectorImage3D );

      writer3D->SetFileName( argv[5] );

      try
        {
            writer3D->Update();
        }
      catch( itk::ExceptionObject & excp )
        {
            std::cerr << excp << std::endl;
        return -1;
        }

}








       
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070802/64902a74/attachment.html


More information about the Insight-users mailing list