[Insight-users] Save Registration Deformation field in ITK and
	display in VTK glyph
    Wei Xiong 
    wumengda at gmail.com
       
    Tue Dec 26 04:10:24 EST 2006
    
    
  
Hi ITKers and VTKers,
   I have some problems in saving and displaying registration deformation
field in VTK format.
The code in ITK is
   typedef itk::Vector< float, Dimension >    VectorPixelType;
   typedef itk::Image< VectorPixelType, Dimension > DeformationFieldType;
   typedef itk::ImageFileWriter< DeformationFieldType > FieldWriterType;
   FieldWriterType::Pointer fieldWriter = FieldWriterType::New();
   fieldWriter->SetFileName( "field.vtk" );
   fieldWriter->SetInput( nrreg->GetDeformationField() );
   fieldWriter->Update();
The code in VTK is
  vtkStructuredPointsReader *fieldReader = vtkStructuredPointsReader::New();
  fieldReader->SetFileName( "field.vtk" );
  vtkArrowSource *arrow = vtkArrowSource::New();
  vtkMaskPoints *masker = vtkMaskPoints::New();
  masker->SetOnRatio( 1000 );
  masker->RandomModeOn();
  masker->SetInputConnection( fieldReader->GetOutputPort() );
  vtkGlyph3D *glyph = vtkGlyph3D::New();
  glyph->SetInputConnection( masker->GetOutputPort() );
  glyph->SetScaleModeToScaleByVector();
  glyph->SetColorModeToColorByVector();
  glyph->OrientOn();
  glyph->SetVectorModeToUseVector();
  glyph->SetSourceConnection( arrow->GetOutputPort() );
  vtkPolyDataMapper *glyphmapper = vtkPolyDataMapper::New();
  glyphmapper->SetInputConnection(glyph->GetOutputPort());
  vtkActor *glyphactor = vtkActor::New();
Displaying in VTK results in all arrows just pointing to one direction, say
along X-axis.
I found this is because ITK save field data in VTK using Data Attribute in
the header:
SCALARS scalars float 3
LOOKUP_TABLE default
If I manually change it to:
VECTORS vectors float
Then, glyphs are displayed correctly.
I also tried to use itkVTKImageIO to correct this behavior using the code:
typedef itk::VTKImageIO  VTKImageIOType;
VTKImageIOType::Pointer vtkIO = VTKImageIOType::New();
vtkIO->SetComponentType( VTKImageIOType::FLOAT );
vtkIO->SetPixelType( VTKImageIOType::VECTOR );
fieldWriter->SetImageIO( vtkIO );
ITK just saves in the same way. Don't work.
Can I change the behavior of ITK or is there any filter in VTK can correct
this?
Anyone has some ideas on this.
Thank you very much!
Mengda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20061226/ab98e653/attachment.html
    
    
More information about the Insight-users
mailing list