[Insight-users] (no subject)
Luis Ibanez
luis.ibanez at kitware.com
Sun Aug 5 10:14:37 EDT 2007
Hi Emma,
Please use a descriptive subject when you submit emails to
the mailing list. That will increase the chances that other
users and developers will reply to your questions.
-----
The first section of code writes directly a 2D image whose pixel
type is a 2D deformation vector. This is the image that you could
use as input to a 2D WarpImageFilter for example. This 2D output
is the natural result of the deformable registration process.
The reason for the second case is that in order to visualize the
deformation field in ParaView/VTK via Glyphs we need to have a 3D
image with 3D vectors. Therefore, on option is to create a 3D image
of 1 slice where every pixel contains a 3D vector with the third
component set to zero.
Since the example was a 2D one, we have to "manually" create
the 3D image of vectors that will contain this single slice
image.
If the example were using a Demons filter in 3D we could just
have used the first segment of code for generating an image of
vectors suitable for being visualized in ParaView / VTK.
Regards,
Luis
-----------------
Emma Ryan wrote:
> 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;
> }
>
> }
>
>
>
>
>
> ------------------------------------------------------------------------
> Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user
> panel
> <http://us.rd.yahoo.com/evt=48516/*http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
> > and lay it on us.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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