概述
mixChannels()是图像通道处理有关的一个函数,能够实现复杂通道的组合。
函数
void cv::mixChannels
(
InputArrayOfArrays src,
OutputArrayOfArrays dst,
std::vector<int> fromTo
)
- src 是输入矩阵。
- dst 是输出矩阵。注意,不能是空构造,必须是赋值构造,大小和深度与输入矩阵相同。
- fomTo 是复制列表,包含索引信息,比如:
vector<int> from = {0,2,1,1,2,0};
测试代码
#include "widget.h"
#include "ui_widget.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <vector>
using namespace cv;
using namespace std;
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
//新建一个图像
cv::Mat mat1(200,200,CV_8UC3,Scalar(100,150,200));
imshow("mat1",mat1);
//运算
vector<int> from = {0,2,1,1,2,0};
cv::Mat mat2(200,200,CV_8UC3);
mixChannels(mat1,mat2,from);
imshow("mat2",mat2);
}
Widget::~Widget()
{
delete ui;
}