阅读背景:

OpenCV之分离和合并颜色通道

来源:互联网 
先上代码 #include <iostream> #include <opencv2/core.hpp> #include <opencv2/highgui.hpp> #include <opencv2/imgproc.hpp> #include <opencv2/videoio.hpp> #include <opencv2/video.hpp> using namespace cv; using namespace std; int main(int argc, char** argv) { Mat srcImage = imread("700levi.jpg"); Mat imageBlueChannel, imageGreenChannel, imageRedChannel, mergeImage; //定义Mat向量容器保存拆分后的容器 vector<Mat> channels; //通道的拆分 split(srcImage, channels); //提取三色的通道的数据 imageBlueChannel = channels.at(0); imshow("imageBlueChannel", imageBlueChannel); imageGreenChannel = channels.at(1); imshow("imageGreenChannel", imageGreenChannel); imageRedChannel = channels.at(2); imshow("imageRedChannel", imageRedChannel); //对拆分的通道数据合并 merge(channels, mergeImage); imshow("mergeImage", mergeImage); waitKey(0); return 0; } 效果 先上代码 #include <iostream> #include <opencv2/core.h



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: