Skip to content
DeepForgeby svx
All problems
HardComputer Visioncv-078

Harris Corner Response

Problem

Compute the Harris corner response for every interior window.

First compute Sobel gradients gx and gy in valid mode. Then slide a 3x3 window over those maps accumulating sxx, syy and sxy, with response R = det - 0.04 * trace^2 where det = sxx * syy - sxy^2 and trace = sxx + syy. Round to 4 decimal places; the output shape is (H - 4) x (W - 4).

Hint

A corner has both large gradient responses, so det dominates the trace term.

Test cases

case 1
in: [[[3,3,3,3,3],[3,3,3,3,3],[3,3,3,3,3],[3,3,3,3,3],[3,3,3,3,3]]]
expected: [[0]]
case 2
in: [[[0,0,0,0,0],[0,0,0,0,0],[0,0,9,9,9],[0,0,9,9,9],[0,0,9,9,9]]]
expected: [[13222776.96]]
case 3
in: [[[0,0,0,0,0],[0,0,0,0,0],[0,0,9,0,0],[0,0,0,0,0],[0,0,0,0,0]]]
expected: [[793618.56]]
case 4
in: [[[0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,5,5,5,5],[0,0,5,5,5,5],[0,0,5,5,5,5]]]
expected: [[1259600,950900]]
Starter codePython
def harris_response(image):
    # Your code here
    pass

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