AW: [Insight-users] (no subject)
Stein Daniel
D.Stein at dkfz-heidelberg.de
Fri Aug 3 06:57:27 EDT 2007
Hi Emma,
You are right; the two files contain the same deformation field in 2D
and 3D, respectively. But if you want to open the vector field in
ParaView you need 3D because ParaView can only handle 3D vector fields.
Please have a look at ITK software guide "8.15.1 Visualizing 2D
deformation fields" on page 470 for further informations.
Best wishes,
Daniel
________________________________
Von: insight-users-bounces+d.stein=dkfz-heidelberg.de at itk.org
[mailto:insight-users-bounces+d.stein=dkfz-heidelberg.de at itk.org] Im
Auftrag von Emma Ryan
Gesendet: Donnerstag, 2. August 2007 22:20
An: Luis Ibanez
Cc: insight-users at itk.org
Betreff: [Insight-users] (no subject)
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%20> and lay it on us.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070803/a80fd520/attachment.html
More information about the Insight-users
mailing list