<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>&nbsp;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".&nbsp; 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.&nbsp; (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>&nbsp; if( argc &gt; 4 ) // if a
 fourth line argument has been provided...<br>&nbsp;&nbsp;&nbsp; {<br><br>&nbsp; &nbsp;&nbsp;&nbsp; typedef itk::ImageFileWriter&lt; DeformationFieldType &gt; FieldWriterType;<br>&nbsp;&nbsp;&nbsp; &nbsp; FieldWriterType::Pointer fieldWriter = FieldWriterType::New();<br>&nbsp;&nbsp;&nbsp; &nbsp; fieldWriter-&gt;SetFileName( argv[4] );<br>&nbsp;&nbsp;&nbsp; &nbsp; fieldWriter-&gt;SetInput( filter-&gt;GetOutput() );<br><br>&nbsp;&nbsp;&nbsp; &nbsp; fieldWriter-&gt;Update();<br>&nbsp;&nbsp; }<br><br><br><br><br>Segment 2<br><br>&nbsp; if( argc &gt; 5 ) <br>&nbsp;&nbsp;&nbsp; {<br><br>&nbsp;&nbsp;&nbsp; &nbsp; typedef DeformationFieldType&nbsp; VectorImage2DType;<br>&nbsp;&nbsp;&nbsp; &nbsp; typedef DeformationFieldType::PixelType Vector2DType;<br><br>&nbsp;&nbsp;&nbsp; &nbsp; VectorImage2DType::ConstPointer vectorImage2D = filter-&gt;GetOutput();<br><br>&nbsp;&nbsp;&nbsp; &nbsp; VectorImage2DType::RegionType&nbsp; region2D =
 vectorImage2D-&gt;GetBufferedRegion();<br>&nbsp;&nbsp;&nbsp; &nbsp; VectorImage2DType::IndexType&nbsp;&nbsp; index2D&nbsp; = region2D.GetIndex();<br>&nbsp;&nbsp;&nbsp; &nbsp; VectorImage2DType::SizeType&nbsp;&nbsp;&nbsp; size2D&nbsp;&nbsp; = region2D.GetSize(); <br><br><br>&nbsp;&nbsp;&nbsp; &nbsp; typedef itk::Vector&lt; float,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3 &gt;&nbsp; Vector3DType;<br>&nbsp;&nbsp;&nbsp; &nbsp; typedef itk::Image&lt; Vector3DType, 3 &gt;&nbsp; VectorImage3DType;<br><br>&nbsp;&nbsp;&nbsp; &nbsp; typedef itk::ImageFileWriter&lt; VectorImage3DType &gt; WriterType;<br><br>&nbsp;&nbsp;&nbsp; &nbsp; WriterType::Pointer writer3D = WriterType::New();<br><br>&nbsp;&nbsp;&nbsp; &nbsp; VectorImage3DType::Pointer vectorImage3D = VectorImage3DType::New();<br>&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp; VectorImage3DType::RegionType&nbsp; region3D;<br>&nbsp;&nbsp;&nbsp; &nbsp; VectorImage3DType::IndexType&nbsp;&nbsp; index3D;<br>&nbsp;&nbsp;&nbsp;
 &nbsp; VectorImage3DType::SizeType&nbsp;&nbsp;&nbsp; size3D;<br><br>&nbsp;&nbsp;&nbsp; &nbsp; index3D[0] = index2D[0];<br>&nbsp;&nbsp;&nbsp; &nbsp; index3D[1] = index2D[1];<br>&nbsp;&nbsp;&nbsp; &nbsp; index3D[2] = 0;<br>&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp; size3D[0]&nbsp; = size2D[0];<br>&nbsp;&nbsp;&nbsp; &nbsp; size3D[1]&nbsp; = size2D[1];<br>&nbsp;&nbsp;&nbsp; &nbsp; size3D[2]&nbsp; = 1;<br><br>&nbsp;&nbsp;&nbsp; &nbsp; region3D.SetSize( size3D );<br>&nbsp;&nbsp;&nbsp; &nbsp; region3D.SetIndex( index3D );<br><br>&nbsp;&nbsp;&nbsp; &nbsp; vectorImage3D-&gt;SetRegions( region3D );<br>&nbsp;&nbsp;&nbsp; &nbsp; vectorImage3D-&gt;Allocate();<br>&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp; typedef itk::ImageRegionConstIterator&lt; VectorImage2DType &gt; Iterator2DType;<br><br>&nbsp;&nbsp;&nbsp; &nbsp; typedef itk::ImageRegionIterator&lt; VectorImage3DType &gt; Iterator3DType;<br><br>&nbsp;&nbsp;&nbsp; &nbsp; Iterator2DType&nbsp; it2( vectorImage2D, region2D
 );<br>&nbsp;&nbsp;&nbsp; &nbsp; Iterator3DType&nbsp; it3( vectorImage3D, region3D );<br><br>&nbsp;&nbsp;&nbsp; &nbsp; it2.GoToBegin();<br>&nbsp;&nbsp;&nbsp; &nbsp; it3.GoToBegin();<br><br>&nbsp;&nbsp;&nbsp; &nbsp; Vector2DType vector2D;<br>&nbsp;&nbsp;&nbsp; &nbsp; Vector3DType vector3D;<br><br>&nbsp;&nbsp;&nbsp; &nbsp; vector3D[2] = 0; // set Z component to zero.<br><br>&nbsp;&nbsp;&nbsp; &nbsp; while( !it2.IsAtEnd() )<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; vector2D = it2.Get();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vector3D[0] = vector2D[0];&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vector3D[1] = vector2D[1];&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; it3.Set( vector3D );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; ++it2;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; ++it3;<br>&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; }<br><br><br>&nbsp; &nbsp;&nbsp;&nbsp; writer3D-&gt;SetInput( vectorImage3D );<br><br>&nbsp;&nbsp;&nbsp; &nbsp; writer3D-&gt;SetFileName( argv[5] );<br><br>&nbsp;&nbsp;&nbsp; &nbsp; try<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; writer3D-&gt;Update();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp; catch( itk::ExceptionObject &amp; excp )<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; std::cerr &lt;&lt; excp &lt;&lt; std::endl;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<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>