Hi Luis,<br><br>&nbsp;&nbsp; Yes. Option B will work, but need small modifications:<br><br>&nbsp; Replace Line 481-484 with:<br><br>&nbsp; if( this-&gt;GetPixelType() == ImageIOBase::VECTOR )<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; file &lt;&lt; &quot;VECTORS vectors &quot;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt; this-&gt;GetComponentTypeAsString(m_ComponentType) &lt;&lt; &quot;\n&quot;;<br>&nbsp; }<br>&nbsp; else<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; file &lt;&lt; &quot;SCALARS scalars &quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt; this-&gt;GetComponentTypeAsString(m_ComponentType) &lt;&lt; &quot; &quot;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt; this-&gt;GetNumberOfComponents() &lt;&lt; &quot;\n&quot;;<br>&nbsp;&nbsp;&nbsp; file &lt;&lt; &quot;LOOKUP_TABLE default\n&quot;;<br>&nbsp; }<br><br>I also find vtkAssignAttribute in VTK can overcome this problem without modifying ITK. Filter the data with before Glyph:
<br><br>vtkAssignAttribute *assigner = vtkAssignAttribute::New();<br>assigner-&gt;Assign( vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);<br><br>Therefore, I think it is OK without modifying ITK.
<br><br>Guanglei<br><br><div><span class="gmail_quote">2006/12/31, Luis Ibanez &lt;<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><br>Hi Wei,<br><br>Here are a couple of options:<br><br><br>A: Have you tried using the vtkImageReader ?<br>&nbsp;&nbsp;&nbsp;&nbsp;instead of using the vtkStructuredPointsReader.<br><br><br><br>B: Enjoy Open Source: you could modify the 
itkVTKImageIO.cxx<br>&nbsp;&nbsp;&nbsp;&nbsp;file in line 481 in order to write out &quot;VECTORS&quot; instead<br>&nbsp;&nbsp;&nbsp;&nbsp;of &quot;SCALARS&quot;. You probably want to do this with code such<br>&nbsp;&nbsp;&nbsp;&nbsp;as:<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp; if( this-&gt;GetPixeltype() == ImageIOBase::VECTOR )
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file &lt;&lt; &quot;SCALARS scalars&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file &lt;&lt; &quot;VECTORS vectors&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;file &lt;&lt; this-&gt;GetComponentTypeAsString( m_ComponentType)...
<br><br><br><br>&quot;B&quot; is probably a better option. Please give it a try<br>and let us know if we should make the changes in the<br>CVS repository.<br><br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;Thanks<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Luis<br><br><br>-------------------
<br>Wei Xiong wrote:<br>&gt; Hi ITKers and VTKers,<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;I have some problems in saving and displaying registration<br>&gt; deformation field in VTK format.<br>&gt;<br>&gt; The code in ITK is<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;typedef itk::Vector&lt; float, Dimension &gt;&nbsp;&nbsp;&nbsp;&nbsp;VectorPixelType;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;typedef itk::Image&lt; VectorPixelType, Dimension &gt; DeformationFieldType;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;typedef itk::ImageFileWriter&lt; DeformationFieldType &gt; FieldWriterType;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;FieldWriterType::Pointer fieldWriter = FieldWriterType::New();
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;fieldWriter-&gt;SetFileName( &quot;field.vtk&quot; );<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;fieldWriter-&gt;SetInput( nrreg-&gt;GetDeformationField() );<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;fieldWriter-&gt;Update();<br>&gt;<br>&gt; The code in VTK is<br>&gt;<br>
&gt;&nbsp;&nbsp; vtkStructuredPointsReader *fieldReader = vtkStructuredPointsReader::New();<br>&gt;&nbsp;&nbsp; fieldReader-&gt;SetFileName( &quot;field.vtk&quot; );<br>&gt;&nbsp;&nbsp; vtkArrowSource *arrow = vtkArrowSource::New();<br>&gt;&nbsp;&nbsp; vtkMaskPoints *masker = vtkMaskPoints::New();
<br>&gt;&nbsp;&nbsp; masker-&gt;SetOnRatio( 1000 );<br>&gt;&nbsp;&nbsp; masker-&gt;RandomModeOn();<br>&gt;&nbsp;&nbsp; masker-&gt;SetInputConnection( fieldReader-&gt;GetOutputPort() );<br>&gt;&nbsp;&nbsp; vtkGlyph3D *glyph = vtkGlyph3D::New();<br>&gt;&nbsp;&nbsp; glyph-&gt;SetInputConnection( masker-&gt;GetOutputPort() );
<br>&gt;&nbsp;&nbsp; glyph-&gt;SetScaleModeToScaleByVector();<br>&gt;&nbsp;&nbsp; glyph-&gt;SetColorModeToColorByVector();<br>&gt;&nbsp;&nbsp; glyph-&gt;OrientOn();<br>&gt;&nbsp;&nbsp; glyph-&gt;SetVectorModeToUseVector();<br>&gt;&nbsp;&nbsp; glyph-&gt;SetSourceConnection( arrow-&gt;GetOutputPort() );
<br>&gt;&nbsp;&nbsp; vtkPolyDataMapper *glyphmapper = vtkPolyDataMapper::New();<br>&gt;&nbsp;&nbsp; glyphmapper-&gt;SetInputConnection(glyph-&gt;GetOutputPort());<br>&gt;&nbsp;&nbsp; vtkActor *glyphactor = vtkActor::New();<br>&gt;<br>&gt; Displaying in VTK results in all arrows just pointing to one direction,
<br>&gt; say along X-axis.<br>&gt; I found this is because ITK save field data in VTK using Data Attribute<br>&gt; in the header:<br>&gt;<br>&gt; SCALARS scalars float 3<br>&gt; LOOKUP_TABLE default<br>&gt;<br>&gt; If I manually change it to:
<br>&gt;<br>&gt; VECTORS vectors float<br>&gt;<br>&gt; Then, glyphs are displayed correctly.<br>&gt;<br>&gt; I also tried to use itkVTKImageIO to correct this behavior using the code:<br>&gt;<br>&gt; typedef itk::VTKImageIO&nbsp;&nbsp;VTKImageIOType;
<br>&gt; VTKImageIOType::Pointer vtkIO = VTKImageIOType::New();<br>&gt; vtkIO-&gt;SetComponentType( VTKImageIOType::FLOAT );<br>&gt; vtkIO-&gt;SetPixelType( VTKImageIOType::VECTOR );<br>&gt; fieldWriter-&gt;SetImageIO( vtkIO );
<br>&gt;<br>&gt; ITK just saves in the same way. Don&#39;t work.<br>&gt;<br>&gt; Can I change the behavior of ITK or is there any filter in VTK can<br>&gt; correct this?<br>&gt; Anyone has some ideas on this.<br>&gt;<br>&gt; Thank you very much!
<br>&gt; Mengda<br>&gt;<br>&gt;<br>&gt; ------------------------------------------------------------------------<br>&gt;<br>&gt; _______________________________________________<br>&gt; This is the private VTK discussion list.
<br>&gt; Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt; Follow this link to subscribe/unsubscribe:<br>&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers">
http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div><br>