Reputation: 705
The code below basically gets the color green from an image:
green_mask = np.all(label==[0,255,0], axis=-1)
But how do I change that line so I can still get mask even if, say the first channel contains pixels greater than 0 BUT still less than 255?
So, I want something like this:
green_mask = np.all((label[:,:,0]<255 and label[:,:,1]==255 and label[:,:,0]<255), axis=-1)
But that gives me an error: "The truth value of an array with more than one element is ambiguous. Use a.any() or a.all().
Upvotes: 1
Views: 476
Reputation: 705
What I ended up doing was:
green_mask = (label[:,:,0]<255) & (label[:,:,1]==255) & (label[:,:,0]<255)
Upvotes: 1