[Insight-users] Updating the ImageViewer

Luis Ibanez luis . ibanez at kitware . com
Wed, 25 Jun 2003 16:55:22 -0400


Hi Darby,

The fltkImageViewer is not really an ITK
object, so it doesn't interact with the
pipeline.

The method you are using is probably the best
way of forcing the viewer to refresh. That is,
using an observer and in its Execute() method
force the viewer to Update.

One of the weakness of the fltkImageViewer class
is that it performs a number of internal
operations when you call SetImage().  You may
want to try calling  m_Viewer->SetImage( ... )
as part of the operations in UpdateMyViewer(),
just in the same way that you are invoking

 >   m_Viewer->SetOverlay( m_Caster->GetOutput() );


----

Another way of dealing with the visualization
is to use the set of FLTK+VTK classes.

That is, convert the ITK image to a VTK one
using the ImageToVTKImage filter, and connect
this VTK image to the vtkImageViewer.  Then
in FLTK use the vtkFlRenderWindowInteractor
in order to allow FLTK to control the events
from the GUI.

In this way, the VTK and ITK pipelines will
be connected and updates will be propagated.

You would still need to call Render() on the
vtkRenderWindow using  an observer connected
to your filter, but at least the updates from
the window will use the pipeline mechanism.



    Luis



--------------------------
Darby J Van Uitert wrote:
> I have an application that uses the ThresholdSegmentationLevelSet filter.
> I want to have my viewer update every 100 iterations or so. I have added
> an observer so that it calls my UpdateMyViewer function every iteration.
> That works. And I can get an fltk::Image2DViewer to update each
> iteration.  But I want the segmented image to be an overlay to the original
> image.  So before I view images, I cast them from 2D to 3D because the
> fltk::ImageViewer has an overlay.
> 
> My problem is that the 3D viewer will not update the overlay until the
> end.  I don't know if it is a pipeline issue either since in my
> UpdateMyViewer function has an update call.  It basically does the
> following:
> 
> void UpdateMyViewer()
> {
>   //cast 2D to 3D
>   m_Caster->SetInput( m_thresholdSegmentation->GetOutput() );
>   try {
>     m_Caster->Update();
>   }
>   catch( itk::ExceptionObject & excep }
>     {
>       std::cerr << "Exception caught! " << excep << std::endl;
>   }
> 
>   // 3D fltk::ImageViewer
>   m_Viewer->SetOverlay( m_Caster->GetOutput() );
>   m_Viewer->Update();
>   Fl::check();
> 
> }
> 
> Any help would be appreciated.
> 
> 	-darby j
> ---------------------------
> Darby J Van Uitert
> SCI Institute
> University of Utah
> Email: darbyb at cs . utah . edu
> Phone: 801.585.1869
> ---------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users
>