关于Mat的拷贝、赋值
来源:互联网 发布:阿德昆托博生涯数据 编辑:程序博客网 时间:2024/05/16 07:44
关于Mat的浅复制(占用相同内存,处理其中一个,会影响另外一个)&
深复制(生成副本,占用不同内存,相互之间无影响)
Mat A, C; // creates just the header parts
A = imread(argv[1], CV_LOAD_IMAGE_COLOR); // here we’ll know the method used (allocate matrix)
Mat B(A); // Use the copy constructor 拷贝构造
C = A; // Assignment operator 赋值运算符
opencv手册中描述如下:(浅复制)
(All the above objects, in the end, point to the same single data matrix. Their headers are different, however, and
making a modification using any of them will affect all the other ones as well. In practice the different objects just
provide different access method to the same underlying data.)
也可以只取原图像的一部分区域(ROI),创建the headers ,如下:(浅复制)
Mat D (A, Rect(10, 10, 100, 100) ); // using a rectangle
Mat E = A(Range:all(), Range(1,3)); // using row and column boundaries
如果想复制整个矩阵,需要(深复制):opencv提供了两个函数the clone()and copyTo()
Mat F = A.clone();
Mat G;
A.copyTo(G);
现在修改F或者G不会影响A。
opencv手册总结如下:
• Output image allocation for OpenCV functions is automatic (unless specified otherwise).
• You do not need to think about memory management with OpenCVs C++ interface.(IplImage类型要手动释放内存,cvReleaseImage(IplImage **))
• The assignment operator and the copy constructor only copies the header.
• The underlying matrix of an image may be copied using theclone()and copyTo()functions.
- 关于Mat的拷贝、赋值
- 关于python的拷贝,赋值理解
- 关于Mat矩阵在浅拷贝下的关于矩阵头的拷贝问题
- 关于类的拷贝构造函数、赋值构造函数探究
- 关于拷贝构造函数,类的赋值与复制
- 关于C++中的拷贝构造和赋值重载的理解
- cv::Mat 的数据拷贝
- 关于复制构造函数(拷贝构造函数)和赋值操作符(拷贝赋值函数)应该知道的
- 关于赋值构造函数和拷贝构造函数的位拷贝
- 深入浅出类的赋值、拷贝
- 类的拷贝、赋值、销毁
- 拷贝和赋值的区别
- 关于拷贝构造函数,赋值运算符
- 关于C++中的赋值与拷贝
- cv::Mat 的子矩阵赋值
- cv::Mat 的子矩阵赋值
- opencv之Mat 类赋值的理解
- 对于一般的Mat如何进行赋值
- J – 搞笑版费马大定理
- 最少乘法次数
- DataTable指定行追加数据
- 【简单dp】Boxes of Chocolates Again
- Codeforces Round #287 (Div. 2)A,B,C,D,E
- 关于Mat的拷贝、赋值
- 南阳理工题目218Dinner
- mac下安装nmap
- Sublime text 3设置用用空格替换tab键
- 仿乐安全首页动态效果
- 微信公众平台获取关注者列表接口详解
- findpanel的相关代码
- 基础练习 数列特征
- hihocoder#1043之完全背包