- #include<opencv2/opencv.hpp>
- #include<iostream>
- #include<cassert>
- #include<vector>
- using namespace cv;
- using namespace std;
- int main()
- {
- Mat srcImage=imread("e:/huangshan.jpg");
- Mat imageBlue,imageGreen,imageRed;
- Mat mergeImage;
- //定義一個Mat向量容器儲存拆分後的資料
- vector<Mat> channels;
- //判斷檔案加載是否正确
- assert(srcImage.data!=NULL);
- namedWindow("image",CV_WINDOW_AUTOSIZE);
- namedWindow("mergeImage",CV_WINDOW_AUTOSIZE);
- //通道的拆分
- split(srcImage,channels);
- //提取藍色通道的資料
- imageBlue = channels.at(0);
- //提取綠色通道的資料
- imageGreen = channels.at(1);
- //提取紅色通道的資料
- imageRed = channels.at(2);
- imshow("image",imageBlue);
- //對拆分的通道資料合并
- merge(channels,mergeImage);
- imshow("mergeImage",mergeImage);
- waitKey();
- system("pause");
- return 0;
- }
- #include<opencv2/opencv.hpp>
- #include<iostream>
- #include<cassert>
- #include<vector>
- using namespace cv;
- using namespace std;
- int main()
- {
- Mat srcImage=imread("e:/jiansheng.jpg");
- Mat logoImage = imread("e:/timu.jpg",0);
- Mat imageBlue,imageGreen,imageRed;
- Mat mergeImage;
- //定義一個Mat向量容器儲存拆分後的資料
- vector<Mat> channels;
- //判斷檔案加載是否正确
- assert(srcImage.data!=NULL && logoImage.data!=NULL);
- //namedWindow("image",CV_WINDOW_AUTOSIZE);
- namedWindow("mergeImage",CV_WINDOW_AUTOSIZE);
- //通道的拆分
- split(srcImage,channels);
- //提取藍色通道的資料
- imageBlue = channels.at(1);
- addWeighted(imageBlue(Rect(0,0,logoImage.cols,logoImage.rows)),0.5,logoImage,0.5,0.,imageBlue(Rect(0,0,logoImage.cols,logoImage.rows)));
- //對拆分的通道資料合并
- merge(channels,mergeImage);
- imshow("mergeImage",mergeImage);
- waitKey();
- system("pause");
- return 0;
- }
- 原文位址:http://blog.csdn.net/omuyejingfeng1/article/details/25685141
- sift,surf比對代碼http://blog.csdn.net/omuyejingfeng1/article/details/24372815