Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-234

NCC Score Map

Problem

Compute the normalized cross-correlation score map for template matching.

For every valid top-left position compute the correlation coefficient between the image patch and the template with both means subtracted. Constant patches score 0.0; round to 4 decimal places.

Test cases

case 1
in: [[[0,0,0],[0,1,2],[0,3,4]],[[1,2],[3,4]]]
expected: [[0.7746,0.9439],[0.7303,1]]
case 2
in: [[[1,2,3],[4,5,6],[7,8,9]],[[5,5],[5,5]]]
expected: [[0,0],[0,0]]
case 3
in: [[[1,2,3],[4,5,6],[7,8,9]],[[1,2],[4,5]]]
expected: [[1,1],[1,1]]
Starter codePython
def ncc_map(image, template):
    # Your code here
    pass

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