Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various PCA Results #21

Open
ykmd opened this issue Jul 17, 2014 · 7 comments
Open

Various PCA Results #21

ykmd opened this issue Jul 17, 2014 · 7 comments

Comments

@ykmd
Copy link

ykmd commented Jul 17, 2014

I applied tapkee PCA and opencv PCA to the same data and I got different results.
So I wonder if the methods are different in detail.

@lisitsyn
Copy link
Owner

This could be caused by whitening. Could you please attach these different projections so I can plot and analyze them?

@ykmd
Copy link
Author

ykmd commented Jul 21, 2014

Code:
image = imread(filename, IMREAD_COLOR);
imageCV = image.reshape(1,image.rows_image.cols);
DenseMatrix imageE = DenseMatrix(imageCV.cols,imageCV.rows);
cv2eigen(imageCV.t(),imageE);
TapkeeOutput output = initialize()
.withParameters((method=tapkee::PCA,
target_dimension=3))
.embedUsing(imageE);
eigen2cv(output.embedding, imagePCA);
cv::PCA pca(imageCV, Mat(), CV_PCA_DATA_AS_COL, 3);
imshow("tapkeePCA", norm_0_255(imagePCA.t()).reshape(1, image.rows_3));
imshow("cvPCA", norm_0_255(pca.eigenvectors).reshape(1, image.rows*3));
Result:
pca

@lisitsyn
Copy link
Owner

What bothers me is the case itself. Could you please explain what would be the meaning of such projection?

@ykmd
Copy link
Author

ykmd commented Jul 31, 2014

PCA in opencv is to maximize the variance with the top dimension.
Data is in the form of RGB, result is treated in gray scale.
I followed the description in this note.
http://www.math.tau.ac.il/~turkel/notes/K-L.pdf

Date: Thu, 31 Jul 2014 10:09:50 -0700
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [tapkee] Various PCA Results (#21)

What bothers me is the case itself. Could you please explain what would be the meaning of such projection?


Reply to this email directly or view it on GitHub.

@lisitsyn
Copy link
Owner

Okay I see. Tapkee's PCA does the same thing as described. OpenCV is a bit different due to normalization.

@ykmd
Copy link
Author

ykmd commented Jul 31, 2014

Somehow this data set cannot be solved by PCA with ARPACK solver, and kPCA with ARPACK produces a more alike result.

Date: Thu, 31 Jul 2014 11:41:14 -0700
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [tapkee] Various PCA Results (#21)

Okay I see. Tapkee's PCA does the same thing as described. OpenCV is a bit different due to normalization.


Reply to this email directly or view it on GitHub.

@lisitsyn
Copy link
Owner

Actually it could be due to numerical stability of ARPACK. This case is pretty singular as such 1-vector covariance could lead to ill-posed eigenproblem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants