All problems
Stereo Disparity from SSD
Problem
Estimate stereo disparity by minimizing the sum of squared differences.
For each shift d in [0, max_disp] compute the SSD between left[i] and right[i + d] over overlapping positions. Return [d, ssd] for the smallest SSD, breaking ties by smaller d, with the SSD rounded to 4 decimal places.
Test cases
case 1
in: [[1,2,3,4],[0,1,2,3],3]
expected: [1,0]
case 2
in: [[5,5,5],[5,5,5],2]
expected: [0,0]
case 3
in: [[0,10],[10,0],1]
expected: [1,0]
case 4
in: [[1,2],[1,2],0]
expected: [0,0]
Starter codePython
def disparity_ssd(left, right, max_disp):
# Your code here
pass4 test cases · run your code against them in the editor