【opencv基础】opencv cv::Mat::step的理解

前言

调试代码过程中发现cv::Mat step的使用,之前没注意过,故记之。

opencv cv::Mat解释

step    Number of bytes each matrix row occupies. The value should include the padding bytes at the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed and the actual step is calculated as cols*elemSize(). See Mat::elemSize.
  • step[0]是矩阵中一行元素的字节数
  • step[1]是矩阵中一个元素的字节数(elemSize)
  • step1 = step / elemSize1,elemSize1是元素的每个通道所占的字节数
    • step1(0)是矩阵一行元素的通道数(不是很贴切)
    • step1(1)是矩阵一个元素的通道数(channel())

code

    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;

results

 

 

 

参考

1. opencv_Mat_step;

2. OpenCV__cv::Mat::step;

posted on   鹅要长大  阅读(778)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
历史上的今天:
2021-08-08 【git基础】git error: failed to push some refs to remote

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示