Commit ceb157d
BUG: Fix issue #1950, ImageMaskSpatialObject access outside image buffer
Fixed issue #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.1 parent 99c5706 commit ceb157d
2 files changed
Lines changed: 22 additions & 13 deletions
File tree
- Modules/Core/SpatialObjects
- include
- test
Lines changed: 5 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
55 | 46 | | |
56 | | - | |
| 47 | + | |
| 48 | + | |
57 | 49 | | |
58 | 50 | | |
59 | 51 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
0 commit comments