I have a numpy array of size 2000*4000 with binary values in it. I have a template that I would like to match with my source array. Currently I'm running a sliding window over the source array. Although this method works fine, it's very time consuming. I'm guessing a native implementation would be much faster. Also can it match multiple occurrences of the template?
Something like
x = [[0 0 1 1 1 1 1 0 0]
[0 0 1 1 0 0 0 0 0]
[0 0 1 1 0 0 0 0 0]
[0 0 1 1 0 0 0 0 0]]
template = [[1 1 1 1]
[1 0 0 0]
[1 0 0 0]]
cords = np.matchtemplate(x, template)
And printing the cords should ideally give a list of tuples which has the diagonal coordinates of the matching segment.
print(cords)
[[(0, 3), (6, 2)]]