【人脸识别】基于FISHER线性判决的人脸识别系统附GUI界面

本文涉及的产品
视觉智能开放平台,视频资源包5000点
视觉智能开放平台,分割抠图1万点
视觉智能开放平台,图像资源包5000点
简介: 【人脸识别】基于FISHER线性判决的人脸识别系统附GUI界面

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法       神经网络预测       雷达通信      无线传感器        电力系统

信号处理              图像处理               路径规划       元胞自动机        无人机

⛄ 内容介绍

人脸识别是计算机视觉和模式识别领域的一个活跃课题,有着十分广泛的应用前景.给出了一种基于PCA和LDA方法的人脸识别系统的实现.首先该算法采用奇异值分解技术提取主成分,然后用Fisher线性判别分析技术来提取最终特征,最后将测试图像的投影与每一训练图像的投影相比较,与测试图像最接近的训练图像被系统识别出,图像的比较采用了欧几里德距离,仿真结果表明了该方法的有效性.

⛄ 部分代码

function [m_database V_PCA V_Fisher ProjectedImages_Fisher] = FisherfaceCore(T)

% Use Principle Component Analysis (PCA) and Fisher Linear Discriminant (FLD) to determine the most

% discriminating features between images of faces.

%

% Description: This function gets a 2D matrix, containing all training image vectors

% and returns 4 outputs which are extracted from training database.

% Suppose Ti is a training image, which has been reshaped into a 1D vector.

% Also, P is the total number of MxN training images and C is the number of

% classes. At first, centered Ti is mapped onto a (P-C) linear subspace by V_PCA

% transfer matrix: Zi = V_PCA * (Ti - m_database).

% Then, Zi is converted to Yi by projecting onto a (C-1) linear subspace, so that

% images of the same class (or person) move closer together and images of difference

% classes move further apart: Yi = V_Fisher' * Zi = V_Fisher' * V_PCA' * (Ti - m_database)

%

% Argument:      T                      - (M*NxP) A 2D matrix, containing all 1D image vectors.

%                                         All of 1D column vectors have the same length of M*N

%                                         and 'T' will be a MNxP 2D matrix.

%

% Returns:       m_database             - (M*Nx1) Mean of the training database

%                V_PCA                  - (M*Nx(P-C)) Eigen vectors of the covariance matrix of the

%                                         training database

%                V_Fisher               - ((P-C)x(C-1)) Largest (C-1) eigen vectors of matrix J = inv(Sw) * Sb

%                ProjectedImages_Fisher - ((C-1)xP) Training images, which are projected onto Fisher linear space

%

% See also: EIG


% Original version by Amir Hossein Omidvarnia, October 2007

%                     Email: aomidvar@ece.ut.ac.ir                  



Class_number = ( size(T,2) )/2; % Number of classes (or persons)  矩阵 T 的列数 除以2,也就是 训练图片数量的一半

Class_population = 2; % Number of images in each class

P = Class_population * Class_number; % Total number of training images


%%%%%%%%%%%%%%%%%%%%%%%% calculating the mean image

m_database = mean(T,2); %样本均值


%%%%%%%%%%%%%%%%%%%%%%%% Calculating the deviation of each image from mean image 每张图片与均值图片的背离程度  

A = T - repmat(m_database,1,P);


%%%%%%%%%%%%%%%%%%%%%%%% Snapshot method of Eigenface algorithm

L = A'*A; % L is the surrogate(代理人) of covariance matrix C=A*A'.协方差矩阵

[V D] = eig(L); % Diagonal elements of D are the eigenvalues for both L=A'*A and C=A*A'.


%%%%%%%%%%%%%%%%%%%%%%%% Sorting and eliminating small eigenvalues

L_eig_vec = [];

for i = 1 : P-Class_number

   L_eig_vec = [L_eig_vec V(:,i)];

end


%%%%%%%%%%%%%%%%%%%%%%%% Calculating the eigenvectors of covariance matrix 'C'

V_PCA = A * L_eig_vec; % A: centered image vectors


%%%%%%%%%%%%%%%%%%%%%%%% Projecting centered image vectors onto eigenspace

% Zi = V_PCA' * (Ti-m_database)

ProjectedImages_PCA = [];

for i = 1 : P

   temp = V_PCA'*A(:,i);

   ProjectedImages_PCA = [ProjectedImages_PCA temp];

end


%%%%%%%%%%%%%%%%%%%%%%%% Calculating the mean of each class in eigenspace

m_PCA = mean(ProjectedImages_PCA,2); % Total mean in eigenspace

m = zeros(P-Class_number,Class_number);

Sw = zeros(P-Class_number,P-Class_number); % Initialization os Within Scatter Matrix

Sb = zeros(P-Class_number,P-Class_number); % Initialization of Between Scatter Matrix


