I solved a problem with a loop, but it is both slow and unpythonic. I'm looking for a mask solution. If I were interested in pixels with values for a specific channel, that would be simple:
img[img[:,:,0]==64] = [0,0,0]
to turn them all black. I want to change a specific color, e.g. [192,0,128]
, so I need all three channels, something like img[ img[:,:,0]==192 and img[:,:,1]==0 and img[:,:,2]==128]=[0,0,0]
but of course this is wrong. I also tried np.all(img==[192,0,128])
but it didn't work either.