You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix segfault due to invalid masks generation. Fixesnmoehrle#125.
Until now, it was possible that a mask with a 255 in its border was generated,
later failing the `valid_mask` assertions, or, if assertions are disabled
by the build, segementation faults due to invalid memory accesses.
See the example in the added comment for a condition where this could happen.
The key insight is that if a point lay exactly on the "border" between two
pixels, say between pixel N and N+1, it counted as occupying pixel N+1.
So the triangle { (1,1), (1,2), (2,1) } in a 3x3 image would result in mask
64 64 64
64 255 255
64 255 64
(notice the triangle of 255s), instead of the correct mask
64 64 64
64 255 64
64 64 64
This commit fixes it by adding the condition that the last
`x = width-1` and `y = height-1` must not count as `inside` the triangle.
It also improves related assertions in a few places.
0 commit comments