I am using OpenCV with Python. I have an image, and what I want to do is set all pixels of BGR value [0, 0, 255] to [0, 255, 255].
I asked a previous question on how to posterize an image, and from the answer I learned about indexing with an Array of indices, for ex: image[image > 128] = 255
I understand how this works, since image > 128 will return an array of multi-dimensional array of indices that satisfy the condition, and then I apply this array to the image and set those to 255. However, I'm getting confused with how to extend this to doing a value for an array.
I tried doing the following:
red = np.array([0, 0, 255])
redIndex = np.where(np.equal(image, red))
image[redIndex] = np.array([0, 255, 255])
but it doesn't work, with the error:
ValueError: array is not broadcastable to correct shape
Is there an efficient way to handle this?