Hi Luis,<br><br> Yes. Option B will work, but need small modifications:<br><br> Replace Line 481-484 with:<br><br> if( this->GetPixelType() == ImageIOBase::VECTOR )<br> {<br> file << "VECTORS vectors "
<br> << this->GetComponentTypeAsString(m_ComponentType) << "\n";<br> }<br> else<br> {<br> file << "SCALARS scalars "<br> << this->GetComponentTypeAsString(m_ComponentType) << " "
<br> << this->GetNumberOfComponents() << "\n";<br> file << "LOOKUP_TABLE default\n";<br> }<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->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 <<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>>:</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> instead of using the vtkStructuredPointsReader.<br><br><br><br>B: Enjoy Open Source: you could modify the
itkVTKImageIO.cxx<br> file in line 481 in order to write out "VECTORS" instead<br> of "SCALARS". You probably want to do this with code such<br> as:<br><br><br> if( this->GetPixeltype() == ImageIOBase::VECTOR )
<br> {<br> file << "SCALARS scalars";<br> }<br> else<br> {<br> file << "VECTORS vectors";<br> }<br> file << this->GetComponentTypeAsString( m_ComponentType)...
<br><br><br><br>"B" 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> Thanks<br><br><br> Luis<br><br><br>-------------------
<br>Wei Xiong wrote:<br>> Hi ITKers and VTKers,<br>><br>> I have some problems in saving and displaying registration<br>> deformation field in VTK format.<br>><br>> The code in ITK is<br>><br>> typedef itk::Vector< float, Dimension > VectorPixelType;
<br>> typedef itk::Image< VectorPixelType, Dimension > DeformationFieldType;<br>> typedef itk::ImageFileWriter< DeformationFieldType > FieldWriterType;<br>> FieldWriterType::Pointer fieldWriter = FieldWriterType::New();
<br>> fieldWriter->SetFileName( "field.vtk" );<br>> fieldWriter->SetInput( nrreg->GetDeformationField() );<br>> fieldWriter->Update();<br>><br>> The code in VTK is<br>><br>
> vtkStructuredPointsReader *fieldReader = vtkStructuredPointsReader::New();<br>> fieldReader->SetFileName( "field.vtk" );<br>> vtkArrowSource *arrow = vtkArrowSource::New();<br>> vtkMaskPoints *masker = vtkMaskPoints::New();
<br>> masker->SetOnRatio( 1000 );<br>> masker->RandomModeOn();<br>> masker->SetInputConnection( fieldReader->GetOutputPort() );<br>> vtkGlyph3D *glyph = vtkGlyph3D::New();<br>> glyph->SetInputConnection( masker->GetOutputPort() );
<br>> glyph->SetScaleModeToScaleByVector();<br>> glyph->SetColorModeToColorByVector();<br>> glyph->OrientOn();<br>> glyph->SetVectorModeToUseVector();<br>> glyph->SetSourceConnection( arrow->GetOutputPort() );
<br>> vtkPolyDataMapper *glyphmapper = vtkPolyDataMapper::New();<br>> glyphmapper->SetInputConnection(glyph->GetOutputPort());<br>> vtkActor *glyphactor = vtkActor::New();<br>><br>> Displaying in VTK results in all arrows just pointing to one direction,
<br>> say along X-axis.<br>> I found this is because ITK save field data in VTK using Data Attribute<br>> in the header:<br>><br>> SCALARS scalars float 3<br>> LOOKUP_TABLE default<br>><br>> If I manually change it to:
<br>><br>> VECTORS vectors float<br>><br>> Then, glyphs are displayed correctly.<br>><br>> I also tried to use itkVTKImageIO to correct this behavior using the code:<br>><br>> typedef itk::VTKImageIO VTKImageIOType;
<br>> VTKImageIOType::Pointer vtkIO = VTKImageIOType::New();<br>> vtkIO->SetComponentType( VTKImageIOType::FLOAT );<br>> vtkIO->SetPixelType( VTKImageIOType::VECTOR );<br>> fieldWriter->SetImageIO( vtkIO );
<br>><br>> ITK just saves in the same way. Don't work.<br>><br>> Can I change the behavior of ITK or is there any filter in VTK can<br>> correct this?<br>> Anyone has some ideas on this.<br>><br>> Thank you very much!
<br>> Mengda<br>><br>><br>> ------------------------------------------------------------------------<br>><br>> _______________________________________________<br>> This is the private VTK discussion list.
<br>> 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>> Follow this link to subscribe/unsubscribe:<br>> <a href="http://www.vtk.org/mailman/listinfo/vtkusers">
http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div><br>