Repository navigation
fix: replace DSI_refine drange with dmin and ignore NaN planes - #247
Merged
Merged
Conversation
DSI_refine compared drange with plane indices and returned a plane index, so a DSI that did not start at disparity 0 gave wrong values or an IndexError. It also used argmax, which returns the first NaN, so a pixel with a good peak and some NaN planes came out NaN. dmin is the disparity of the first plane; the default 0 keeps the result of DSI_refine(DSI). stereo_BM and stereo_SGBM annotations now include int, which they already accepted. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 8 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
Fixes the two faults in
DSI_refine()from the bug list.drangewas compared with plane indices, and the result was a plane index. For a DSI made bystereo_simple(..., drange=[4, 12])and a true disparity of 8, the refined values were about 4, andDSI_refine(dsi, (4, 12))raisedIndexError. The DSI does not record its first disparity, sodrangeis replaced bydmin, the disparity of the first plane (default 0). The result is the plane index plusdmin, minus the sub-pixel offset.DSI_refine(DSI), as in the book, returns what it did before.np.argmaxreturns the first NaN. A pixel with a good peak and some NaN planes (disparities that reach beyond the image edge) came out NaN. The peak is now the best valid plane. The result is still NaN where every plane is NaN, where the peak is the first or last plane, where a neighbour is NaN, and where the peak is flat (no warnings in the last two cases).The docstring explains that the returned disparities are relative to
drange[0]ofstereo_simple(), and thatdminturns them into true disparities. The function is also no longer a Python loop over pixels.stereo_BMandstereo_SGBMannotations now includeint, which they already accepted (meaning(0, n)).drangeis removed fromDSI_refine, which is incompatible for anyone who passed it, though it only worked when the range started at 0. It is a plainfix:with.. versionchanged:: 2.5.0.Tests: exact parabolas with known sub-pixel peaks,
dmin, peaks in the first and last plane, NaN planes, an all-NaN fibre, a NaN neighbour and a flat peak without warnings, and the DSI from a realstereo_simpleof a shifted pair (true disparity 8, DSI starting at 4, which used to raise). mypy reports no issues and the full suite passes (2118 passed, 33 skipped).AI-assisted: written with Claude Code (Claude Sonnet 5.5) and reviewed by the maintainer.
🤖 Generated with Claude Code