Im currently trying to search pictures for the, what one could call, "most red" pixels and cannot use a fixed rgb value. so i tried to create a system of loops counting the g value up, then the b value and at last counting the r value down, to search for pixels with the highest r value, while maintaining low g and b values. the coordinates of the pixel/pixels should be saved to a tuple of arrays created with numpy. right now it doesnt find anything, even if i feed the program picture with the rgb value 255,0,0. do you have any opinions what could be wrong or how to search for the "most red" pixel coordinates of an image?(below "data[]" is an array with the rgb values of all pixels of the image which i got with PIL and numpy)
r=0 # red plane1
g=1 # green plane
b=2 # blue plane
r_search = 255
g_search = 0
b_search = 0
z = True
h = True
q = True
while q == True:
while h == True:
while z == True:
coordinatestuple = np.where((data[:,:,r] == r_search) & (data[:,:,g] == g_search) & (data[:,:,b] == b_search))
g_search = g_search + 1
if not coordinatestuple:
z = False
elif g_search == 256:
z = False
coordinatestuple = np.where((data[:,:,r] == r_search) & (data[:,:,g] == g_search) & (data[:,:,b] == b_search))
b_search = b_search + 1
if not coordinatestuple:
h = False
elif b_search == 256:
h = False
coordinatestuple = np.where((data[:,:,r] == r_search) & (data[:,:,g] == g_search) & (data[:,:,b] == b_search))
r_search = r_search - 1
if not coordinatestuple:
q = False
elif r_search == 0:
q = False
print(coordinatestuple)