def FindRefs3(a):
    box = tuple(x / 8 for x in a.shape)
z = ast(a, shape=(8, 8) + box, strides=(a.strides[0] * box[0], a.strides[1] *
    box[1]) + a.strides)
v3 = np.max(z, axis=-1)
i3r = np.argmax(z, axis=-1)
v2 = np.max(v3, axis=-1)
i2 = np.argmax(v3, axis=-1)
i2x = np.indices(i2.shape)
i3 = i3r[np.ix_(*[np.arange(x) for x in i2.shape]) + (i2,)]
i3x = np.indices(i3.shape)
ix0 = i2x[0] * box[0] + i2
ix1 = i3x[1] * box[1] + i3
return zip(np.ravel(ix0), np.ravel(ix1), np.ravel(v2))
Поиск относительных максимумов двумерного массива numpy