BUG: Fix issue #1950, "ImageMaskSpatialObject tries to access pixels outside the image buffer (segfault)"#1951
Conversation
|
The test failure that this PR should fix, once it's ready:
|
… access outside image buffer Fixed issue InsightSoftwareConsortium#1950, "ImageMaskSpatialObject tries to access pixels outside the image buffer (segfault)". In the original code, `TransformPhysicalPointToContinuousIndex` did estimate whether the specified point was inside the image buffer, but then `GetInterpolator()->EvaluateAtContinuousIndex(index)` did in some cases still try to access a pixel outside the image buffer. This fix avoids using an interpolator. It only accesses a pixel when its index is inside the buffered region. The use of an interpolator appears less relevant for an image mask than for other spatial objects, as for each mask pixel value, it is usually only interesting to know whether it is zero or non-zero. Added ImageMaskSpatialObject.CornerPointIsNotInsideMaskOfZeroValues unit test.
e7f7448 to
cf54e98
Compare
|
Merged into |
|
@aylward Hi Stephen, because of the holidays (heatwave) I did not have time to ask you for feedback on this issue. I'm very happy to see that Matt merged my PR so quickly already, to avoid those segfaults. But as you are very much involved with spatial objects, is it also OK to you that This PR is certainly OK to me, I just want to be sure it's also fine to you! |
|
@N-Dekker - Hi Neal, This looks good to me! Thanks for checking, and thanks for the fix! I do see arguments either way regarding the use of an interpolator - so not using an interpolator seems reasonable and it would clearly be faster. I appreciate the change! |
Tests behavior regarding ITK issue InsightSoftwareConsortium/ITK#1950 and pull request InsightSoftwareConsortium/ITK#1951
Including a fix of a bug, reported by Theo van Walsum, "Issues with mask in el 5.0.0 when mask extent is smaller then image extent", https://groups.google.com/forum/#!category-topic/elastix-imageregistration/elastix/lSLWJq9Zcgk BUG: Fix issue #1950, "ImageMaskSpatialObject tries to access pixels outside the image buffer (segfault)" InsightSoftwareConsortium/ITK#1951 InsightSoftwareConsortium/ITK@ceb157d
Including a fix of a bug, reported by Theo van Walsum, "Issues with mask in el 5.0.0 when mask extent is smaller then image extent", https://groups.google.com/forum/#!category-topic/elastix-imageregistration/elastix/lSLWJq9Zcgk BUG: Fix issue #1950, "ImageMaskSpatialObject tries to access pixels outside the image buffer (segfault)" InsightSoftwareConsortium/ITK#1951 InsightSoftwareConsortium/ITK@ceb157d
Fixed issue #1950, "ImageMaskSpatialObject tries to access pixels
outside the image buffer (segfault)".
In the original code,
TransformPhysicalPointToContinuousIndexdidestimate whether the specified point was inside the image buffer, but
then
GetInterpolator()->EvaluateAtContinuousIndex(index)did in somecases still try to access a pixel outside the image buffer.
This fix avoids using an interpolator. It only accesses a pixel when its
index is inside the buffered region.
The use of an interpolator appears less relevant for an image mask than
for other spatial objects, as for each mask pixel value, it is usually
only interesting to know whether it is zero or non-zero.
Added ImageMaskSpatialObject.CornerPointIsNotInsideMaskOfZeroValues unit
test.