Repository navigation
Conversation
Preserve original parabola costs while writing the squared distance transform in place.
Cover in-place and strided costs, brute-force distance fields, rectangular grids, and uniform fields.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference issue
No matching issue found for this defect. Searches for distance-map and distance-transform fixes found no matching open PR.
What does this implement/fix?
The final pass of
dtwrites its result into the same array that contains the original parabola costs. A later output can therefore read an already transformed value instead of the original cost, underestimating the squared distance.For example,
[0, 4, 9, 9]becomes[0, 1, 4, 5], althoughmin_j((q - j)^2 + cost[j])gives[0, 1, 4, 8]. This also affects the public 2D distance fields: for[[1,0,0,0], [0,0,1,0], [0,0,0,1], [0,0,0,1]], the unsigned distance at[3,0]is incorrectlysqrt(5)instead ofsqrt(8).Snapshot the original costs before writing the evaluated envelope. Preserve the existing in-place updates, including strided column views,
Nonereturn, dtype behavior and public APIs. Clarify the in-place contract in the existing docstring. No new dependencies or algorithm examples.Additional information
Prepared and tested with AI assistance. No hardware verification or human review is claimed.
Validation on Linux, Python 3.14.8, with the repository-pinned requirements:
bash runtests.sh: 173 passed in 132.36s, including the repository codestyle and full mypy checks.The tests retain the finite
INFsentinel behavior for all-free/all-occupied maps rather than comparing these cases against SciPy's different boundary convention. Documentation build and macOS/Windows execution were not run locally; there are no RST changes.CheckList