如何使用matplotlib中的类PCA进行人脸识别?

时间:2013-04-09 11:01:59

标签: python matplotlib face-recognition pca

我正在尝试使用python构建面部识别代码。现在,我可以将所有数据库图像放入一个二维数组中,以便能够对它们应用主成分分析(PCA)。我在matplotlib中找到了一个名为PCA的类,但我想知道如何将它用于人脸识别。

以下是上述课程的描述:

class matplotlib.mlab.PCA(a)
compute the SVD of a and store data for PCA. Use project to project the data onto a reduced set of dimensions

Inputs:

a: a numobservations x numdims array
Attrs:

a a centered unit sigma version of input a

numrows, numcols: the dimensions of a

mu : a numdims array of means of a

sigma : a numdims array of atandard deviation of a

fracs : the proportion of variance of each of the principal components

Wt : the weight vector for projecting a numdims point or array into PCA space

Y : a projected into PCA space

The factor loadings are in the Wt factor, ie the factor loadings for the 1st principal component are given by Wt[0] 

1 个答案:

答案 0 :(得分:1)

它们的关键概念是将面部投影到更高维度的空间中,然后测量它们在该空间中的距离。

我引用了这个文档(看起来像是一个类的作业):

http://www.umiacs.umd.edu/~knkim/KG_VISA/PCA/FaceRecog_PCA_Kim.pdf

“PCA计算由训练向量表示的空间的基础。这些基本向量,实际上是由PCA计算的特征向量,是训练向量的最大方差的方向。如前所述,我们称他们为特征脸。

每个特征脸都可以被视为一个特征。当特定的面部投射到面部空间时,其向面部空间的矢量描述了面部中每个特征的重要性。面部通过其特征面系数(或权重)在面部空间中表示。我们只能通过在面部空间中使用其小的权重向量来处理大的输入向量,面部图像。这意味着我们可以用一些误差重建原始面部,因为图像空间的维度远大于面部空间的维度。

在本报告中,我们只考虑面部识别。训练集中的每个面都被转换为面部空间,其组件存储在内存中。面部空间必须填充这些已知面部。将输入面提供给系统,然后将其投影到面部空间。系统计算它与所有存储面的距离。“

有几个教程可用。这是我的最爱:

相关问题