首页 > 行业资讯 > 【人脸识别】基于KL变换人脸识别含Matlab源码

【人脸识别】基于KL变换人脸识别含Matlab源码

时间:2022-02-28 来源: 浏览:

【人脸识别】基于KL变换人脸识别含Matlab源码

天天Matlab 天天Matlab
天天Matlab

TT_Matlab

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,完整matlab代码或者程序定制加qq1575304183。

收录于话题 #图像处理matlab源码 446个

1 简介

系统的设计是利用奇异值分解确定KL变换系数,并对人脸训练样本和待识别样本进行KL变换,对变换向量进行最小距离判别决策.对ORL人脸数据库的实验结果表明正确识别率随着变换系数维数的增加而增加,识别率可以达到的最大值为95%. 

K-L变换的思想:利用K-L变换确定相应的人脸基图像,再反过来用这些基图像对人脸图像库中的所有人脸图像进行K-L变换,从而得到每幅图像的参数向量并将每幅图的参数向量存起来。在识别时,先对一张所输入的脸图像进行必要的规范化,再进行K-L变换分析,得到其参数向量。将这个参数向量与库中每幅图的参数向量进行比较,找到最相似的参数向量,也就等于找到最相似的人脸。

2 部分代码

function varargout = renlian(varargin) % RENLIAN MATLAB code for renlian.fig % RENLIAN, by itself, creates a new RENLIAN or raises the existing % singleton*. % % H = RENLIAN returns the handle to a new RENLIAN or the handle to % the existing singleton*. % % RENLIAN(’CALLBACK’,hObject,eventData,handles,...) calls the local % function named CALLBACK in RENLIAN.M with the given input arguments. % % RENLIAN(’Property’,’Value’,...) creates a new RENLIAN or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before renlian_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to renlian_OpeningFcn via varargin. % % *See GUI Options on GUIDE’s Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help renlian % L % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct(’gui_Name’, mfilename, ... ’gui_Singleton’, gui_Singleton, ... ’gui_OpeningFcn’, @renlian_OpeningFcn, ... ’gui_OutputFcn’, @renlian_OutputFcn, ... ’gui_LayoutFcn’, [] , ... ’gui_Callback’, []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1 : nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before renlian is made visible. function renlian_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to renlian (see VARARGIN) % Choose default command line output for renlian handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes renlian wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = renlian_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on selection change in listbox1. function listbox1_Callback(hObject, eventdata, handles) str = get(handles.listbox1,’string’); v = get(handles.listbox1,’value’); a = [str{v} ’.bmp’]; axes(handles.axes1) imshow(a); % hObject handle to listbox1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,’String’)) returns listbox1 contents as cell array % contents{get(hObject,’Value’)} returns selected item from listbox1 % --- Executes during object creation, after setting all properties. function listbox1_CreateFcn(hObject, eventdata, handles) % hObject handle to listbox1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’)) set(hObject,’BackgroundColor’,’white’); end % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) N = 75; q = 5; x = zeros(10000,15); for i=1:N a = [num2str(i) ’.bmp’]; h = imread(a); [m n]=size(h); x( : ,i)=reshape(h,m*n,1); end pingjun = mean(x,2); d = repmat(pingjun,1,N); A = x-d; y = A’*A; [v u]=eig(y); tezhengzhi = sum(u); [tezhengzhi,xulie] = sort(tezhengzhi,2,’descend’); for i=1:q tezhenglian( : ,i)=A*v(:,xulie(i))*(tezhengzhi(i)^(-0.5));%特征脸 end for i=1:N P( : ,i)=tezhenglian’*A(:,i); end str = get(handles.listbox1,’string’); v = get(handles.listbox1,’value’); a = [str{v} ’.bmp’]; z = zeros(10000,1); h = imread(a); [m n]=size(h); z( : ,1)=reshape(h,m*n,1); shibie = tezhenglian’*(z-pingjun);%投影 chonggou = tezhenglian*shibie+pingjun;%重构 fangcha = ((z-chonggou)’*(z-chonggou))^0.5; yuzhi = 0; for i=1:N for j=i:N zanshiyuzhi = ((P(:,i)-P(:,j))’*(P(:,i)-P(:,j)))^0.5; if zanshiyuzhi>yuzhi yuzhi = zanshiyuzhi; end end end yuzhi = yuzhi/2; juli = 9e+009; for i=1:N bijiao = ((shibie-P(:,i))’*(shibie-P(:,i)))^0.5; if bijiao<juli; juli = bijiao; k = i; end end if fangcha>=yuzhi flag=1; elseif fangcha<yuzhi&&juli>=yuzhi flag==2; elseif fangcha<yuzhi&&juli<yuzhi flag=3; end if flag==1 a = [ ’0.png’]; axes(handles.axes3) imshow(a); set(handles.edit1,’string’,’未被识别,请重新采集’); elseif flag==2 a = [ ’0.png’]; axes(handles.axes3) imshow(a); set(handles.edit1,’string’,’输入图像包含未知人脸’); elseif flag==3 if k>15 ren = rem(k-1,15)+1; else ren=k; end a = [num2str(k) ’.bmp’]; axes(handles.axes3) imshow(a); set(handles.edit1,’string’,ren) end % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) function edit1_Callback(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) ren = rem(k-1,15)+1; else ren=k; end a = [num2str(k) ’.bmp’]; axes(handles.axes3) imshow(a); set(handles.edit1,’string’,ren) end % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

3 仿真结果

4 参考文献

[1]姚鸿勋, 高文. 基于KL变换的人脸识别方法[C]// 全国青年计算机工作者会议. 2007.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

版权:如无特殊注明,文章转载自网络,侵权请联系cnmhg168#163.com删除!文件均为网友上传,仅供研究和学习使用,务必24小时内删除。
相关推荐