[Insight-users] Extract Image Filter

Miller, James V (Research) millerjv@crd.ge.com
Wed, 5 Feb 2003 17:26:04 -0500


VTK's image viewers do stream.  Since a standard image viewer
can only display one slice at time, it only requests a single 
slice from the pipeline.  We usually control this with a method
on the viewer called SetZSlice(num).  The viewer defines the 
appropriate region and sends the request up the pipeline.

Depending on the filters in the pipeline, that single slice request
may expand to 3 slices upstream or even to the whole dataset if 
an upstream filter requires all of its input.



> -----Original Message-----
> From: Stephen R. Aylward [mailto:aylward@unc.edu]
> Sent: Wednesday, February 05, 2003 10:39 AM
> To: Miller, James V (Research)
> Cc: Luis Ibanez; 'Puja Malik'; itk newsgroup
> Subject: Re: [Insight-users] Extract Image Filter
> 
> 
> Hi,
> 
> Sorry about the confusion, I think we agree.  The viewer should only 
> show what has been calculated and so the viewer's requested region 
> should be the largestpossibleregion until we get a viewer 
> that can stream.
> 
> I think all that Puja needs to do is to init the viewer using the 
> extracted image instead of using the whole image.   But I could be 
> mistaken - I haven't had time to look into this - sorry.   Am 
> I missing 
> something?
> 
> About streaming viewers, does vtk provide streaming viewing 
> of slices? 
> We've got an old version of GlSliceView that is called 
> VTKSliceView. It 
> provides nearly the same functionality since it too derives from 
> SliceView.   I run/compiled that code in well over 3 years, 
> but I could 
> probably revive it if VTK provides slice based streaming to a 
> 2D window. 
>    But...itsa viewer and this is itk :)
> 
> Thanks - see ya soon,
> Stephen
> 
> 
> Miller, James V (Research) wrote:
> > A viewer should only show the RequestedRegion. The RequestedRegion
> > is the only area that an algorithm HAS to provide valid pixel values
> > for.  In other words, an algorithm may not set all the pixels in 
> > the BufferedRegion. (This behavior is not recommended but 
> not enforced
> > either).
> > 
> > A viewer should never try to show the LargestPossibleRegion (unless
> > the LargestPossibleRegion happens to be the same as the 
> RequestedRegion).
> > 
> > Now, what should be happening is that the viewer should be 
> "requesting"
> > that the pipeline provide a particular region.  The viewer should be
> > setting the RequestedRegion on the last node in the 
> pipeline.  The viewer
> > should then check whether the BufferedRegion is the same 
> size as the 
> > RequestedRegion.  If they match, then the viewer knows the data is 
> > contiguous in memory and viewing should be straightforward.  If they
> > do not match, then the viewer either has to be able to handle the 
> > fact that it is supposed to display a subregion of the 
> buffered region
> > or the viewer needs to "copy" the RequestedRegion to a 
> contiguous block
> > of memory.
> > 
> > The other option is for the viewer to set the RequestedRegion to be
> > the LargestPossibleRegion.  This is a quick fix but not a 
> recommended
> > solution.
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> >>-----Original Message-----
> >>From: Stephen R. Aylward [mailto:aylward@unc.edu]
> >>Sent: Tuesday, February 04, 2003 3:49 PM
> >>To: Luis Ibanez
> >>Cc: Miller, James V (Research); 'Puja Malik'; itk newsgroup
> >>Subject: Re: [Insight-users] Extract Image Filter
> >>
> >>
> >>The difficult thing is that viewers need an entire slice 
> per view (at 
> >>least).   I don't think any viewer will work if it is only passed a 
> >>Requested or Buffered region.   FltkImageViewer actually has 
> >>a built-in 
> >>volume renderer, hence it does a GetLargestPossibleRegion.
> >>
> >>We could try to determine which data is currently being 
> >>viewed, and then 
> >>pass that back as the requested region - in effect, the 
> >>viewer would end 
> >>up driving the pipeline - calculations are made based on 
> >>which slice the 
> >>user is currently viewing.
> >>
> >>There are commercial viz systems for medicine that work that 
> >>way: slice 
> >>based.
> >>
> >>I could try to check something in really fast on this...just 
> >>kidding... 
> >>  Perhaps we can talk about it at the meeting on Thursday.
> >>
> >>Stephen
> >>
> >>Luis Ibanez wrote:
> >>
> >>
> >>>Jim,
> >>>
> >>>Well, may this is the problem....
> >>>
> >>>fltkImageViewer uses internally the GLSliceViewer
> >>>which in the SetInputImage() method it asks for
> >>>
> >>>      GetLargestPossibleRegion()
> >>>
> >>>Should be change it for "GetRequestedRegion()"
> >>>or "GetBufferedRegion()" ?
> >>>
> >>>
> >>>Luis
> >>>
> >>>
> >>>
> >>>--------------------------------------------
> >>>
> >>>
> >>>Miller, James V (Research) wrote:
> >>>
> >>>
> >>>>Luis,
> >>>>
> >>>> 
> >>>>
> >>>>Does this mean there is an issue with the FLTK image 
> >>>
> >>viewer?  Is it 
> >>
> >>>>triggering off the wrong Region?
> >>>>
> >>>> 
> >>>>
> >>>>Jim
> >>>>
> >>>>    -----Original Message-----
> >>>>    *From:* Puja Malik [mailto:puja.malik@MEMcenter.unibe.ch]
> >>>>    *Sent:* Tuesday, February 04, 2003 11:27 AM
> >>>>    *To:* itk newsgroup
> >>>>    *Subject:* [Insight-users] Extract Image Filter
> >>>>
> >>>>    Hi Luis,
> >>>>
> >>>>    I've managed to fix my problem in the 
> >>>
> >>ExtractImageFilter.  I do have
> >>
> >>>>    one concern though.  I cannot directly use the image 
> >>>
> >>object from the
> >>
> >>>>    output of the filter, and view it in the fltk image 
> >>>
> >>filter.  If I do
> >>
> >>>>    this, the images intensity range is altered, and the 
> >>>
> >>first slice is
> >>
> >>>>    distorted.  I must first write the output of the 
> filter ( image
> >>>>    object ) to a file, read it back into a new image 
> >>>
> >>object and then
> >>
> >>>>    view it.  This way, I see a correctly extracted image. 
> >>>
> >> This is very
> >>
> >>>>    strange.  It would be convenient if the output of the 
> >>>
> >>filter could
> >>
> >>>>    be used directly.  Please see my code below, including 
> >>>
> >>the extra
> >>
> >>>>    steps I needed to perform to get the desired results.
> >>>>
> >>>>    void ExtractImageRegion(ImageType::Pointer imIN, 
> >>>
> >>ImageType::SizeType
> >>
> >>>>    regSize,
> >>>>                                                       
> >>>>ImageType::IndexType
> >>>>    regIndex)
> >>>>    {
> >>>>
> >>>>     typedef itk::ExtractImageFilter< ImageType, ImageType 
> >>>
> >>>FilterType;
> >>>
> >>>>     FilterType::Pointer filter = FilterType::New();
> >>>>     ImageType::Pointer imOUT;
> >>>>
> >>>>     ImageType::RegionType region;
> >>>>     region.SetSize(regSize);
> >>>>     region.SetIndex(regIndex);
> >>>>
> >>>>     filter->SetExtractionRegion(region);
> >>>>     filter->SetInput(imIN);
> >>>>     filter->Update();
> >>>>         // View(filter->GetOutput(), "region");  <-- doing this 
> >>>>directly
> >>>>    shows a distorted image
> >>>>
> >>>>    //the following is the extra steps needed to view a 
> >>>
> >>correct image
> >>
> >>>>    //View, Read, WriteMetaFile are my own functions 
> >>>
> >>written using itk
> >>
> >>>>    classes.
> >>>>        imOUT = filter->GetOutput();
> >>>>        imOUT->DisconnectPipeline();
> >>>>             ImageType::Pointer im;
> >>>>        
> >>>
> >>WriteMetaFile("/home/encephalon/puja/testRegion.mhd", imOUT);
> >>
> >>>>         im=Read("/home/encephalon/puja/testRegion.mhd");
> >>>>         View(im, "region");
> >>>>
> >>>>    }
> >>>>
> >>>>    Thanks for your help,
> >>>>    Puja
> >>>>
> >>>>-- 
> >>>>---------------------------------------
> >>>>Puja Malik
> >>>>Surgical Instruments Group
> >>>>MEM Research Center for Orthopaedic Surgery
> >>>>Institute for Surgical Technology and Biomechanics 
> >>>
> >>University of Bern
> >>
> >>>>Murtenstrasse 35, P.O. Box 8354
> >>>>3010 Bern, Switzerland
> >>>>Phone: +41-31-632-8730
> >>>>Fax: +41-31-632-4951
> >>>>Email: Puja.Malik@MEMcenter.unibe.ch
> >>>>http://www.MEMcenter.unibe.ch
> >>>>---------------------------------------
> >>>>
> >>>>     
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>_______________________________________________
> >>>Insight-users mailing list
> >>>Insight-users@public.kitware.com
> >>>http://public.kitware.com/mailman/listinfo/insight-users
> >>
> >>
> >>
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users@public.kitware.com
> > http://public.kitware.com/mailman/listinfo/insight-users
> 
> 
> -- 
> ===============================================
> Dr. Stephen R. Aylward
> Assistant Professor of Radiology
> Adjunct Assistant Professor of Computer Science
> http://caddlab.rad.unc.edu
> aylward@unc.edu
> (919) 966-9695
>