简体   繁体   中英

Equivalent matlab code to maths formula (covariance matrix for eigenfaces algorithm)

在此处输入图片说明

I'm developing the eigenfaces algorithm for face recognition. Having subtracted the mean from the training images I now have the matrix A with the centered images.

Now I'm not sure whether the matlab code AxA' is equivalent the whole first line shown in the image above or just the ΣΦnΦn' part.

So what I'm asking is do I still need to divide AxA' by M (training set size) or is it part of the matrix multiplication carried out by Matlab?

It actually depends on the notation used in this paper and/or in Matlab. From a strictly mathematical point of view, the two must be equal.

In a general terms, if you have subtracted the mean value, the next step is to evaluate the covariance matrix (have a look at cov() in Matlab) and then from such matrix you should extract eigenvalues and eigenvectors.

Turns out that only the ΣΦnΦn' part is equivalent to AxA' so division by M is ALSO required. I have found the way to do the sum on paper and I tried a simple 2x2 matrix ( https://math.stackexchange.com/questions/621036/how-sum-work-vectors-and-matrices ).

For a matrix Q = [1 2 ; 3 4] the transpose Q' = [1 3 ; 2 4]. On paper ΣQnQn' = [5 11 ; 11 25] and in Matlab QxQ' = [5 11 ; 11 25]. This shows that the 1/M part of the formula is not done by Matlab and I need to do it separately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM