Forwarding this to the developers list because it seems like a serious issue and it hasn't gotten any replies on the users list in a month.
Any thoughts? David  Forwarded message  From: engin <[hidden email]> Date: Fri, Mar 17, 2017 at 8:55 AM Subject: [PCLusers] pcl::PCA eigenvectors/eigenvalues are computed with incorrect Cov matrix? (1.8) To: [hidden email] Hello, Line 8588 of: https://github.com/ /*..*/ Eigen::Matrix3f alpha = static_cast<Eigen::Matrix3f> (cloud_demean.topRows<3> () * cloud_demean.topRows<3> ().transpose ()); // Compute eigen vectors and values Eigen::SelfAdjointEigenSolver< /*..*/ alpha is presumably the covariance matrix as it is passed to SelfAdjonitEigenSolver. But shouldn't that be: alpha = 1/(N1) * cloud_demean * cloud_demean.transpose()? Not putting the 1/(N1) 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. Here is an example, I replicated from http://www.cs.otago.ac.nz/ <http://www.cs.otago.ac.nz/ : If cov is calculated as in the code, the eigenvalues you get will be: [0.44354, 80.79646]' their ratio: L1/L2 = 182.16 The correct values are: [0.049083 , 1.284028] L1/L2 = 26.160 Was there a reason to write it like this that I'm missing? Engin  View this message in context: http://www.pclusers.org/pcl Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com. ______________________________ [hidden email] / http://pointclouds.org http://pointclouds.org/ _______________________________________________ PCLdevelopers mailing list [hidden email] http://pointclouds.org/mailman/listinfo/pcldevelopers http://pointclouds.org 
Administrator

Hi Nizar,
looks like this is your code in question: https://github.com/PointCloudLibrary/pcl/commit/10796ed4b2ee3ae2c2badba630be139d2ed3e357 Can you comment or better, send a pull request? @David thanks for pinging! Cheers Jochen * David Doria <[hidden email]> [20170427 09:45]: > Forwarding this to the developers list because it seems like a serious > issue and it hasn't gotten any replies on the users list in a month. > > Any thoughts? > > David > >  Forwarded message  > From: engin <[hidden email]> > Date: Fri, Mar 17, 2017 at 8:55 AM > Subject: [PCLusers] pcl::PCA eigenvectors/eigenvalues are computed with > incorrect Cov matrix? (1.8) > To: [hidden email] > > > Hello, > > Line 8588 of: > https://github.com/PointCloudLibrary/pcl/blob/pcl1.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/(N1) * cloud_demean * cloud_demean.transpose()? > > Not putting the 1/(N1) 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. > > Here is an example, I replicated from > http://www.cs.otago.ac.nz/cosc453/student_tutorials/principal_components.pdf > <http://www.cs.otago.ac.nz/cosc453/student_tutorials/ > principal_components.pdf> > : > > If cov is calculated as in the code, the eigenvalues you get will be: > [0.44354, 80.79646]' > their ratio: L1/L2 = 182.16 > > The correct values are: > [0.049083 , 1.284028] > L1/L2 = 26.160 > > Was there a reason to write it like this that I'm missing? > > Engin > > > >  > View this message in context: http://www.pclusers.org/pcl > PCAeigenvectorseigenvaluesarecomputedwithincorrect > Covmatrix18tp4044153.html > Sent from the Point Cloud Library (PCL) Users mailing list mailing list > archive at Nabble.com. > _______________________________________________ > [hidden email] / http://pointclouds.org > http://pointclouds.org/mailman/listinfo/pclusers > _______________________________________________ > PCLdevelopers mailing list > [hidden email] > http://pointclouds.org/mailman/listinfo/pcldevelopers > http://pointclouds.org _______________________________________________ PCLdevelopers mailing list [hidden email] http://pointclouds.org/mailman/listinfo/pcldevelopers http://pointclouds.org signature.asc (849 bytes) Download Attachment 
Just discovered this now. The issue is opened and the corresponding PR as well. Sorry for the late feedback. Cheers20170427 15:53 GMT+01:00 Jochen Sprickerhof <[hidden email]>: Hi Nizar, _______________________________________________ PCLdevelopers mailing list [hidden email] http://pointclouds.org/mailman/listinfo/pcldevelopers http://pointclouds.org 
Free forum by Nabble  Resume Templates  Edit this page 