[Insight-users] Problem in visualization of the deformation field using vtk
vidhyadhari
vgondle at gmail.com
Tue Dec 8 05:00:41 EST 2009
hi,
I am new to ITK. I have a problem in visualization of the
deformation field from a .vtk file using vtk. The following is my code
-----------------------------------------------------------------------------------------------
int main( int argc, char **argv )
{ const unsigned int ImageDimension = 2;
typedef float PixelType;
typedef itk::Vector < float, ImageDimension > VectorType;
typedef itk::Image <VectorType, ImageDimension > ImageType;
typedef itk::ImageFileReader < ImageType > FieldReaderType;
FieldReaderType::Pointer reader = FieldReaderType::New ();
reader->SetFileName( argv[1] );
reader->Update();
typedef itk::VTKImageExport< ImageType > ExportFilterType;
ExportFilterType::Pointer itkExporter = ExportFilterType::New();
itkExporter->SetInput( reader->GetOutput() );
vtkImageImport* vtkImporter = vtkImageImport::New();
ConnectPipelines(itkExporter, vtkImporter);
vtkArrowSource *arrow = vtkArrowSource::New();
vtkMaskPoints *masker = vtkMaskPoints::New();
masker->SetOnRatio( 1000 );
masker->RandomModeOff();
masker->SetInputConnection( vtkImporter->GetOutputPort() );
vtkGlyph2D *glyph = vtkGlyph2D::New();
glyph->SetInputConnection( masker->GetOutputPort() );
glyph->SetSourceConnection( arrow->GetOutputPort() );
glyph->SetVectorModeToUseVector();
glyph->SetColorModeToColorByScalar();
glyph->SetScaleModeToDataScalingOff();
glyph->OrientOn();
glyph->SetScaleFactor( 0.2 );
vtkPolyDataMapper *glyphmapper = vtkPolyDataMapper::New();
glyphmapper->SetInputConnection(glyph->GetOutputPort());
glyphmapper->ScalarVisibilityOn();
vtkActor *glyphactor = vtkActor::New();
glyphactor->SetMapper(glyphmapper);
vtkRenderer *renderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(renderer);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
renderer->AddActor(glyphactor);
renderer->SetBackground(0,0,0);
renderer->ResetCamera();
renderer->GetActiveCamera()->Elevation(60.0);
renderer->GetActiveCamera()->Azimuth(30.0);
renderer->GetActiveCamera()->Zoom(1.25);
renWin->SetSize(100,100);
renWin->Render();
iren->Start();
renderer->Delete();
renWin->Delete();
iren->Delete();
return 0;
}
void ConnectPipelines(ITK_Exporter exporter, VTK_Importer* importer)
{
importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
importer->SetSpacingCallback(exporter->GetSpacingCallback());
importer->SetOriginCallback(exporter->GetOriginCallback());
importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
importer->SetCallbackUserData(exporter->GetCallbackUserData());
}
-------------------------------------------------------------
I get a set of white arrows along some diagonal which remains same
even if I change the input file. Could you please give me some
suggestions on how to view the deformation field using vtk.
regards,
vidhyadhari.
More information about the Insight-users
mailing list