多通道矩阵的分离与聚合
Posted suonikeyinsu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了多通道矩阵的分离与聚合相关的知识,希望对你有一定的参考价值。
1 #include<opencv2/opencv.hpp> 2 #include<iostream> 3 #include<cassert> 4 #include<vector> 5 #include<stdio.h> 6 #include <sys/time.h> 7 8 using namespace cv; 9 using namespace std; 10 11 int main(int argc, char** argv) 12 { 13 Mat srcImage=imread(argv[1], CV_LOAD_IMAGE_COLOR); 14 printf("srcImage-data address:%p\n", srcImage.data); 15 Mat m = srcImage.clone(); 16 printf("m-data address:%p\n", m.data); 17 cout << "m.depth:" << m.depth() << endl; 18 cout << "m.type:" << m.type() << "-" << CV_8UC3 << endl; 19 20 Mat m_64; 21 m.convertTo(m_64, CV_64FC3); 22 printf("m_64-data address:%p\n", m_64.data); 23 cout << "m_64.depth:" << m_64.depth() << endl; 24 cout << "m_64.type:" << m_64.type() <<"-" << CV_64FC3 << endl; 25 26 Mat m_8; 27 m_64.convertTo(m_8, CV_8UC3); 28 printf("m_8-data address:%p\n", m_8.data); 29 cout << "m_8.depth:" << m_8.depth() << endl; 30 cout << "m_8.type:" << m_8.type() <<"-" << CV_8UC3 << endl; 31 32 //cout << m_64 << endl; 33 cout << m_8 << endl; 34 35 36 //result:convertTo转换data会存储在新的地方 37 //srcImage-data address:0x7fa6ac1bb020 38 //m-data address:0x7fa6ac0fa020 39 //m.depth:0 40 //m.type:16-16 41 //m_64-data address:0x7fa69dcba020 42 //m_64.depth:6 43 //m_64.type:22-22 44 //m_8-data address:0x7fa69dbf9020 45 //m_8.depth:0 46 //m_8.type:16-16 47 48 vector<Mat> channels; 49 Mat imageBlue,imageGreen,imageRed; 50 Mat mergeImage; 51 52 split(m, channels); 53 imageBlue = channels.at(0); 54 55 for (int i = 0; i < imageBlue.rows; i++) 56 for (int j = 0; j < imageBlue.cols; j++) 57 { 58 imageBlue.at<uchar>(i, j) = i; 59 } 60 61 imageGreen = channels.at(1); 62 imageRed = channels.at(2); 63 merge(channels, m); 64 65 //result:67 //m-data address:0x7f8058621020 68 69 //cout << srcImage << endl; 70 //cout << m << endl; 71 //cout << mergeImage << endl; 72 cout << endl; 73 74 return 0; 75 }
以上是关于多通道矩阵的分离与聚合的主要内容,如果未能解决你的问题,请参考以下文章
利用OpenCV的函数split()和merge()实现通道的分离与合并
opencv学习笔记第六篇:分离颜色通道多通道图像混合和图像对比度亮度值的调整
在学习opencv的时候看到多通道矩阵这一概率,恳求大神告诉我一下啥意思
SpringCloud系列十一:SpringCloudStream(SpringCloudStream 简介创建消息生产者创建消息消费者自定义消息通道分组与持久化设置 RoutingKey)(代码片段