On a previous question I asked how to change colors on an image uploaded on a numpy.array using opencv (BGR format). The goal was to convert any red channel value < 255 to 255.
How to optimize changing the value of 3d numpy.array if meet a condition
The best answer was:
img[img[:, :, 2] < 255] = 255
The point is that I am not understanding what is going on (This is a different question since the previous one was perfectly answered). I understand this part:
img[:, :, 2] < 255
Is slicing y, x pixels on the red channel and being compared to 255 value.
However, I do not understand why this is embedded in another array:
img[...] = 255
This has to be read something like: if (img[:, :, 2] < 255) then make this pixel-red channel=255 but I don't know how to read the code line to make it sound like that.
Can anyone explain me this code line very clear so I can modify for other purposes? How should I read it while writing it?