1.軟體版本
matlab2013b
2.系統概述

步驟一:圖檔特征提取
這裡,關于圖檔特征的提取,利用garbor變換進行特征提取的。以二維形式存在的人臉圖像所包含的資料資訊是非常多的,而且,這些資料中還包含了很多與人臉身份并沒有多少關系的備援資訊,例如,表情、光線條件等。是以,不能将這些資料直接作為人臉的代表特征來進行識别,也就是必須首先進行特征提取。特征提取的定義為:當原始特征的數量很大,或者說樣本是處于一個高維空間中的向量時,通過映射(或變換)的方法用低維空間來表示。如上所述,由于人臉的維數在通常情況下很高,特征提取的成敗就對整個識别階段的效果有決定性的影響。甚至可以這樣認為:在某種意義上,人臉識别過程的成敗就決定于特征提取的好壞,是以,如何有效的進行特征提取就成為人臉識别科研人員不得不面對的關鍵性問題。鑒于特征提取的重要性,也有人将它獨立作為整個人臉識别過程中的一個階段。這裡,其主要操作時提取特征,并将特征結果向量化,使二維的特征矩陣變為一維的特征向量,進而友善操作。
Face圖檔:
Noface圖檔:
這裡,我們使用的特征參數公式為:
最後将得到特征圖像,然後将其變為一維的向量:
首先,這裡面的資料gabor特征資料,具體的理論要看這次提供給你的文獻(之前沒有給你)
裡面有四個論文,其主要的思想是這樣的:
首先要了解二維的gabor函數:
這裡的feature就是根據gabor函數得到的特征參數組。
這個參數是用來在提取特征的時候,參與運算的。
步驟二:訓練
這裡,我們主要通過支援向量機,對特種資料進行訓練,其主要的理論如下所示:
SVM是20世紀90年代由Vapnik等人提出的,來源于統計學習理論的一種新的資料分類技術。其主要思想就是通過一個非線性變換将原始的資料變換到一個高維的特征空間,并在新的空間實作最優分類。
上述的最優分類函數其最終的分類判别函數以及它的求解過程隻涉及樣本之間的内積運算。可見,要解決一個特征空間中的最優線性分類問題,隻需知道這個空間的内積運算即可。
SVM本身是用于分類的,并不具有比對的功能,本系統為了保證在較高的正确通過率的基礎上仍然具有較高的正确拒識率,提出了基于SVM的人臉比對方法。它是在第一步基于個性特征模闆的人臉比對結果為“拒絕”的基礎上進行的第二層驗證。
SVM的主要思想可以概括為兩點:
(1) 它是針對線性可分情況進行分析,對于線性不可分的情況,通過使用非線性映射算法将低維輸入空間線性不可分的樣本轉化為高維特征空間使其線性可分,進而 使得高維特征空間采用線性算法對樣本的非線性特征進行線性分析成為可能。
(2) 它基于結構風險最小化理論之上在特征空間中建構最優分割超平面,使得學習器得到全局最優化,并且在整個樣本空間的期望風險以某個機率滿足一定上界。
本文給出 “相似性” 的度量方法來構造 SVM分類器。所謂“相似性” , 是指兩幅人臉圖像在特征臉空間中值之差,如果各分量都保持在一個較小範圍内, 有理由相信這是同一個人臉。
標明集合C={},其中n為人數,和分别為第i個人不同的圖像,在特征空間中的值,将其按照如下方案分:,,可以看出正是 “相似” 的人臉, 共有n 個; 而全部都是“非相似”人臉,共有 n* ( n- 1)個,是以,組成如下n*n個訓練樣本集: 。
現假設在資料庫共有 m個已知人臉圖像, 基于上述SVM的設計原理, 構造如下的 m個函數( 注意這些函數沒有取符号sgn) :
3.部分源碼
function varargout = main(varargin)
% MAIN MATLAB code for main.fig
% MAIN, by itself, creates a new MAIN or raises the existing
% singleton*.
%
% H = MAIN returns the handle to a new MAIN or the handle to
% the existing singleton*.
%
% MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MAIN.M with the given input arguments.
%
% MAIN('Property','Value',...) creates a new MAIN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before main_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to main_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 main
% Last Modified by GUIDE v2.5 16-Sep-2011 23:09:23
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @main_OpeningFcn, ...
'gui_OutputFcn', @main_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 main is made visible.
function main_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 main (see VARARGIN)
% Choose default command line output for main
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes main wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = main_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 button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% 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)
func_image_features();
warning off;
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% 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)
load mat\Lib_pic.mat
net = func_trains(PICS);
warning off;
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I;
global I2;
global Nums;
axes(handles.axes1);
[filename,pathname]=uigetfile({'*.*','All Files(*.*)';},'選擇檔案');
if isequal([filename,pathname],[0,0])
return
else
pic = fullfile(pathname,filename);
I = imread(pic);
imshow(I,'notruesize');
end
if isrgb(I)
I2 = rgb2gray(I);
else
I2 = imresize(I);
end
axes(handles.axes2);
imshow(I2,'notruesize');
warning off;
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I;
global I2;
global Nums;
global images_facefind
load mat\Network.mat;
Nums2 = str2num(get(handles.edit2,'string'));
images_facefind = func_facefind(net,I2,Nums2);
axes(handles.axes2);
imshow(images_facefind,'notruesize');
warning off;
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clc;
clear;
close all;
warning off;
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)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit 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
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit 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
4.仿真結論
整個算法的測試效果如下所示: