图像的通道复制

#include <opencv2\opencv.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>

using namespace cv;
using namespace std;

int main()
{
/对通道的简单复制/
Mat rgba(100,100,CV_8UC4,Scalar(0,255,0,255));
Mat bgr(rgba.rows,rgba.cols,CV_8UC3);
Mat alpha(rgba.rows,rgba.cols,CV_8UC1);

Mat out[]={bgr,alpha};//对图像数组的定义
int from_to[]={0,2,1,1,2,0,3,3};

mixChannels(&rgba,1,out,2,from_to,4);

imshow(“四通道的图像”,rgba);
imshow(“三通道的图像”,bgr);
imshow(“单通道的图像”,alpha);
waitKey(0);
return 0;
}

猜你喜欢

转载自blog.csdn.net/nbxuwentao/article/details/86669846