InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.42k stars 664 forks source link

Let `ImageSpatialObject` update the image regions of its base class, let `ImageMaskSpatialObject` use these image regions #4450

Closed N-Dekker closed 9 months ago

N-Dekker commented 9 months ago

SpatialObject stores the image regions of the spatial object. It appears reasonable for its derived class ImageSpatialObject to keep them up-to-date, in accordance with its image.

A significant performance improvement of ImageMaskSpatialObject is then achieved by using the buffered region and the requested region as cached in its base class, instead of calling the virtual functions GetBufferedRegion() and GetRequestedRegion() from its image.


It's interesting to see that the common base class itk::SpatialObject already has those data members to cache the image regions (m_LargestPossibleRegion, m_RequestedRegion, m_BufferedRegion), but it looks like they weren't used anywhere, as far as I can see:

https://github.com/InsightSoftwareConsortium/ITK/blob/436423d798e63e72444dd4a9d8787ffd34c5eb60/Modules/Core/SpatialObjects/include/itkSpatialObject.h#L731-L733

For the record, those data members were added to itk::SpatialObject with commit 433987062ccaee80c9a7d2f6c1ff857fe96cf929 "ENH: Removed NDimensionalSpatialObject", Julien Jomier (@jjomier), 10 February 2003.