I have an Image<Gray, Byte>
trainImage with the size NxN, and i want to change it into 1D Matrix<float>
trainMatrix with the size (N^2)x1
.
What I am trying to do is to call CvInvoke.cvCalvCovarmatrix()
. For the first parameter I'm using Matrix<Single>[]
that i convert into IntPtr[]
.
Matrix<Single> avg = new Matrix<float>(7, 1);
Matrix<Single> cov = new Matrix<float>(7, 7);
Matrix<Single>[] input = new Matrix<float>[3];
for (int i = 0; i < 3; i++)
input[i] = new Matrix<float>(7, 1);
IntPtr[] inObjs = Array.ConvertAll<Matrix<Single>, IntPtr>(input, delegate(Matrix<Single> mat) { return mat.Ptr; });
CvInvoke.cvCalcCovarMatrix(inObjs, 3, cov, avg, COVAR_METHOD.CV_COVAR_NORMAL);
But now i have input that is Image<Gray, Byte>[]
with each image size (let's assume) 7x7. I think i will need to convert each image into Matrix<float>
with size 49x1 first before changing it into IntPtr[]
. How to do it?