赞
踩
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
首先说一下对矩阵维度和通道的理解:
维:体现为坐标。
通道:
对于这样一个数组矩阵:
float data[18] =
{
30, 60, 40, 60, 50, 40,
67, 88, 55, 33, 22, 97,
59, 69, 32, 46, 25, 45
};
单通道显示的话,就是这样:
所以,单通道:可以理解为:一个元素中含有1个数字。
双通道就是把数组中每两个数(如30和60)结合在一起,如:
双通道可以
所以,双通道:可以理解为:一个元素中含有2个数字。
以此类推:三通道可以;理解为一个元素中有3分数字。
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
打印双通道矩阵实例:
#include "highgui.h"
#include "cv.h"
int main()
{
float data[18] =
{
30, 60, 40, 60, 50, 40,
67, 88, 55, 33, 22, 97,
59, 69, 32, 46, 25, 45
};
CvMat mat;
cvInitMatHeader(&mat, 3, 3, CV_32FC2, data);
for (int y = 0; y < mat.rows; y++)
{
for (int x = 0; x < mat.cols; x++)
{
//CvScalar value = cvGetRealND(&mat, y, x,z);三维
CvScalar value = cvGet2D(&mat, y, x);
printf("(%f %f)", value.val[0], value.val[1]);
}
printf("\n");
}
return 0;
}
+++++++++++++++++++++++++++++++++++++++++++&#
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。