zoukankan      html  css  js  c++  java
  • Mat::operator =

    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.

     1 int main(int argc, char** argv)
     2 {
     3     Mat m = Mat(8, 8, CV_8UC1);
     4 
     5     for (int i = 0; i < m.rows; i++)
     6         for (int j = 0; j < m.cols; j++)
     7         {
     8             m.at<uchar>(i, j) = i;    
     9         }
    10 
    11     cout << "type:" << m.type() << endl;
    12     cout << "CV_8UC1:" << CV_8UC1 << endl;
    13     cout << "depth:" << m.depth() << endl;
    14     cout << "channel:" << m.channels() << endl;
    15     printf("m-data address:%p
    ", m.data);
    16 
    17     //printMat(m);
    18 
    19     //cout << "m:" << endl;
    20     //cout << m << endl;
    21 
    22     Mat imageR = Mat::zeros(8,8,CV_8UC1); 
    23     printf("imageR-data address:%p
    ", imageR.data);
    24     //cout << imageR << endl;
    25     //cout << endl;
    26     imageR = m;//会将imageR的数据指针指向m的数据地址
    27     printf("imageR-data address:%p
    ", imageR.data);
    28     //cout << imageR << endl;
    29 
    30     //result
    31     //m-data address:0x178d3e0
    32     //imageR-data address:0x178d450
    33     //imageR-data address:0x178d3e0
    34 
    35     return 0;
    36 }
  • 相关阅读:
    XSS跨站脚本攻击实例讲解,新浪微博XSS漏洞过程分析
    PHP常量PHP_SAPI与函数php_sapi_name()简介,PHP运行环境检测
    PHP导出数据到CSV文件函数/方法
    iOS8 Core Image In Swift:视频实时滤镜
    实战:mysql版本号升级
    Apache Shiro 使用手冊 链接文件夹整理
    Windows 驱动开发
    Python标准库:内置函数bytearray([source[, encoding[, errors]]])
    cocos2d-x 2.2.3 之菜单分析(1)
    JSP具体篇——out
  • 原文地址:https://www.cnblogs.com/black-mamba/p/5947976.html
Copyright © 2011-2022 走看看