How to Declare Matrix array in Emgu CV?

2019-08-09 08:36发布

问题:

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.

回答1:

Do it like that:

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));


回答2:

Actually you can directly access gray pixel values from the image data in emgucv. You can check the implementation in emgu cv from this link work with matrix



标签: emgucv