for i = 1 : Class_number

   m(:,i) = mean( ( ProjectedImages_PCA(:,((i-1)*Class_population+1):i*Class_population) ), 2 )';    

   

   S  = zeros(P-Class_number,P-Class_number);

   for j = ( (i-1)*Class_population+1 ) : ( i*Class_population )

       S = S + (ProjectedImages_PCA(:,j)-m(:,i))*(ProjectedImages_PCA(:,j)-m(:,i))';

   end

   

   Sw = Sw + S; % Within Scatter Matrix

   Sb = Sb + (m(:,i)-m_PCA) * (m(:,i)-m_PCA)'; % Between Scatter Matrix

end


%%%%%%%%%%%%%%%%%%%%%%%% Calculating Fisher discriminant basis's

% We want to maximise the Between Scatter Matrix, while minimising the

% Within Scatter Matrix. Thus, a cost function J is defined, so that this condition is satisfied.

[J_eig_vec, J_eig_val] = eig(Sb,Sw); % Cost function J = inv(Sw) * Sb

J_eig_vec = fliplr(J_eig_vec);


%%%%%%%%%%%%%%%%%%%%%%%% Eliminating zero eigens and sorting in descend order

for i = 1 : Class_number-1

   V_Fisher(:,i) = J_eig_vec(:,i); % Largest (C-1) eigen vectors of matrix J

end


%%%%%%%%%%%%%%%%%%%%%%%% Projecting images onto Fisher linear space

% Yi = V_Fisher' * V_PCA' * (Ti - m_database)

for i = 1 : Class_number*Class_population

   ProjectedImages_Fisher(:,i) = V_Fisher' * ProjectedImages_PCA(:,i);

end

⛄ 运行结果

⛄ 参考文献

[1] 钟向阳, 胡仕明. 基于主分量线性判别方法人脸识别系统的实现[J]. 嘉应学院学报:自然科学版, 2006.

[2] 张凯歌. 基于线性判别分析的人脸识别系统研究与实现[D]. 广东工业大学.

[3] 乐丹, 罗文兵, 叶继华,等. 基于2DPCA和Fisher的嵌入式人脸识别系统的实现[J]. 科技广场, 2011(1):4.

[4] 曾贤灏, 李向伟. 基于Fisher准则改进线性判别回归分类的人脸识别[J]. 计算机应用与软件, 2014, 31(9):4.

[5] 马祥, 王映卓, 樊强. 基于LLE与Fisher线性判别的人脸识别算法[J]. 现代电子技术, 2012, 35(8):3.

⛳️ 代码获取关注我

❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料


相关文章
|
9月前
|
存储 算法 Linux
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
295 7
|
4月前
|
计算机视觉 Python
基于Dlib的人脸识别客户端(UI界面)
基于Dlib的人脸识别客户端(UI界面)
125 2
|
6月前
|
数据安全/隐私保护
数据安全用户系统问题之实人认证信息在用户模型中体现的如何解决
数据安全用户系统问题之实人认证信息在用户模型中体现的如何解决
|
6月前
|
机器学习/深度学习 人工智能 监控
利用Python和OpenCV实现实时人脸识别系统
【8月更文挑战第31天】本文将引导您了解如何使用Python结合OpenCV库构建一个简易的实时人脸识别系统。通过分步讲解和示例代码,我们将探索如何从摄像头捕获视频流、进行人脸检测以及识别特定个体。本教程旨在为初学者提供一条明晰的学习路径,帮助他们快速入门并实践人脸识别技术。
|
9月前
|
传感器 人工智能 前端开发
JAVA语言VUE2+Spring boot+MySQL开发的智慧校园系统源码(电子班牌可人脸识别)Saas 模式
智慧校园电子班牌,坐落于班级的门口,适合于各类型学校的场景应用,班级学校日常内容更新可由班级自行管理,也可由学校统一管理。让我们一起看看,电子班牌有哪些功能呢?
580 4
JAVA语言VUE2+Spring boot+MySQL开发的智慧校园系统源码(电子班牌可人脸识别)Saas 模式
|
7月前
|
机器学习/深度学习 人工智能 计算机视觉
好的资源-----打卡机+Arm+Qt+OpenCV嵌入式项目-基于人脸识别的考勤系统-----B站神经网络与深度学习,商城
好的资源-----打卡机+Arm+Qt+OpenCV嵌入式项目-基于人脸识别的考勤系统-----B站神经网络与深度学习,商城
|
8月前
|
机器学习/深度学习 监控 算法
使用Python和OpenCV实现简单的人脸识别系统
使用Python和OpenCV实现简单的人脸识别系统
95 0
|
9月前
|
机器学习/深度学习 监控 算法
利用深度学习技术实现人脸识别系统
人脸识别技术在当今社会得到了广泛应用,其中深度学习算法的发展为人脸识别系统的性能提升提供了强大支持。本文将介绍如何利用深度学习技术构建一个高效的人脸识别系统,包括数据准备、模型选择、训练过程和系统部署等方面的内容。
|
9月前
|
小程序 JavaScript Java
android电子班牌人脸识别系统源码
智慧校园云平台全套源码包含:电子班牌管理系统、成绩管理系统、考勤人脸刷卡管理系统、综合素养评价系统、请假管理系统、电子班牌发布系统、校务管理系统、小程序移动端、教师后台管理系统、SaaS运营云平台。
81 1

热门文章

最新文章