I finally looked at the tutorial that you provided, and it seems that the author suggests that you smooth the images. At this point, you can continue using flattened arrays, as it better matches this tutorial.
I believe that the place to fix it is in step 7, where you have the covariance of the input image. However, the covariance matrix of the input image will be scalar, and you will not be able to find the eigenvalues ββand eigenvectors. You can project it as a 2d matrix of size (1,1) , but then your own value will be just covariance, and your own vector will be [[1]] .
That is, for example,
In [563]: input_image = np.random.rand(90,90).flatten() In [564]: c = np.cov(input_image) In [565]: c Out[565]: array(0.08280644230318886) In [566]: c.shape Out[566]: () In [567]: c.ndim Out[567]: 0
So, we reformat c as 2d:
In [568]: cmat = c.reshape(1,1)
So now we can find our own element:
In [572]: ceigval, ceigvec = linalg.eig(cmat)
But for a singleton matrix, there is only one eigenvalue and one eigenvector, and the eigenvalue is an element of the matrix, and the eigenvector is a unit vector of length 1, so I'm not sure if this is really what you want to do for face recognition.
In [573]: ceigval Out[573]: array([ 0.08280644]) In [574]: ceigvec Out[574]: array([[ 1.]]) In [576]: np.isclose(c, ceigval) Out[576]: True
By the way, so we had to do c 2d:
In [577]: linalg.eig(c) --------------------------------------------------------------------------- LinAlgError: 0-dimensional array given. Array must be two-dimensional
On the other hand, you can get covariance of uncompressed image_input, then you will have N eigenvalues ββand N eigenvectors:
In [582]: input_image = np.random.rand(90,90) In [583]: c = np.cov(input_image) In [584]: c.shape Out[584]: (90, 90) In [585]: ceigval, ceigvec = linalg.eig(c) In [586]: ceigval.shape Out[586]: (90,) In [587]: ceigvec.shape Out[587]: (90, 90)