/** @brief Returns the matrix element size in bytes.
The method returns the matrix element size in bytes. For example, if the matrix type is CV_16SC3 ,the method returns 3*sizeof(short) or 6.*/
size_t elemSize() const;
/** @brief Returns the size of each matrix element channel in bytes.
The method returns the matrix element channel size in bytes, that is, it ignores the number of channels. For example, if the matrix type is CV_16SC3 , the method returns sizeof(short) or 2. */
size_t elemSize1() const;
elemSize是一个像素的字节数,elemSize1是一个像素点的一个通道(也就是一个值)的字节数
step Number of bytes each matrix row occupies. The value should include the padding bytes at the end of each row, if any.
step[0]为一行的字节数(因为可能有字节对齐所以并不一定等于cols*elemSize()),step[1]为一个像素点的字节数
/** @brief Returns a normalized step.
The method returns a matrix step divided by Mat::elemSize1() . It can be useful to quickly access anarbitrary matrix element.*/
size_t step1(int i=0) const;
step1(0)为一行的值个数,step1(1)为一个像素点的值个数,也就是通道数,从注释中可以看出step1(i)=step[i]/elemSize1(),也就是计数单位从step的字节变成step1值
设置一个行列为100,值类型为short(2字节长),三通道,每行1000字节的矩阵
每个像素的字节数为3*2=6
每个通道的字节数为2
每行最多可容纳1000/6=166个像素
每行1000字节(实际有400字节的浪费)
每个像素6字节
每行可容纳step[0]/elemSize1()=500个值
每个像素可容纳step[1]/elemSize1()=3个值