Dynamic Programming Stereo: Monotonicity Check
Dynamic Programming stereo matching relies on the monotonicity constraint: pixel ordering is preserved between views.
A valid DP path can only move right (i+1,j), down (i,j+1), or diagonal (i+1,j+1).
Violation occurs if: i decreases OR j decreases between consecutive points.
Given a path as list of (i,j) pairs, return True if monotonicity is violated, False otherwise.
Constraints:
- 3 ≤ path length ≤ 1000
- 0 ≤ i, j < 1000
Examples:
| Input | Output | |-------|--------| | [(0,0),(1,1),(2,2),(3,3)] | False | | [(0,0),(1,0),(0,1)] | True | | [(0,0),(0,1),(1,1),(1,2)] | False |
Example
path = [(0,0), (1,1), (2,2), (3,3)]
False
- Input:
pathis a list of correspondences : is a column in the left image and the matching column in the right image. The sample has four points, , so there are three moves between neighbouring points. - Math: for each move from to , compute the changes and . Monotonicity is broken if either change is negative.
- Every move here is diagonal: and for , and . No change is negative.
- Output: a single boolean that answers "was the ordering broken?", so a valid path gives
False, the sample output. - Notice the contrast with : the move has . The two image columns would swap order, so the answer is
True. A move with in one coordinate (a pure right or down step) is still allowed.