I have a condition where I want to detect white line incase of black background and black line incase of white background. I used bitwise_not operation something like this: It is working perfectly until and unless i give a condition like this: I get an error ValueError: The truth value of an array with more than one element is ambiguous.