当前位置 : 主页 > 编程语言 > c语言 >

Mat step详解

来源:互联网 收集:自由互联 发布时间:2023-09-03
简述 cv::Mat step详解 内容 step的几个类别区分: step:矩阵第一行元素的字节数 step[0]:矩阵第一行元素的字节数 step[1]:矩阵中一个元素的字节数 step1(0):矩阵中一行有几个通道数 step1(1):一个元

简述

cv::Mat step详解

内容

step的几个类别区分:

  • step:矩阵第一行元素的字节数
  • step[0]:矩阵第一行元素的字节数
  • step[1]:矩阵中一个元素的字节数
  • step1(0):矩阵中一行有几个通道数
  • step1(1):一个元素有几个通道数(channel())
Mat img(3, 4, CV_16UC4, Scalar_<uchar>(1, 2, 3, 4));

    cout << img << endl;

    cout << "step:" << img.step << endl;

    cout << "step[0]:" << img.step[0] << endl;

    cout << "step[1]:" << img.step[1] << endl;

    cout << "step1(0):" << img.step1(0) << endl;

    cout << "step1(1):" << img.step1(1) << endl;

Mat step详解_Mat

解释:

创建了一个3∗4的16位4通道的矩阵,每一个元素赋值为1,2,3,4.可以看到生成了16∗3的矩阵.因为创建的是16位的,所以每一个通道是2个字节数。所以一行共有4∗4∗2=32个字节数,故step和step[0]都为32

因为一个元素有4个通道,每个通道2个字节,所以1个元素的字节数,step[1]为4∗2=8,一行是4个元素,每个元素是4个通道,所以一行的通道数,step1(0)为4∗4=16,step1(1)为4

【感谢龙石数据为本站数据中台建设方案 http://www.longshidata.com/pages/government.html,感恩 】
网友评论