Reputation: 1
I'm trying to check if one of the pixel values exist in the image and tried it a lot with zero results:
if value or value2 or value3 or value4 == (248, 64, 64)or(250, 64, 64)or(83, 159, 254)or(255,255,255):
print(value),print(value2),print(value3),print(value4)
It gives me this output:
(0, 33, 66)
(167, 126, 101)
(152, 178, 82)
(239, 174, 67)
Upvotes: 0
Views: 177
Reputation: 12140
I'd suggest storing values and colors in lists and check with the in
operator.
values = [
value,
value2,
value3,
value4
]
colors = [
(248, 64, 64),
(250, 64, 64),
(83, 159, 254),
(255, 255, 255)
]
if any(v in colors for v in values):
for v in values:
print(v)
But if you want to check the whole image, depending on the way images are represented, you should be able to check if color exists in the image without iterating manually through each pixel.
For example, if it is 2D NumPy array of tuples:
if any(np.any(image == c) for c in colors):
...
could be the solution.
Upvotes: 1