Creating transparent image in OpenCV

c++, image-processing, opencv

Solution

It appears that JPEG doesn't support transparency. PNG does, though, so you will want to change your output file format.

Also, an alpha value of 255 indicates full visibility. Change your alpha value to zero to make the image fully transparent:

outputImage=cv::Scalar(255,255,255,0);

Problem

I am trying to create a transparent image in OpenCV and wave it as jpg without any success. My code is something such as this: ``` string outputImageName="myimage.jpg"; Mat outputImage(outputRows,outputCols,CV_8UC4); outputImage=cv::Scalar(255,255,255,255); imwrite(outputImageName,outputImage); ``` But the image is not transparent and its colour is white. How can I do this? If OpenCV can not do this, is there any free library that I use for this?

Original source