# ImageMaskSpatialObject IsInside less than half a pixel away?

**URL:** <https://discourse.itk.org/t/imagemaskspatialobject-isinside-less-than-half-a-pixel-away/1807>\
**Category:** Algorithms\
**Created:** [April 22, 2019, 8:45am UTC](https://discourse.itk.org/t/imagemaskspatialobject-isinside-less-than-half-a-pixel-away/1807 "2019-04-22T08:45:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)\
**Post date:** [April 22, 2019, 8:45am UTC](https://discourse.itk.org/t/imagemaskspatialobject-isinside-less-than-half-a-pixel-away/1807/1 "2019-04-22T08:45:02Z")

</div>

[Pull request #751](https://github.com/InsightSoftwareConsortium/ITK/pull/751) proposes two rather simple tests for `ImageMaskSpatialObject::IsInside(point)`:

1. Test [IsInsideSingleZeroPixel](https://github.com/InsightSoftwareConsortium/ITK/blob/0df1d8beb86c986bb493fa27bae69ccd63984506/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectGTest.cxx#L221) has a black pixel (pixel value zero) on a white background (pixel value 1)

2. Test [IsInsideSingleNonZeroPixel](https://github.com/InsightSoftwareConsortium/ITK/blob/0df1d8beb86c986bb493fa27bae69ccd63984506/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectGTest.cxx#L248) has a white pixel on a black background.

The first test passed successfully but the second one fails: [https://open.cdash.org/testDetails.php?test=756152233&build=5870461](https://open.cdash.org/testDetails.php?test=756152233&build=5870461)

Regarding the first test:

`IsInside(point)` returns **false** for a point that has exactly the same coordinates as the index of the black pixel, and also for a point that is less than half a pixel size away from the black pixel index. OK?

Regarding the second test:

`IsInside(point)` returns **true** for a point that has exactly the same coordinates as the index of the white pixel. But what if the point is just very close to the pixel index (less than half a pixel size away)? My expectations fail, for both:

```
spatialObject->IsInside(PointType{ indexValue - 0.4999 })
spatialObject->IsInside(PointType{ indexValue + 0.4999 })

```

(In this case, `indexValue` is the index value of the white pixel.)

Please tell me what you think!
