Michael
Michael

Reputation: 13616

How can I make black color to transparent color?

I have image:

Image<Bgr,Byte> someImage = new Image<Bgr,Byte>(someImage.jpg);   

enter image description here

How can I make all black pixels(black color) transparent?

Thank you in advance.

Upvotes: 0

Views: 3529

Answers (2)

Haris
Haris

Reputation: 14053

You can see an example about how to use alpha to make background transparent on this thread.

Upvotes: 1

scap3y
scap3y

Reputation: 1198

You will need to find a way to define your image in such a way that it uses the alpha channel. If you want details, this is the link for RGBA color space.

Basically, you need to initialize a CV_8UC4 image. Keep in mind to initialize all pixels to zero before you start (basically, the entire matrix will be black before you start putting values in)..

Upvotes: 1

Related Questions