Skip to content
DeepForgeby svx
All problems
HardComputer Visioncv-394

Optical Flow Warp Error

Problem

Compute the photometric error after warping with optical flow.

Sample image2 bilinearly at (x + fx, y + fy), clamping the sample coordinates to the image, and average |image1 - sampled| over all pixels. Return the mean error rounded to 4 decimal places.

Hint

Clamping keeps the warp valid at the image border.

Test cases

case 1
in: [[[1,2],[3,4]],[[0,0],[0,0]],[[0,0],[0,0]],[[1,2],[3,4]]]
expected: 0
case 2
in: [[[0,0],[0,0]],[[0,0],[0,0]],[[0,0],[0,0]],[[1,1],[1,1]]]
expected: 1
case 3
in: [[[1,2],[3,4]],[[1,1],[1,1]],[[0,0],[0,0]],[[0,1],[0,3]]]
expected: 0.5
case 4
in: [[[1,2],[3,4]],[[0,0],[0,0]],[[0.5,0.5],[0.5,0.5]],[[1,2],[3,4]]]
expected: 0.5
Starter codePython
def flow_warp_error(image1, fx, fy, image2):
    # Your code here
    pass

4 test cases · run your code against them in the editor