本文介绍了将OpenCV 2.4 Jpeg转换为具有Alpha通道的PNG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个JPEG和一个Mask.我想用三个JPEG通道创建一个PNG,而alpha通道应该是Mask.如何使用OpenCV做到这一点?
I have a JPEG and a Mask. I want to create a PNG with the three JPEG channels and the alpha channel should be the Mask. How can I achieve this with OpenCV?
致谢
推荐答案
感谢您的回答,我找到了第二个解决方案:
Thanks for your answer, I found a second solution:
cv::Mat transparent( height, width, CV_8UC4);
cv::Mat srcImg[] = {JPEG_img, alpha_Mask};
int from_to[] = { 0,0, 1,1, 2,2, 3,3 };
cv::mixChannels( srcImg, 2, &transparent, 1, from_to, 4 );
这很完美,不确定哪种解决方案更好.
This works perfect, not sure which solution is better.
这篇关于将OpenCV 2.4 Jpeg转换为具有Alpha通道的PNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!