[Insight-users] Problem in visualization of the deformation field using vtk
Luis Ibanez
luis.ibanez at kitware.com
Tue Dec 8 08:22:10 EST 2009
Hi Vidhayadhari
Since you are doing this in 2D,
You may want to replace the vtkArrowSource (as the Glyph source)
with the vtkGlyphSource2D class:
http://www.vtk.org/doc/release/4.0/html/classvtkGlyphSource2D.html
and to set it to produce arrows, by calling its method:
SetGlyphTypeToArrow ()
Regards,
Luis
--------------------------------------------------------------------------------------
On Tue, Dec 8, 2009 at 5:00 AM, vidhyadhari <vgondle at gmail.com> wrote:
> 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.
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
More information about the Insight-users
mailing list