opencv中int step = (int)img.step1()怎么理解?

opencv中int step = (int)img.step1()怎么理解? .step1()这个函数的作用是什么

一行像素的有效宽度
规整化的step,值为step / elemSize1。 定义如下:
inline size_t Mat::step1(int i) const { return step.p[i]/elemSize1(); }

仍以上例代码中定义的img为例,来看下step,step1具体的值:
img(3*4)的type是CV_16UC4,step[0]是其一行所占的数据字节数4 *4 * 16 / 8 = 32.
step[1] 是一个元素所占的字节数,img的一个元素具有4个通道,故:4 * 16 / 8 = 2
step1 = step / elemSize1,elemSize1是元素的每个通道所占的字节数。
温馨提示:答案为网友推荐,仅供参考
相似回答