if image[i][j][1]>=lower_red and image[i][j][1]<=upper_red:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
if image[i][j][1]>=lower_red and image[i][j][1]<=upper_red:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
This is the right answer:
if ((image[i][j][1] >= lower_red).all()) and ((image[i][j][1] <= upper_red).any()):
...
This does work when called in the correct way...
if-else
.This works:
# example image 3d array
image = [
[[5,6,5],[1,2,3]],
[[1,2,3],[5,6,5]]
]
# some values to check
lower_red = 10
upper_red = 10
# example of checking
i, j = 0,1
if image[i][j][1]>=lower_red and image[i][j][1]<=upper_red:
print('done')
else:
print(image[i][j][1])
result:
2