[Insight-users] ITK to VTK - Vector Images

Hari Sundar mudrarakshasha at yahoo.com
Mon Nov 7 15:23:29 EST 2005


That doesn't seem to make a difference. I think VTK is interpreting
this as a scalar image. Do I need to somehow force VTK to expect it as
a vector image ?

Another strange thing is that I am unable to change the color of the
glyphs. Maybe that tells you something.

I have attached the code so that you can take a look at the output. 

thanks,
~Hari

--- Karthik Krishnan <Karthik.Krishnan at kitware.com> wrote:

> I've done exactly this before and I am certain it works.
> 
> Your code looks good except for this line:
> 
>     glyph->SetVectorModeToUseNormal();
> 
> Usually when you glyph, you want
> 
>     glyph->SetVectorModeToUseVector();
> 
> Using the Normal should explain why you see all of them lined up
> along 
> one axis. At least I hope that's the reason.
> 
> HTH
> Karthik
> 
> Hari Sundar wrote:
> 
> >Hi,
> >
> >I am trying to set up a simple connection between ITK and VTK. It
> >doesn't seem to be working correctly. I started with the
> >itkReadITKImageShowVTK.cxx example file under InsightApplications.
> This
> >example compiles and works correctly.
> >
> >I want to load in a displacement field (MHD file, 3D, 3 Components
> per
> >voxel), and show arrows at each voxel location. However the program
> >that I wrote doesn't display correctly. I see all the arrows aligned
> >with the X axis and of constant length. 
> >
> >Why isn't VTK seeing this as a Vector dataset ? I have attached the
> >main code.
> >
> >thanks,
> >~Hari
> >
> >--
> >try {
> >    const unsigned int ImageDimension = 3;
> >    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);
> >    
> >    vtkOutlineFilter *outline = vtkOutlineFilter::New();
> >    outline->SetInput(vtkImporter->GetOutput());
> >
> >    vtkPolyDataMapper *outlineMapper = vtkPolyDataMapper::New();
> >    outlineMapper->SetInput(outline->GetOutput());
> >
> >    vtkActor *outlineActor = vtkActor::New();
> >    outlineActor->SetMapper(outlineMapper);
> >    outlineActor->GetProperty()->SetColor(0.7, 0.3, 0.1);
> >    
> >    vtkExtractVOI *m_ExtractVOI  = vtkExtractVOI::New();
> >    m_ExtractVOI->SetInput(vtkImporter->GetOutput() );
> >    m_ExtractVOI->SetSampleRate( 4,4,4 );
> >    
> >    vtkArrowSource* vector = vtkArrowSource::New();
> >    
> >    vtkGlyph3D *glyph = vtkGlyph3D::New();
> >    glyph->SetInput( m_ExtractVOI->GetOutput());
> >    glyph->SetSource( vector->GetOutput() );
> >    glyph->SetVectorModeToUseNormal();
> >    glyph->SetScaleModeToScaleByVector();
> >    glyph->SetScaleFactor(2);
> >    
> >    vtkPolyDataMapper *spikeMapper = vtkPolyDataMapper::New();
> >    spikeMapper->SetInput(glyph->GetOutput());
> >    
> >    vtkActor *spikeActor = vtkActor::New();
> >    spikeActor->SetMapper(spikeMapper);
> >    spikeActor->GetProperty()->SetColor(0.0, 0.79, 0.34);
> >
> >    vtkRenderer *ren= vtkRenderer::New();
> >    ren->AddActor( spikeActor );
> >    ren->AddActor( outlineActor );
> >    ren->SetBackground( 0.1, 0.2, 0.4 );
> >
> >    vtkRenderWindow *renWin = vtkRenderWindow::New();
> >    renWin->SetSize(600,600);
> >    renWin->AddRenderer( ren );  
> >    
> >    vtkRenderWindowInteractor *iren =
> vtkRenderWindowInteractor::New();
> >    iren->SetRenderWindow(renWin);
> >    
> >    vtkInteractorStyleTrackballCamera *style =
> >vtkInteractorStyleTrackballCamera::New();
> >    iren->SetInteractorStyle(style);
> >    
> >    iren->Initialize();
> >    iren->Start();
> >    
> >    
> >  }
> >  catch( itk::ExceptionObject & e ) {
> >    std::cerr << "Exception catched !! " << e << std::endl;
> >  }
> >
> >  return 0;
> >}
> >
> > template <typename ITK_Exporter, typename VTK_Importer>
> >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());
> >}
> >
> >
> >bhogaa na bhuktaa vayameva bhuktaaH
> >tapo na tapta.n vayameva taptaaH |
> >kaalo na yaato vayameva yaataaH
> >tR^ishhNaa na jiirNaa vayameva jiirNaaH ||
> >
> >
> >		
> >__________________________________ 
> >Yahoo! FareChase: Search multiple travel sites in one click.
> >http://farechase.yahoo.com
> >_______________________________________________
> >Insight-users mailing list
> >Insight-users at itk.org
> >http://www.itk.org/mailman/listinfo/insight-users
> >
> >  
> >
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 

bhogaa na bhuktaa vayameva bhuktaaH
tapo na tapta.n vayameva taptaaH |
kaalo na yaato vayameva yaataaH
tR^ishhNaa na jiirNaa vayameva jiirNaaH ||


		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fView.cpp
Type: text/x-c++src
Size: 7964 bytes
Desc: 2437058411-fView.cpp
Url : http://public.kitware.com/pipermail/insight-users/attachments/20051107/de42df86/fView-0001.cpp


More information about the Insight-users mailing list