[vtkusers] Deformation field itk->vtk export and visualization

Lodron, Gerald Gerald.Lodron at joanneum.at
Thu Jan 14 04:48:35 EST 2010


Hello

I sucessfully made a 3D registration with ITK Demon registration filter and want to visualize the deformation field using VTK.

The deformation field is of type:

typedef itk::Vector< float, 3>                          VectorPixelType;
typedef itk::OrientedImage<  VectorPixelType, 3>        DeformationFieldType;

I use the itk::ImageToVTKImageFilter to transform it and get a vtkImageData with 3 Components.

My question is:

- is that the right way for bringing it into vtk (wouldn't a vtkPolyData export better, but how?)
- how can i visualize it (example?), i tried it with a lot of ways but all i get are vectros pointing in the same direction, here my very strange code:

vtkImageData* m_Deformation;

m_DeformationExtractorX = vtkImageExtractComponents::New();
m_DeformationExtractorX->SetInputConnection(m_Deformation->GetProducerPort());
m_DeformationExtractorX->SetComponents(1);

m_DeformationExtractorY = vtkImageExtractComponents::New();
m_DeformationExtractorY->SetInputConnection(m_Deformation->GetProducerPort());
m_DeformationExtractorY->SetComponents(2);

m_DeformationExtractorZ = vtkImageExtractComponents::New();
m_DeformationExtractorZ->SetInputConnection(m_Deformation->GetProducerPort());
m_DeformationExtractorZ->SetComponents(3);

m_DeformationResliceX = vtkImageReslice::New();
m_DeformationResliceX->SetInput(m_DeformationExtractorX->GetOutput());
m_DeformationResliceX->SetOutputDimensionality(2);
m_DeformationResliceX->SetInterpolationModeToLinear();

m_DeformationResliceY = vtkImageReslice::New();
m_DeformationResliceY->SetInput(m_DeformationExtractorY->GetOutput());
m_DeformationResliceY->SetOutputDimensionality(2);
m_DeformationResliceY->SetInterpolationModeToLinear();

m_DeformationResliceZ = vtkImageReslice::New();
m_DeformationResliceZ->SetInput(m_DeformationExtractorZ->GetOutput());
m_DeformationResliceZ->SetOutputDimensionality(2);
m_DeformationResliceZ->SetInterpolationModeToLinear();

m_DeformationAppend1 = vtkImageAppendComponents::New();
m_DeformationAppend1->SetInput(0,m_DeformationResliceX->GetOutput());
m_DeformationAppend1->SetInput(1,m_DeformationResliceY->GetOutput());

m_DeformationAppend2 = vtkImageAppendComponents::New();
m_DeformationAppend2->SetInput(0,m_DeformationAppend1->GetOutput());
m_DeformationAppend2->SetInput(1,m_DeformationResliceZ->GetOutput());

m_Arrow = vtkArrowSource::New();

m_DeformationGlyph = vtkGlyph3D::New();
m_DeformationGlyph->SetInput(m_DeformationAppend2->GetOutput());
m_DeformationGlyph->SetScaleModeToScaleByVector();
m_DeformationGlyph->SetColorModeToColorByVector();
m_DeformationGlyph->OrientOn();
m_DeformationGlyph->SetVectorModeToUseVector();
m_DeformationGlyph->SetSourceConnection( m_Arrow->GetOutputPort() );

m_DeformationMapper = vtkPolyDataMapper::New();
m_DeformationMapper->SetInputConnection(m_DeformationGlyph->GetOutputPort());

m_DefActor = vtkActor::New();
m_DefActor->SetMapper(m_DeformationMapper);
m_Renderer->AddActor(m_DefActor);

GetRenderWindow()->Render();








More information about the vtkusers mailing list