-1

我正在尝试将 RGB 图像转换为 ARGB 格式。在openCV中有什么办法吗?据我所知,可以将图像转换为 RGBA,但不确定 ARGB。

这就是我目前正在做的事情:

        cv::Mat argb(myImage.rows, myImage.cols, CV_8UC4);
        cv::Mat alpha(myImage.rows, myImage.cols, CV_8UC1);
        cv::Mat in[] = { myImage, alpha };
        int from_to[] = { 0,1,  1,2,  2,3,  3,0 };
        cv::mixChannels( in, 2, &argb, 1, from_to, 4 );

myImage 是 8uc3 格式,这是我的输入图像。但我需要将格式更改为 ARGB 以用于另一个应用程序。

4

1 回答 1

0

As far as i know cvtColor function doesn't provide such convertion, so you need to write it on your own - look at the source code of cvtColor function, your convertion will be quite similar to CV_BGR2RGB - you just need to switch first and last channel.

于 2013-08-14T23:21:31.663 回答