ENH: Improve test coverage of ImageMoments#662
Conversation
dzenanz
left a comment
There was a problem hiding this comment.
The code looks good to me, but
File: /home/vsts/work/1/s/Modules/Filtering/ImageStatistics/include/itkImageMomentsCalculator.hxx
Line: 150
Description: itk::ERROR: ImageMomentsCalculator(0x1e15d40): Compute(): Total Mass of the image was zero. Aborting here to prevent division by zero later on.
Add masking from SpatialObjects for computing the ImageMoments.
The template code to replace the often used GetAxisAlignedBoundingBoxRegion is provided in the documentation to facilitate a suggested alternate solution.
The ComputeMyBoundingBox and ComputeObjectToWorldTransform have functionality is moved to protected methods, ProtectedComputeMyBoundingBox and ProtectedComputeObjectToWorldTransform. Document preferred method for updating. Replace use of ComputeMyBoundingBox() with Update(); Replace use of ComputeObjectToWorldTransform() with Update(); Provide legacy methods signatures for ComputeMyBoundingBox and ComputeObjectToWorldTransform as aliases to Update().
cba18b8 to
2f3ab79
Compare
aylward
left a comment
There was a problem hiding this comment.
The only "bug" seems to be in Modules/Filtering/ImageStatistics/test/itkImageMomentsTest.cxx - where there is still a call to ComputeObjectToWorldTransform() that should probably be a call to Update(). The rest seems perfect. Great work! Darn fast work too!!!
Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest.cxx
Outdated
Show resolved
Hide resolved
Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest2.cxx
Outdated
Show resolved
Hide resolved
Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest2.cxx
Outdated
Show resolved
Hide resolved
a7d0aa0 to
655bd62
Compare
Remove the use of legacy deprecated interfaces from ITK use. Use Update() instead of ComputeMyBoundingBox(). Use Update() instead of ComputeObjectToWorldTransform().
The ProtectedComputeMyBoundingBox return value is never used. The value was not propogated through the Update call. In the few casees where false was returned, an exception is now thrown.
655bd62 to
659a1dd
Compare
dzenanz
left a comment
There was a problem hiding this comment.
Looks good, only minor comments
Modules/Core/SpatialObjects/test/itkContourSpatialObjectTest.cxx
Outdated
Show resolved
Hide resolved
Modules/Core/SpatialObjects/test/itkEllipseSpatialObjectTest.cxx
Outdated
Show resolved
Hide resolved
The ordering of the API calls is needed in order to pass the tests. These tests now conform to the simplified API for keeping the state of the spatial object transforms consistent.
659a1dd to
bf84697
Compare
| } | ||
| std::cout<<"[PASSED]"<<std::endl; | ||
|
|
||
| myEllipse->ComputeFamilyBoundingBox( EllipseType::MaximumDepth ); |
There was a problem hiding this comment.
@aylward I'm a little concerned that the ordering of these calls changes the behavior. For example, calling "ComputeFamilyBoundingBox" must occur after calling "Update".
Should "ComputeFamilyBoundingBox" implicitly call update?
There was a problem hiding this comment.
As long as ComputeMyBoundingBox() has been called via Update(), there is no need for ComputeFamilyBoundingBox() to call Update(). We perhaps need to make it clear that function calls to get BoundingBoxes, PerimeterSize, Areas, and other values from the objects must occur after defining the parameters of the object and then calling Update(). I think this is a logical flow, and relatively easy to document. My concern with calling Update() from ComputeFamilyBoundingBox() or any other function is that Update() could be a computationally expensive call. We would need to make certain all computations within Update() are conditional on modified times, and they are not at this time. One thing I did not clear up in the refactoring is the odd handling of modified times by certain spatial objects - there are still some inconsistencies (and some pretzel logic, imo), but I think that the appropriate use of Update() mitigates those deficiencies and will not change behavior once they are resolved.
Add masking from SpatialObjects for
computing the ImageMoments.