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()
CodePudding user response:
This is the right annswer:
if ((image[i][j][1]>=lower_red).all()) and ((image[i][j][1]<=upper_red).any()):
CodePudding user response:
This does work when called in the correct way...
- I make a suitable image array (list of lists) that has 3 dimensions.
- I set values for upper an lower for testing.
- I then add the logical check with an
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