I know this has been asked before but there doesn't seem to be anything for my specific use-case.
I have a numpy array obs which represents a color image and has shape (252, 288, 3).
I want to convert every pixel that is not pure black to pure white.
What I have tried is obs[obs != [0, 0, 0]] = [255, 255, 255] but it gives the following exception:
ValueError: NumPy boolean array indexing assignment cannot assign 3 input values to the 807 output values where the mask is true
The result is the same withobs[obs[:, :] != [0, 0, 0]] = [255, 255, 255]. Also, (obs[:, :] != [0, 0, 0]).shape is (252, 288, 3) and I do not understand why it isnt simply (252, 288) (a matrix of bools).
I thought about using obs[obs != 0] = 255 but that would not have the effect I want since a pixel that is pure green ([0, 255, 0]) would be processed component wise and would still be [0, 255, 0] after the filtering, instead of being actually white ([255, 255, 255]).
Why isn't what I have tried up until now working and how should I go about this?
