All problems
Global NCC
Problem
Compute the normalized cross-correlation between two same-shaped images.
Subtract each image mean, then divide the dot product of the centered images by the product of their L2 norms. Return 0.0 when either image is constant, otherwise round to 4 decimal places.
Test cases
case 1
in: [[[1,2],[3,4]],[[1,2],[3,4]]]
expected: 1
case 2
in: [[[1,2],[3,4]],[[-1,-2],[-3,-4]]]
expected: -1
case 3
in: [[[1,2],[3,4]],[[7,7],[7,7]]]
expected: 0
case 4
in: [[[1,2],[3,4]],[[1,2],[3,5]]]
expected: 0.9827
Starter codePython
def global_ncc(a, b):
# Your code here
pass4 test cases · run your code against them in the editor