• 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 }
  • 相关阅读:
    CSS背景background、backgroundposition使用详解
    为何img、input等内联元素可以设置宽、高
    各种Js封装
    CSS布局奇淫技巧之各种居中
    document.compatMode属性
    jquery的each()详细介绍
    jQuery所支持的css样式
    js,jQuery获取html5的data*属性
    PHP中MVC的编程思想浅谈
    php读取xml的神器
  • 原文地址:https://www.cnblogs.com/black-mamba/p/5947976.html
Copyright © 2020-2023  润新知