I have a 3D NumPy array which is essentially image data in RGBA format like so:
[
[
[233 228 230 120]
[233 228 230 0]
[232 227 229 212]
...
]
...
]
In the example above the last (4th) column represents alpha channel. As I can't have semi-transparent pixels (value other than 0 or 255), I need to threshold that column. Any value below 255 should become 0.
What I have is the line below.
image[...,3][image[...,3] < 255] = 0
It does work but I wanted to ask if there is something shorter and more elegant that would do the job. Thanks.