opencv2学习(五)——reshape函数的使用
来源:互联网 发布:岗位优化人员优化方案 编辑:程序博客网 时间:2024/05/21 19:30
reshape不需要内存拷贝或者重新分配就能改变矩阵的维度
Mat reshape(int cn, int rows=0) const;
cn:表示通道数channels,如果设为0,则表示保持通道数不变,否则则变为设置的通道数
rows;表示矩阵函数,如果设为0,则表示所有函数不变,否则则变为设置的函数
Mat reshape(int cn, int newndims, const int* newsz) const;提供方便的重载函数,和上面的函数只有输入参数不同。
程序代码:
int main(void){Mat Image = imread("F:\\1\\yellow_lane\\0.png", 1);cout<<"channel:"<<Image.channels()<<endl;cout<<"rows:"<<Image.rows<<endl;cout<<"cols:"<<Image.cols<<endl;cout<<endl;Mat dst = Image.reshape(1, Image.cols*Image.channels()*Image.rows);cout<<"channel:"<<dst.channels()<<endl;cout<<"rows:"<<dst.rows<<endl;cout<<"cols:"<<dst.cols<<endl;return 0;}
需要注意的是,如果程序这样写:
Image.reshape(1, Image.cols*Image.channels()*Image.rows);
Image的行列变换是不会显现出有改变的
1 0
- opencv2学习(五)——reshape函数的使用
- reshape函数—— Matlab和opencv的reshape函数 不同点
- MATLAB——reshape 函数
- Tensorflow中reshape()函数的使用
- opencv3学习:reshape函数
- reshape函数使用
- numpy reshape函数使用
- OpenCV学习笔记(五):OpenCV2.4.13+VS2013的配置(非本机使用)
- TensorFlow学习笔记(五):tf.reshape用法
- Matlab 的reshape函数
- Matlab 的reshape函数
- matlab的reshape函数
- MATLAB的reshape函数
- Matlab 的reshape函数
- Matlab 的reshape函数
- MATLAB的reshape函数
- Leetcode学习(5)—— Reshape the Matrix
- matlab的reshape使用
- ios10 部分app无法连接到网络
- MySQL数据库:SQL语句
- 使用Maven
- getDimension,getDimensionPixelOffset和getDimensionPixelSize
- Canvas基础图形的绘制
- opencv2学习(五)——reshape函数的使用
- 理解函数参数
- centos
- ubuntu 安装eclipse
- 设计模式-----工厂模式
- 排序算法(二) 冒泡排序
- 一般现在常见的网站攻击方式 及预防
- 使用Java原生API编写发送HTTP_POST请求的工具类
- Android greenDAO3x数据库框架使用小结