如何在Emgu CV中声明矩阵数组? [英] How to Declare Matrix array in Emgu CV?
问题描述
我是Emgu CV的新手。我需要一个矩阵数组来存储灰度图像的像素值。可以声明一个矩阵数组。
I am new in Emgu CV . I need a matrix array to store pixel values of gray images. Is it possible to declare a matrix array .
我为矩阵数组编写这样的代码,但是给出了错误
I code like this for matrix array But is gives "Error"
public Matrix<Double>[] Myimgmatrix = new Matrix<Double>[5](100,80);
错误:预期方法名称
任何人都可以帮助。
Error:"Method name expected" Any one Please Help.
推荐答案
这样做:
private Matrix<Double>[] Myimgmatrix = new Matrix<Double>[5];
然后,在您的类构造函数上,分别初始化数组上的每个矩阵:
And then, on your class constructor, initialize every matrix on the array individually:
for(int i = 0; i < Myimgmatrix.Length; i++)
Myimgmatrix[i] = new Matrix<Double>(100,80);
据我所知,您无法同时实例化数组及其元素。
As far as I know, you can't instantiate the array and its elements at the same time.
如果您不想在数组大小上灵活,也可以创建矩阵列表:
You can also create a matrix list, if you don't want to be flexible with the size of your array:
private List<Matrix<Double>> matrixList = new List<Matrix<Double>>();
然后,当您需要新矩阵时,只需将其添加到列表中即可,代码如下:
and then, when you need a new matrix, just add it to your list, on the code:
matrixList.Add(new Matrix<Double>(100,80));
这篇关于如何在Emgu CV中声明矩阵数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!