How particular pixel to transparent in opencv python?


I have image messi.jpeg .I want to replace pixel with color (0,111,111) to transparent in messi.jpeg. now. my code is give below.

 img[np.where((img == [0,111,111]).all(axis = 2))] = [255,255,255]

I want transparent pixel. now it converted to white


For those arriving from Google the above answer may have been true at the time it was written but as the docs describe it is no longer accurate. Passing a negative value to imread returns an array with an alpha channel.

In python this does the job:

By : phro

This video can help you solving your question :)
By: admin