[Insight-users] Re: Visualizing a binary itk-Image

Luis Ibanez luis.ibanez@kitware.com
Wed, 12 Mar 2003 09:59:24 -0500


Hi Zein,


1) The vtkImageActor will show by default the first slice
    of a volume. In order to see other slices you have to
    invoke the method SetZSlice().

    Please look at the documentation of this class

    http://www.vtk.org/doc/nightly/html/classvtkImageActor.html

    You may want to add a Slider to your FLTK GUI and
    make the callback to invoke SetZSlice() in the vtk
    class.



2) You can get displays of orthogonal slices by using
    the vtkImagePlaneWidget. This may be more interactive.

    http://www.vtk.org/doc/nightly/html/classvtkImagePlaneWidget.html



3) VTK until recently was not friendly with other OpenGL
    windows in the same application. This has been fixed now.

    If you get VTK 4.2 this problem should go away.




Please let us know if you have further questions.


Thanks


    Luis


-----------------------------

salah wrote:
> Hi Luis,
> 
> I have written this piece of code. I based on the class  itk::ImageToVTKImageFilter and actually hacked the rest from the example VTKtoITKtoVTK found in 
> /InsightApplications/Auxiliary/vtk/
> 
> // read the input image
>    VolumeReaderType::Pointer  in_Reader = VolumeReaderType::New();
>    in_Reader->SetFileName( "/data/RawFiles/smallmastoid.mhd" );
>    in_Reader->Update();
>    this->ShowImage( in_Reader->GetOutput(), "Original Image" );   // using  the normal FltkImageViewer
> 
>    ImageType::Pointer m_Image = in_Reader->GetOutput();
> 
> // ITK to VTK pipeline
> //------------------------------------------------------------------------
>    typedef itk::ImageToVTKImageFilter<ImageType> Itk2VtkType;
>    Itk2VtkType::Pointer  m_Itk2Vtk = Itk2VtkType::New();
> 
>    m_Itk2Vtk->SetInput(m_Image);  // m_Reader reads a binary image
>    m_Itk2Vtk->Update();
> 
> 
> // VTK pipeline.
> //------------------------------------------------------------------------
> 
>   // Create a vtkImageActor to help render the image.  
>   vtkImageActor* actor = vtkImageActor::New();
>   actor->SetInput(m_Itk2Vtk->GetOutput());
>   
>   // Create a renderer, render window, and render window interactor to display the results.
>   vtkRenderer* renderer = vtkRenderer::New();
>   vtkRenderWindow* renWin = vtkRenderWindow::New();
>   vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
>   
>   renWin->SetSize(500, 500);
>   renWin->AddRenderer(renderer);
>   iren->SetRenderWindow(renWin);
>   
>   // Add the vtkImageActor to the renderer for display.
>   renderer->AddActor(actor);
>   renderer->SetBackground(0.4392, 0.5020, 0.5647);
> 
>   // Bring up the render window and begin interaction.
>   renWin->Render();
>   iren->Start();
>   
>   
>   // VTK does not use smart pointers, so we must clean up its pipeline
>   // explicitly.
>   iren->Delete();
>   renWin->Delete();
>   renderer->Delete();
>   actor->Delete();
> 
> 
> This code ran with no compile or link errors. It hase two problems:
> 
> 1. In the vtk windows, I can see only the first slide of the input image. I can move this slice freely, but is only ONE slice, not a 3D image.
> 2. After I close the vtk windows, The FltkImageViewer windows does not respond to any of its controls (buttons, sliders, ....). 
> 
> Could you please guess, what is going on????
> 
> Many thanks in advanced....
> 
> Zein
> 
> ->8<------------->8<------------->8<------------->8<------------->8<------------->8<-
> Zein I. Salah 
> University of Tübingen, WSI-GRIS, Sand 14, 72076 Tübingen 
> Email: salah@gris.uni-tuebingen.de
> Tel.: (07071) 29 75465 (GRIS),           Fax: (07071) 29 54 66
> 
>