资源简介
基于Python3.7实现人脸图像特征提取与对比,调用NMF算法和PCA算法。包括源程序和结果图片。

代码片段和文件信息
from numpy.random import RandomState
import matplotlib.pyplot as plt
from sklearn.datasets import fetch_olivetti_faces
from sklearn import decomposition
n_row n_col = 2 3
n_components = n_row * n_col
image_shape = (64 64)
###############################################################################
# Load faces data
dataset = fetch_olivetti_faces(shuffle=True random_state=RandomState(0))
faces = dataset.data
###############################################################################
def plot_gallery(title images n_col=n_col n_row=n_row):
plt.figure(figsize=(2. * n_col 2.26 * n_row))
plt.suptitle(title size=16)
for i comp in enumerate(images):
plt.subplot(n_row n_col i + 1)
vmax = max(comp.max() -comp.min())
plt.imshow(comp.reshape(image_shape) cmap=plt.cm.gray
interpolation=‘nearest‘ vmin=-vmax vmax=vmax)
plt.xticks(())
plt.yticks(())
plt.subplots_adjust(0.01 0.05 0.99 0.94 0.04 0.)
plot_gallery(“First centered Olivetti faces“ faces[:n_components])
###############################################################################
estimators = [
(‘Eigenfaces - PCA using randomized SVD‘
decomposition.PCA(n_components=6whiten=True))
(‘Non-negative components - NMF‘
decomposition.NMF(n_components=6 init=‘nndsvda‘ tol=5e-3))
]
###############################################################################
for name estimator in estimators:
print(“Extracting the top %d %s...“ % (n_components name))
print(faces.shape)
estimator.fit(faces)
components_ = estimator.components_
plot_gallery(name components_[:n_components])
plt.show()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 42672 2018-07-11 22:47 人脸图像特征提取与对比\Figure_1.png
文件 42610 2018-07-11 22:47 人脸图像特征提取与对比\Figure_2.png
文件 36555 2018-07-11 22:47 人脸图像特征提取与对比\Figure_3.png
文件 1788 2017-06-13 23:30 人脸图像特征提取与对比\NMF、PCA-人脸图像特征抽取与对比.py
目录 0 2018-07-11 22:47 人脸图像特征提取与对比
----------- --------- ---------- ----- ----
123625 5
相关资源
- 基于PCA模型的鸢尾花数据可视化
- 二维码识别+RGB识别+色环识别+通过串
- 人脸识别算法,双2D2DPCALBP余弦相似度
- MATLAB版本的2Dpca和欧式距离算法
- Python-PCA降维人脸识别,已包含yale数据
- 《深入浅出Python机器学习》源程序.
- 人脸识别-python-特征脸-PCA
- PCA 算法实验代码python
- PCA+PSO-ELM.rar
- Python程序设计_车万翔译_课后全部答案
- PCA算法实现
- 主成分分析(PCA)python实现(含数据
- PCA降维+分类器 python语言写的
- 核主成分分析(Kernel Principal Componen
- python分析pcap
- 基于PCA的人脸识别系统-python版
- 粒子群算法 Python源程序
- python基于winpcap的抓包和发包
- PCA故障诊断python实现
- python pcap模块WIN32 64位版本
- 基于GDAL的Python实现遥感影像PCA的代码
- 树莓派_python_PCA9685_16路舵机自定义角
- 解析pcap数据包
- Python实现PCA
- PCA结合马氏距离 py代码
- 基于PCA实现鸢尾花数据集降维
- 基于sklearn模块的KMeans聚类算法实现“
- KMeans++算法实现图像分割
- 基于KNN实现“手写识别”
- 基于sklearn模块的神经网络实现“手写
评论
共有 条评论