12/16/2016

Eigen analysis(of a symmetric matrix) in opencv exmaple code


//Eigen analysis(of a symmetric matrix) :
 float f11[] = { 1, 0.446, -0.56, 0.446, 1, -0.239, -0.56, 0.239, 1 };
 Mat data(3, 3, CV_32F, f11);
 cout << "input data" << endl;
 cout << data << endl;
 Mat value, vector;
 eigen(data, value, vector);
 cout << "Eigenvalues" << endl << value << endl;
 cout << "Eigenvectors" << endl << vector << endl;

proof
cout << vector << endl;
 cout << endl << "AV" << endl;
 cout << data * vector << endl;

 cout << "vV" << endl;
 Mat ValueEye = Mat::eye(3, 3, CV_32F);
 ValueEye.at< float>(0, 0) = value.at< float>(0, 0);
 ValueEye.at< float>(1, 1) = value.at< float>(1, 0);
 ValueEye.at< float>(2, 2) = value.at< float>(2, 0);
 cout << vector*ValueEye << endl;

No comments:

Post a Comment