How can I use PCACompute and PCAProject in java?

asked 2014-04-03 21:40:03 -0600

lingyun gravatar image

updated 2014-04-03 22:08:27 -0600

I am trying to reduce vector size usig PCA in java. I am dealing with 40 objects(col), and each object has 644 feature vector(row). I want to reduce feature vector size 50% which means resultant feature vector would be (322). I use following code segment,but could not get the right answer. How can I reduce using PCACommpute and PCAProject? Thanks in advance.

code:

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

float[] a= new float[]{(....};

Mat srcMat = new Mat(644,40,CvType.CV_32FC1);

srcMat.put(0,0,a);

Mat Avg = new Mat(1,644,CvType.CV_32FC1);

Mat EginenValue = new Mat(644,1,CvType.CV_32FC1);

Mat EigenVector = new Mat(644,644,CvType.CV_32FC1);

core.PCACompute(srcMat,Avg,EigenVector,322)

edit retag flag offensive close merge delete