с учетом того, что img открыто в 'img'
Вы можете использовать immg [i, j], чтобы вернуть значения синего красного зеленого цвета, например
>>img[12,12]
[143,144,255] // this is what is returned [blue green red]
так что вы можете использовать что-то вроде
rows = img.shape[0]
cols = img.shape[1]
for (i in range(0,rows)):
for (j in range(0,cols)):
bgr=img[i,j]
#now use if condition and match brg values with color you wnana detect then append the pair i,j in the a list if the condition matcches