1 | initial version |
Merge source channel to final image including alpha.
//Laod source and create alpha
Mat src=imread("red.png",1);
Mat alpha;
inRange(src, Scalar(0,0,250), Scalar(0,0,255),alpha);
bitwise_not(alpha,alpha);
//split source
Mat bgr[3];
split(src,bgr);
//Merge to final image including alpha
Mat tmp[4] = { bgr[0],bgr[1],bgr[2],alpha};
Mat dst;
merge(tmp,4,dst);
imwrite("dst.png",dst);