<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> 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" <br><br>Are the two files not the same ?<br><br>The code segments are taken from the deformableRegistration2.cxx. (Demons Registration). The ITK software guide does not describe the reason for the second segment.<br><br><br>Thank you in advance.<br>Emma<br>Segment 1<br><br> if( argc > 4 ) // if a
fourth line argument has been provided...<br> {<br><br> typedef itk::ImageFileWriter< DeformationFieldType > FieldWriterType;<br> FieldWriterType::Pointer fieldWriter = FieldWriterType::New();<br> fieldWriter->SetFileName( argv[4] );<br> fieldWriter->SetInput( filter->GetOutput() );<br><br> fieldWriter->Update();<br> }<br><br><br><br><br>Segment 2<br><br> if( argc > 5 ) <br> {<br><br> typedef DeformationFieldType VectorImage2DType;<br> typedef DeformationFieldType::PixelType Vector2DType;<br><br> VectorImage2DType::ConstPointer vectorImage2D = filter->GetOutput();<br><br> VectorImage2DType::RegionType region2D =
vectorImage2D->GetBufferedRegion();<br> VectorImage2DType::IndexType index2D = region2D.GetIndex();<br> VectorImage2DType::SizeType size2D = region2D.GetSize(); <br><br><br> typedef itk::Vector< float, 3 > Vector3DType;<br> typedef itk::Image< Vector3DType, 3 > VectorImage3DType;<br><br> typedef itk::ImageFileWriter< VectorImage3DType > WriterType;<br><br> WriterType::Pointer writer3D = WriterType::New();<br><br> VectorImage3DType::Pointer vectorImage3D = VectorImage3DType::New();<br> <br> VectorImage3DType::RegionType region3D;<br> VectorImage3DType::IndexType index3D;<br>
VectorImage3DType::SizeType size3D;<br><br> index3D[0] = index2D[0];<br> index3D[1] = index2D[1];<br> index3D[2] = 0;<br> <br> size3D[0] = size2D[0];<br> size3D[1] = size2D[1];<br> size3D[2] = 1;<br><br> region3D.SetSize( size3D );<br> region3D.SetIndex( index3D );<br><br> vectorImage3D->SetRegions( region3D );<br> vectorImage3D->Allocate();<br> <br> typedef itk::ImageRegionConstIterator< VectorImage2DType > Iterator2DType;<br><br> typedef itk::ImageRegionIterator< VectorImage3DType > Iterator3DType;<br><br> Iterator2DType it2( vectorImage2D, region2D
);<br> Iterator3DType it3( vectorImage3D, region3D );<br><br> it2.GoToBegin();<br> it3.GoToBegin();<br><br> Vector2DType vector2D;<br> Vector3DType vector3D;<br><br> vector3D[2] = 0; // set Z component to zero.<br><br> while( !it2.IsAtEnd() )<br> {<br> vector2D = it2.Get();<br> vector3D[0] = vector2D[0]; <br> vector3D[1] = vector2D[1]; <br> it3.Set( vector3D );<br> ++it2;<br> ++it3;<br>
}<br><br><br> writer3D->SetInput( vectorImage3D );<br><br> writer3D->SetFileName( argv[5] );<br><br> try<br> {<br> writer3D->Update();<br> }<br> catch( itk::ExceptionObject & excp )<br> {<br> std::cerr << excp << std::endl;<br> return -1;<br> }<br><br>}<br><br><br><br><br></div></div><br>
<hr size=1>Fussy? Opinionated? Impossible to please? Perfect. <a href="http://us.rd.yahoo.com/evt=48516/*http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 ">Join Yahoo!'s user panel</a> and lay it on us.
</body></html>