[Insight-developers] readers and regions

Miller, James V (Research) millerjv@crd.ge.com
Mon, 22 Apr 2002 13:06:09 -0400


Background on the pipeline (not really pertinent but I had already
typed this out by the time a re-read your message):
-------------------------------------------------------------------

The first time Update() is called, it defaults to grabbing
the LargestPossibleRegion if a specific RequestedRegion has
not been specified.

Subsequent calls to Update() try to update the same RequestedRegion
that it updated the last time.  If a filter has been modified 
such that that requested region is invalid (for instance, the data has
shifted or different scaling is used) then an exception may be thrown.

For these situations, you want to either make sure the RequestedRegion
is always something reasonable or call UpdateLargestPossibleRegion().

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

In your scenario, you told the reader to Update() which generated
an image based on the initialization of the reader (it might have
read the entire volume or it may have read just a portion, I can't
tell from the example).  At this point, the RequestedRegion and the
BufferedRegion probably match (though the buffered region is allowed
to be bigger) and both "may" match the LargestPossibleRegion() if the
reader read the entire dataset (volume).

Then you call SetRequestedRegionToLargestPossibleRegion().  This
made the RequestedRegion match the LargestPossibleRegion but the 
BufferedRegion will be unchanged.  The next time Update() is called, the
reader would read the entire dataset and the Requested/Buffered/ and 
LargestPossibleRegion should all match (in your example).

All image indexing is based off of the BufferedRegion. Algorithms
should never try to access data outside of the BufferedRegion.
If a proper requested region is specified at the tail of the pipeline,
the pipeline mechanism should guarentee that the RequestedRegions
fall within the BufferedRegions. If you pixel access is behaving
strangely, then one of the algorithms is not basing its addressing
off of the BufferedRegion.

In your example, if you move the 

inputImage->SetRequestedRegionToLargestPossibleRegion() before
the reader->Update() call, then you have the data you wanted.
You may still have an indexing problem, however, because it sounds
like something is indexing off of the LargestPossibleRegion when it
should be indexing off of the BufferedRegion.





-----Original Message-----
From: Damion Shelton [mailto:dmshelto@andrew.cmu.edu]
Sent: Monday, April 22, 2002 11:37 AM
To: insight-developers@public.kitware.com
Subject: [Insight-developers] readers and regions


Hi,

Wilson and I figured out (apparently) why the Difference of Gaussians 
gradient filter was breaking, in the context of our multiprocessor machine. 
The problem arises in the following lines:

<reader creation, initialization>
TImageType::Pointer inputImage = reader->GetOutput();
reader->Update();
inputImage->SetRequestedRegionToLargestPossibleRegion();

Later on the code, there is a mismatch between buffered, allocated, and 
requested regions, which causes pixel access to behave quite strangely. 
This problem goes away when we remove:

inputImage->SetRequestedRegionToLargestPossibleRegion();

Why does this work? What's bad about setting the requested region after an 
image is loaded?

Thanks,
-Damion-
_______________________________________________
Insight-developers mailing list
Insight-developers@public.kitware.com
http://public.kitware.com/mailman/listinfo/insight-developers