Skip to content

Commit 5d558d3

Browse files
N-Dekkerhjmjohnson
authored andcommitted
BUG: Fix issue #785 removing BoundingBox check from ImageMask IsInside
Fixed issue #785 (ImageMaskSpatialObject IsInside should not depend on distant pixels) by removing the BoundingBox check from `ImageMask::IsInsideInObjectSpace`. It appears that the computed bounding box is too small to recognize all points whose interpolated pixel value is non-zero as being inside. The run-time duration might become either slightly longer or slightly shorter, depending on the image. In practice, the performance effect of this commit appears very small (in either way).
1 parent 8d4676d commit 5d558d3

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

Modules/Core/SpatialObjects/include/itkImageMaskSpatialObject.hxx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,19 @@ ImageMaskSpatialObject< TDimension, TPixel >
4444
{
4545
if( this->GetTypeName().find( name ) != std::string::npos )
4646
{
47-
if( this->GetMyBoundingBoxInObjectSpace()->IsInside(point) )
47+
typename Superclass::InterpolatorType::ContinuousIndexType index;
48+
if( this->GetImage()->TransformPhysicalPointToContinuousIndex( point,
49+
index ) )
4850
{
49-
typename Superclass::InterpolatorType::ContinuousIndexType index;
50-
if( this->GetImage()->TransformPhysicalPointToContinuousIndex( point,
51-
index ) )
51+
using InterpolatorOutputType = typename InterpolatorType::OutputType;
52+
bool insideMask = (
53+
Math::NotExactlyEquals(
54+
DefaultConvertPixelTraits<InterpolatorOutputType>::GetScalarValue(
55+
this->GetInterpolator()->EvaluateAtContinuousIndex(index)),
56+
NumericTraits<PixelType>::ZeroValue() ) );
57+
if( insideMask )
5258
{
53-
using InterpolatorOutputType = typename InterpolatorType::OutputType;
54-
bool insideMask = (
55-
Math::NotExactlyEquals(
56-
DefaultConvertPixelTraits<InterpolatorOutputType>::GetScalarValue(
57-
this->GetInterpolator()->EvaluateAtContinuousIndex(index)),
58-
NumericTraits<PixelType>::ZeroValue() ) );
59-
if( insideMask )
60-
{
61-
return true;
62-
}
59+
return true;
6360
}
6461
}
6562
}

0 commit comments

Comments
 (0)