Arnar Flatberg arnar.flatberg@gmail....
Sat Mar 1 11:50:48 CST 2008

```On Sat, Mar 1, 2008 at 8:27 AM, devnew@gmail.com <devnew@gmail.com> wrote:
>
>  > This example assumes that facearray is an ndarray.(like you described
>  > in original post ;-) ) It looks like you are using a matrix.
>
>  hi Arnar
>  thanks ..
>  a few doubts however
>
>  1.when i use say 10 images of 4X3 each
>
> u, s, vt = linalg.svd(facearray, 0)
>  i will get vt of shape (10,12)

> can't i take this as facespace?
Yes, you may

> why do i need to get the transpose?
You dont need to. I did because then it would put the eigenvectors
that span your column space as columns of the facespace array. I
figured that would be easier for you, as that would be compatible with
the use of eig (eigh) and matlab

>  then i can take as eigface_image0= vt[0].reshape(imgwdth,imght)
>
> 2.this way (svd) is diff from covariance matrix method.

No it is not. You may be fooled by the scaling though. I see from the
post above, that there may be some confusion here about svd and eig on
a crossproduct matrix :-)

Essentially, if X is a column centered array of size (num_images, num_pixels):

u, s, vt = linalg.svd(X),

Then, the columns of u span the space of dot(X, X.T), the rows of vt
span the space of dot(X.T, X) and s is a vector of scaling
coefficients. Another way of seeing this is that u spans the column
space of X, and vt spans the row space of X. So, for a third view, the
columns of u are the eigenvectors of dot(X, X.T) and the rows of vt
contains the eigenvectors of dot(X.T, X).

Now, in your, `covariance method` you use eigh(dot(X, X.T)), where the
eigenvectors would be exactly the same as u(the array) from an svd on
X. In order to recover the facespace you use facespace=dot(X.T, u).
This facespace is the same as s*vt.T, where s and vt are from the svd.

In my example, the eigenvectors spanning the column space were scaled.
I called this for scores: (u*s)
In your computation the facespace gets scaled implicit. Where to put
the scale is different from application to application and has no
clear definition.

I dont know if this made anything any clearer. However, a simple
example may be clearer:

-------
# X is (a ndarray, *not* matrix) column centered with vectorized images in rows

# method 1:
XX = dot(X, X.T)
s, u = linalg.eigh(XX)
reorder = s.argsort()[::-1]
facespace = dot(X.T, u[:,reorder])

# method 2:
u, s, vt = svd(X, 0)
facespace2 = s*vt.T
------

This gives identical result.
Please remember that eigenvector signs are arbitrary when comparing.

> if i am to do
>  it using the later ,how can i get the eigenface image data?

Just like I described before

Arnar
```