I am trying to perform the following operation on an array in python:
if true then a else b
I am trying to perform it on one channel of an image. Basically I want to check if a value is greater than 255, if so, return 255 else return the value that is being checked.
here is what I'm trying:
imfinal[:,:,1] = imfinal[:,:,1] if imfinal[:,:,1] <= 255 else 255
I get the following error: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Is there a better way to perform this operation?