1 | initial version |
You can easily solve this by reconstruct your image with alpha channel using the following step
And here is the C++ code for the above steps.
Mat src=imread("0.jpg",1);
Mat dst;//(src.rows,src.cols,CV_8UC4);
Mat tmp,alpha;
cvtColor(src,tmp,CV_BGR2GRAY);
threshold(tmp,alpha,100,255,THRESH_BINARY);
Mat rgb[3];
split(src,rgb);
Mat rgba[4]={rgb[0],rgb[1],rgb[2],alpha};
merge(rgba,4,dst);
imwrite("dst.png",dst);
Source Image without alpha.
Result with alpha
2 | No.2 Revision |
You can easily solve this by reconstruct your image with alpha channel using the following step
And here is the C++ code for the above steps.steps, re-write in Java as your need.
Mat src=imread("0.jpg",1);
Mat dst;//(src.rows,src.cols,CV_8UC4);
Mat tmp,alpha;
cvtColor(src,tmp,CV_BGR2GRAY);
threshold(tmp,alpha,100,255,THRESH_BINARY);
Mat rgb[3];
split(src,rgb);
Mat rgba[4]={rgb[0],rgb[1],rgb[2],alpha};
merge(rgba,4,dst);
imwrite("dst.png",dst);
Source Image without alpha.
Result with alpha