I need to find specific pixels (BGR format) coordinates in a game while it's live ,
(i saved a screenshot just for testing , the program it self takes screenshots continuously).
Here's a working for loop example of what i need
s = np.array(Image.open("image.png"))
cr = []
for y in range(338):
for x in range(326):
C = s[y, x]
if C[1] < 25 and 20 <= C[0] < 25 and 130 < C[2] < 215:
cr.append((y, x))
but the for loop takes 1.03 sec , which is very slow for my task , so i tried
cr = s[(20 < s[:,][:,0]) & (s[:,][:,0] < 25) & (s[:,][:,1] < 25) & (130 < s[:,][:,2]) & (s[:,][:,2] < 215)]
but it returns me the error IndexError: boolean index did not match indexed array along dimension 1; dimension is 415 but corresponding boolean dimension is 3
so how do i need to make it , with the fastest way?
EDIT:
example image:
