I have two Numpy arrays (3-dimensional uint8) converted from PIL images.
I want to find if the first image contains the second image, and if so, find out the coordinates of the top-left pixel inside the first image where the match is.
Is there a way to do that purely in Numpy, in a fast enough way, rather than using (4! very slow) pure Python loops?
2D example:
a = numpy.array([
[0, 1, 2, 3],
[4, 5, 6, 7],
[8, 9, 10, 11]
])
b = numpy.array([
[2, 3],
[6, 7]
])
How to do something like this?
position = a.find(b)
position
would then be (0, 2)
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…