pcl::PCA eigenvectors/eigenvalues are computed with incorrect Cov matrix? (1.8)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

pcl::PCA eigenvectors/eigenvalues are computed with incorrect Cov matrix? (1.8)

engin
This post was updated on .
Hello,

Line 85-88 of: https://github.com/PointCloudLibrary/pcl/blob/pcl-1.8.0/common/include/pcl/common/impl/pca.hpp
/*..*/
Eigen::Matrix3f alpha = static_cast<Eigen::Matrix3f> (cloud_demean.topRows<3> () * cloud_demean.topRows<3> ().transpose ());
 
  // Compute eigen vectors and values
Eigen::SelfAdjointEigenSolver<Eigen::Matrix3f> evd (alpha);
/*..*/

alpha is presumably the covariance matrix as it is passed to SelfAdjonitEigenSolver. But shouldn't that be:

alpha = 1/(N-1) * cloud_demean * cloud_demean.transpose()?

Not putting the 1/(N-1) makes the eigenvalues dependent on the number of points you have in the cloud. Double the number of data points you have in the exact same [x,y,z] interval you will get eigenvalues that are twice as big. The eigenvectors may still be fine as they are also normalized. But it still looks incorrect to me.

Was there a reason to write it like this that I'm missing?

Engin
Loading...