[Insight-users] 2 "Update()" - related problems

Luis Ibanez luis.ibanez at kitware.com
Thu, 15 Jan 2004 16:29:31 -0500


Hi Ivan,

Welcome to ITK !

-----------

Problem (1) is a known behavior of the pipeline.

Whenever you anticipate that the region size of
the images to be processed by the pipeline is
subject to change, you must invoke the method

         UpdateLargestPossibleRegion();

instead of the traditional

         Update();

---------

Problem (2) is related to (1).
and it comes down to a design decison of you
application:

   Do you want the users to wait for the smoothing
   of the entire volume even when they are going
   to see a single slice ?

If so, you can simply invoke

       smoother3D->UpdateLargestPossibleRegion();

before you start the user interaction for
visualizing the slices.



---------


The reason why you are finding that connecting a
writer solves problems (1) and (2) is that writers
internally invoke UpdateLargestPossibleRegion().



Regards,



    Luis



--------------------------------
Ivan.Bricault at imag.fr wrote:

> Hi all,
> 
> I started using ITK a few weeks ago, and it's a great toolkit ! 
> Nevertheless, I had some hard time identifying and solving 2 "update()"-
> related problems.
> Are you aware of that kind of problems ?
> Are there any possibly more elegant solutions for that ?
> Thanks !
> 
>   Ivan.
> 
> 
> --------- (1) ---------------
> 
> PROBLEM
> 
> Within my GUI, a button executes a itk::ResampleImageFilter on a 3D image with 
> a user-defined isotropic spacing value (same spacing for x,y,z).
> 
> When the user executes the filter various time with various spacing values, 
> the following exception is caught during " resampler->Update(); " : 
> 
> 
>      Requested region is (at least partially) outside the largest possible 
> region.
>      Location: Image::PropagateRequestedRegion()
> 
> 
> This happens when (and only when) the new spacing value is superior to the 
> spacing value used during the previous resample filter update.
> 
> 
> 
> SOLUTION
> 
> I connected a writer to the resampler :  " writer->SetInput(resampler-
> 
>>GetOutput()); "
> 
> In my code, instead of doing
>      " resampler->Update(); "
> I changed for 
>      " writer->Update(); "
> 
> Now everything is fine, and no exceptions occur.
> 
> 
> ------------- (2) --------------------------------------
> 
> PROBLEM
> 
> I use the following pipeline to smooth a 3D image (with 
> itk::CurvatureFlowImageFilter), extract a particular slice and then view it 
> with a 2D viewer
> 
>       smoother3D->SetInput(reader3D->GetOutput());
>       extractSlice->SetInput(smoother3D->GetOutput());
>       viewer2D->SetInput(extractSlice->GetOutput());
> 
> Then, after executing " smoother3D->Update(); " : 
> 
> if the user interactively changes the extracted slice to be viewed and 
> generates a " viewer2D->Update(); ",
> it takes a long time to see the new smoothed slice, because ITK seems to need 
> to compute a new smoother3D->Update() which corresponds to some part of the 3D 
> image that was not extracted before, and that has not been smoothed yet 
> (despite of the smoother3D->Update() ).
> 
> SOLUTION
> 
> Again, I connected a writer to the smoother :  " writer->SetInput(smoother3D-
> 
>>GetOutput()); "
> 
> And in my code, instead of doing
>      " smoother3D->Update(); "     (*)
> I changed for 
>      " writer->Update(); "         (**)
> 
> The time needed for executing (**) is longer than for (*). But now the 
> smoothing process is computed all at once, and the user can view the various 
> smoothed slices without experiencing any delay.
> 
> 
> 
>