Provides matrix assignment operators.

C++: Mat& Mat::operator=(const Mat& m)
C++: Mat& Mat::operator=(const MatExpr& expr)
C++: Mat& Mat::operator=(const Scalar& s)
Parameters:
  • m – Assigned, right-hand-side matrix. Matrix assignment is an O(1) operation. This means that no data is copied but the data is shared and the reference counter, if any, is incremented. Before assigning new data, the old data is de-referenced via Mat::release() .
  • expr – Assigned matrix expression object. As opposite to the first form of the assignment operation, the second form can reuse already allocated matrix if it has the right size and type to fit the matrix expression result. It is automatically handled by the real function that the matrix expressions is expanded to. For example, C=A+B is expanded to add(A, B, C), and add() takes care of automatic C reallocation.
  • s – Scalar assigned to each matrix element. The matrix size or type is not changed.

These are available assignment operators. Since they all are very different, make sure to read the operator parameters description.

 int main(int argc, char** argv)
{
Mat m = Mat(, , CV_8UC1); for (int i = ; i < m.rows; i++)
for (int j = ; j < m.cols; j++)
{
m.at<uchar>(i, j) = i;
} cout << "type:" << m.type() << endl;
cout << "CV_8UC1:" << CV_8UC1 << endl;
cout << "depth:" << m.depth() << endl;
cout << "channel:" << m.channels() << endl;
printf("m-data address:%p\n", m.data); //printMat(m); //cout << "m:" << endl;
//cout << m << endl; Mat imageR = Mat::zeros(,,CV_8UC1);
printf("imageR-data address:%p\n", imageR.data);
//cout << imageR << endl;
//cout << endl;
imageR = m;//会将imageR的数据指针指向m的数据地址
printf("imageR-data address:%p\n", imageR.data);
//cout << imageR << endl; //result
//m-data address:0x178d3e0
//imageR-data address:0x178d450
//imageR-data address:0x178d3e0 return ;
}

Mat::operator =的更多相关文章

  1. OpenCV MAT基本图像容器

    参考博客: OpenCv中cv::Mat和IplImage,CvMat之间的转换 Mat - 基本图像容器 Mat类型较CvMat和IplImage有更强的矩阵运算能力,支持常见的矩阵运算(参照Mat ...

  2. CvMat and cv::Mat

    CvMat: typedef struct CvMat { int type; int step; /* for internal use only */ int* refcount; int hdr ...

  3. OpenCV中Mat的详解

    每次碰到Mat都得反复查具体的用法,网上的基础讲解不多,难得看到一篇,赶快转来收藏~ 原文地址:http://www.opencvchina.com/thread-1039-1-1.html 目标 我 ...

  4. Mat的详解

    [转]OpenCV中Mat的详解 每次碰到Mat都得反复查具体的用法,网上的基础讲解不多,难得看到一篇,赶快转来收藏~ 原文地址:http://www.opencvchina.com/thread-1 ...

  5. ncnn 源码学习-Mat.h Mat.c

    纯小白记录下腾讯的ncnn框架源码的学习.纯粹写给自己看的,不保证正确性. Mat 类似于 caffe中的blob,是一个张量的存储结构体. 一.数据成员: 1.void * data 多维数据按一位 ...

  6. Mat类具体解释(二)

    Mat::~Mat Mat的析构函数. C++: Mat::~Mat() 析构函数调用Mat::release(). Mat::operator = 提供矩阵赋值操作. C++: Mat& M ...

  7. OPENCV mat类

    OpenCV参考手册之Mat类详解 目标 我们有多种方法可以获得从现实世界的数字图像:数码相机.扫描仪.计算机体层摄影或磁共振成像就是其中的几种.在每种情况下我们(人类)看到了什么是图像.但是,转换图 ...

  8. mat 和IPIImage之间的转换

    opencv2.3.1 Mat::operator IplImageCreates the IplImage header for the matrix.C++: Mat::operator IplI ...

  9. 【opencv 源码剖析】 四、 Mat的赋值构造函数 和 拷贝构造函数

    1.赋值构造函数 右值引用 inline Mat& Mat::operator = (Mat&& m) { if (this == &m) return *this; ...

随机推荐

  1. UOJ Rounds

    UOJ Test Round #1 T1:数字比大小的本质是按(长度,字典序)比大小. T2:首先发现单调性,二分答案,用堆模拟,$O(n\log^2 n)$. 第二个log已经没有什么可优化的了,但 ...

  2. 【前缀和】【分类讨论】hdu5163 Taking Bus

    #include<cstdio> using namespace std; int T,n,m,x,y; long long sum[100001],ans,d[100001]; int ...

  3. python基础-协程函数、递归、模块、包等内容

    1. 协程函数 1.1 yield基本用法 yield作用 1.把函数的执行结果封装好,即封装__iter__和__next__,即得到一个迭代器 2.与return功能类似,都可以返回值,但不同的是 ...

  4. 1.1(java学习笔记) 面向过程与面向对象

    面向过程思考时,我们会先思考具体的步骤,第一步走什么,第二步做什么. 比如电脑新建文件夹,第一步:打开电脑 第二步:按下鼠标右键. 第三步:找到新建选项 第四步:点击新建选项下的文件夹 c语言是典型的 ...

  5. XAMPP 下apache部署网站,多个虚拟机(空间)配置

    1.首先修改C盘WINDOWS/system32/drivers/etc目录下的 hosts 文件,用记事本打开,加入: 127.0.0.1 www.a.com 127.0.0.1 www.b.com ...

  6. 更新升级10.11 cocoapods安装出问题最简单的解决方法

    这是因为10.11把cocoapods直接干掉了 sudo gem install -n /usr/local/bin cocoapods 再加一句,完美解决 sudo xcode-select -- ...

  7. 【InteillJ IDEA】Git的安装+同步项目到GitHub上

    需要的工具: 1.InteillJ IDEA 2.Git 3.GitHub帐号 步骤: 1.下载Git 下载地址:https://git-scm.com/downloads 安装完成后 勾选Launc ...

  8. Android2017进阶知识点、面试题及答案(精选版)

    前言 没啥好说的,撸起袖子就是干吧! 1 2 JAVA 相关 1.静态内部类.内部类.匿名内部类,为什么内部类会持有外部类的引用?持有的引用是this?还是其它? 静态内部类:使用static修饰的内 ...

  9. easyui textbox获取焦点事件

    $('#textboxid').textbox().next('span').find('input').focus(); $('#id').textbox('textbox').focus();

  10. MyEclipse中快捷键

    ------------------------------------- MyEclipse 快捷键1(CTRL) ------------------------------------- Ctr ...