Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-351

Brightness Constraint Residual

Problem

Evaluate the optical flow brightness constancy constraint pixelwise.

For each pixel compute the residual ix * u + iy * v + it, take its absolute value, and return the mean over all pixels rounded to 4 decimal places. ix, iy and it are H x W gradient maps and u, v are the per-pixel flow components.

Hint

The brightness constraint is zero when the flow exactly explains the temporal change.

Test cases

case 1
in: [[[1,2],[3,4]],[[0,0],[0,0]],[[-1,-2],[-3,-4]],1,0]
expected: 0
case 2
in: [[[1,0],[0,1]],[[0,1],[1,0]],[[-1,-1],[-1,-1]],2,0]
expected: 1
case 3
in: [[[2]],[[1]],[[0]],1,1]
expected: 3
case 4
in: [[[1]],[[1]],[[-2]],0.5,1]
expected: 0.5
Starter codePython
def brightness_constraint_residual(ix, iy, it, u, v):
    # Your code here
    pass

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