I am trying to find a smaller image in a larger image. I have it done using PIL, but I am looking for ways to speed it up so I am currently looking for some numpy solutions. So far I have gotten to: loading both RGB images to np.arrays
rows, cols = np.where(np.all(haystack == needle[0,0], axis=-1))
for row, col in zip(rows, cols):
if row+h > H or col+w > W: continue
local_haystack = haystack[row:row+h, col:col+w].copy()
And this is where I am stuck, I have tried np.count_nonzeros, np.sum etc. but the problem seems to be, that it counts any color like it would be a flattened array instead of a tuple. So instead of counting 1 for (255, 255, 255) it counts 3 which makes me miss the needle