opencv中step、step1、size、elemSize以及elemSize1区别

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/love_image_xie/article/details/87280031
int main()
{
	int matSize[] = {3,4,5};
	//mat1有3维,3个面,4行5列组成一个面
	Mat mat1(3,matSize,CV_16UC3,Scalar::all(0));
	//step[i]表示每一维元素的大小,单位字节
	cout << "step[0]: " << mat1.step[0] << endl;//表示面的大小,每个面4行,所以是120
	cout << "step[1]: " << mat1.step[1] << endl;//表示线的大小,每行5个元素,每个元素大小6,因此为30
	cout << "step[2]: " << mat1.step[2] << endl;//表示点的大小,16UC3表明点的大小是6
	//size[i]表示每维元素的个数
	cout << "size[0]: " << mat1.size[0] << endl;//3
	cout << "size[1]: " << mat1.size[1] << endl;//4
	cout << "size[2]: " << mat1.size[2] << endl;//5
	//step1(i)表示每维元素的通道数
	cout << "step1[0]: " << mat1.step1(0) << endl;//15*4=60
	cout << "step1[1]: " << mat1.step1(1) << endl;//5*3=15
	cout << "step1[2]: " << mat1.step1(2) << endl;//16UC3表示通道数是3
	cout << "elemSize: " << mat1.elemSize() << endl;//每个元素的大小,6
	cout << "elemSize1: " << mat1.elemSize1() << endl;//每个通道的大小,2
	return 0;
}
step[0]: 120
step[1]: 30
step[2]: 6
size[0]: 3
size[1]: 4
size[2]: 5
step1[0]: 60
step1[1]: 15
step1[2]: 3
elemSize: 6
elemSize1: 2

猜你喜欢

转载自blog.csdn.net/love_image_xie/article/details/87280031