a[a < 0] = 0
a[a > 0] = 255
b = numpy.random.randn(20, 20)
b[b < 0] = 0
b[b > 0] = 255
a[37:37 + b.shape[0], 84:84 + b.shape[1]] = b
a[a == 0] = -1
b[b == 0] = -1
a[a == 255] = 1
b[b == 255] = 1
max_peak = numpy.prod(b.shape)
c = signal.correlate(a, b, 'valid')
overlaps = numpy.where(c == max_peak)
print(overlaps)
Поиск совпадающих подматриц внутри матрицы