Skip to content

Commit

Permalink
BUG: Test ImageMaskSpatialObject.CornerPointIsNotInsideMaskOfZeroValues
Browse files Browse the repository at this point in the history
Based on example code from issue #1950, "ImageMaskSpatialObject tries
to access pixels outside the image buffer (segfault)"
  • Loading branch information
N-Dekker committed Aug 6, 2020
1 parent 4a1fdf9 commit e7f7448
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,20 @@ TEST(ImageMaskSpatialObject, IsInsideIndependentOfDistantPixels)


#endif


// Tests that IsInsideInObjectSpace returns false for a corner point, when the
// mask image is filled with zero values. This test would sometimes fail on
// ITK v5.0.1 and v5.1.0
TEST(ImageMaskSpatialObject, CornerPointIsNotInsideMaskOfZeroValues)
{
// Create a mask image, and fill the image with zero vales.
const auto image = itk::Image<unsigned char>::New();
image->SetRegions(itk::Size<>{ { 2, 2 } });
image->Allocate(true);

const auto imageMaskSpatialObject = itk::ImageMaskSpatialObject<2>::New();
imageMaskSpatialObject->SetImage(image);
const double cornerPoint[] = { 1.5, 1.5 };
ASSERT_FALSE(imageMaskSpatialObject->IsInsideInObjectSpace(cornerPoint));
}

0 comments on commit e7f7448

Please sign in to comment.