Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-352

Lucas-Kanade Window Sum

Problem

Accumulate the sums that build the Lucas-Kanade structure matrix over one window.

Return [sum(ix^2), sum(ix*iy), sum(iy^2)] over the two H x W gradient maps, each rounded to 4 decimal places. An all-zero window returns zeros.

Hint

These three sums form the symmetric 2x2 matrix inverted by Lucas-Kanade.

Test cases

case 1
in: [[[1,2],[3,4]],[[1,1],[1,1]]]
expected: [30,10,4]
case 2
in: [[[1,0],[-1,0]],[[0,1],[0,-1]]]
expected: [2,0,2]
case 3
in: [[[2]],[[3]]]
expected: [4,6,9]
case 4
in: [[[0,0],[0,0]],[[0,0],[0,0]]]
expected: [0,0,0]
Starter codePython
def lk_window_sum(ix, iy):
    # Your code here
    pass

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