Read RGBA Image OpenCV

冷暖自知 提交于 2019-12-11 08:11:25

问题


I am stuck with reading, processing and displaying sample.png image which contains RGB and an additional Alpha layer. I have manually removed background in this image and only foreground appears in windows image slideshow propgram. I couldnt find any useful information anywhr... when i read it from opencv usng functions imread or cvloadimage it creates a white background by itself... i have read documentation of highgui which states that these functions only deal wth RGB not RGBA...any help or idea will be helpful...

Thanks Saleh...


回答1:


AFAIK only current solution is to load alpha channel as separate image and then join it together. You can use cvtColor() to add alpha channel to Mat with image and e.g. mixChannels() to mix it together with loaded aplha image.




回答2:


You can use cv::imread() with IMREAD_UNCHANGED option, to read the data to a cv::Mat structure. If you still need an IplImage to work with, it is possible to convert from cv::Mat to IplImage without losing the alpha channel.



来源:https://stackoverflow.com/questions/8667929/read-rgba-image-opencv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!