版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、計(jì)劃實(shí)現(xiàn)了一個(gè)基于PCA的人臉識(shí)別方法,我稱之為“特征點(diǎn)方法”,所有的功能簡(jiǎn)單而且實(shí)用。 下面,我使用一個(gè)簡(jiǎn)單的MATLAB腳本說(shuō)明它的用法。 一般情況,你應(yīng)該按照以下這個(gè)順序執(zhí)行這個(gè)方法: 1.選擇實(shí)際測(cè)試和參照組人臉圖像數(shù)據(jù)庫(kù)的路徑; 2.選擇實(shí)際測(cè)試人臉圖像的路徑; 3.運(yùn)行“CreateDatabase”函數(shù)來(lái)創(chuàng)建所有參照組人臉圖像的二維矩陣; 4.運(yùn)行“eigenfacecore函數(shù)產(chǎn)生基礎(chǔ)人臉圖像空間; 5.運(yùn)行“識(shí)別”功能得到參照組人臉圖像數(shù)據(jù)庫(kù)中等價(jià)圖像的名稱。 為了您的方便,我準(zhǔn)備了實(shí)際測(cè)試和參照組人臉圖像數(shù)據(jù)庫(kù),其中部分來(lái)自“Face94”埃塞克斯人臉數(shù)據(jù)庫(kù)。 你只需要復(fù)制
2、上述功能,指定實(shí)際測(cè)試和參照組人臉圖像數(shù)據(jù)庫(kù)的路徑(比如Matlab工作路徑)。 然后按照對(duì)話框提示輸入圖片編號(hào),實(shí)例將運(yùn)行實(shí)現(xiàn)。 希望您能喜歡它! 引用:1 P. N. Belhumeur, J. Hespanha, and D. J. Kriegman. Eigenfaces vs. Fisherfaces: Recognition using class specific linear projection. In ECCV (1), pages 45-58, 1996.2 Available at: http:/cswww.essex.ac.uk/mv/allfaces/faces94
3、.zip以下為源代碼文件:-CreateDatabase.mfunction T = CreateDatabase(TrainDatabasePath)% Align a set of face images (the training set T1, T2, . , TM )% Description: This function reshapes all 2D images of the training database% into 1D column vectors. Then, it puts these 1D column vectors in a row to% construc
4、t 2D matrix T.% % Argument: TrainDatabasePath - Path of the training database% Returns: T - A 2D matrix, containing all 1D image vectors.% Suppose all P images in the training database% have the same size of MxN. So the length of 1D% column vectors is MN and T will be a MNxP 2D matrix.% See also: ST
5、RCMP, STRCAT, RESHAPE% Original version by Amir Hossein Omidvarnia, October 2007% Email: aomidvarece.ut.ac.ir % File managementTrainFiles = dir(TrainDatabasePath);Train_Number = 0;for i = 1:size(TrainFiles,1) if not(strcmp(TrainFiles(i).name,.)|strcmp(TrainFiles(i).name,.)|strcmp(TrainFiles(i).name,
6、Thumbs.db) Train_Number = Train_Number + 1; % Number of all images in the training database endend% Construction of 2D matrix from 1D image vectorsT = ;for i = 1 : Train_Number % I have chosen the name of each image in databases as a corresponding % number. However, it is not mandatory! str = int2st
7、r(i); str = strcat(,str,.jpg); str = strcat(TrainDatabasePath,str); img = imread(str); img = rgb2gray(img); irow icol = size(img); temp = reshape(img,irow*icol,1); % Reshaping 2D images into 1D image vectors T = T temp; % T grows after each turn end-EigenfaceCore.mfunction m, A, Eigenfaces = Eigenfa
8、ceCore(T)% Use Principle Component Analysis (PCA) to determine the most% discriminating features between images of faces.% Description: This function gets a 2D matrix, containing all training image vectors% and returns 3 outputs which are extracted from training database.% Argument: T - A 2D matrix,
9、 containing all 1D image vectors.% Suppose all P images in the training database% have the same size of MxN. So the length of 1D% column vectors is M*N and T will be a MNxP 2D matrix.% Returns: m - (M*Nx1) Mean of the training database% Eigenfaces - (M*Nx(P-1) Eigen vectors of the covariance matrix
10、of the training database% A - (M*NxP) Matrix of centered image vectors% See also: EIG% Original version by Amir Hossein Omidvarnia, October 2007% Email: aomidvarece.ut.ac.ir % Calculating the mean imagem = mean(T,2); % Computing the average face image m = (1/P)*sum(Tjs) (j = 1 : P)Train_Number = siz
11、e(T,2);% Calculating the deviation of each image from mean imageA = ; for i = 1 : Train_Number temp = double(T(:,i) - m; % Computing the difference image for each image in the training set Ai = Ti - m A = A temp; % Merging all centered imagesend% Snapshot method of Eigenface methos% We know from lin
12、ear algebra theory that for a PxQ matrix, the maximum% number of non-zero eigenvalues that the matrix can have is min(P-1,Q-1).% Since the number of training images (P) is usually less than the number% of pixels (M*N), the most non-zero eigenvalues that can be found are equal% to P-1. So we can calc
13、ulate eigenvalues of A*A (a PxP matrix) instead of% A*A (a M*NxM*N matrix). It is clear that the dimensions of A*A is much% larger that A*A. So the dimensionality will decrease.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 bot
14、h L=A*A and C=A*A.% Sorting and eliminating eigenvalues% All eigenvalues of matrix L are sorted and those who are less than a% specified threshold, are eliminated. So the number of non-zero% eigenvectors may be less than (P-1).L_eig_vec = ;for i = 1 : size(V,2) if( D(i,i)1 ) L_eig_vec = L_eig_vec V(
15、:,i); endend% Calculating the eigenvectors of covariance matrix C% Eigenvectors of covariance matrix C (or so-called Eigenfaces)% can be recovered from Ls eiegnvectors.Eigenfaces = A * L_eig_vec; % A: centered image vectors-Recognition.mfunction OutputName = Recognition(TestImage, m, A, Eigenfaces)%
16、 Recognizing step.% Description: This function compares two faces by projecting the images into facespace and% measuring the Euclidean distance between them.% Argument: TestImage - Path of the input test image% m - (M*Nx1) Mean of the training% database, which is output of EigenfaceCore function.% E
17、igenfaces - (M*Nx(P-1) Eigen vectors of the% covariance matrix of the training% database, which is output of EigenfaceCore function.% A - (M*NxP) Matrix of centered image% vectors, which is output of EigenfaceCore function.% Returns: OutputName - Name of the recognized image in the training database
18、.% See also: RESHAPE, STRCAT% Original version by Amir Hossein Omidvarnia, October 2007% Email: aomidvarece.ut.ac.ir % Projecting centered image vectors into facespace% All centered images are projected into facespace by multiplying in% Eigenface basiss. Projected vector of each face will be its cor
19、responding% feature vector.ProjectedImages = ;Train_Number = size(Eigenfaces,2);for i = 1 : Train_Number temp = Eigenfaces*A(:,i); % Projection of centered images into facespace ProjectedImages = ProjectedImages temp;end% Extracting the PCA features from test imageInputImage = imread(TestImage);temp
20、 = InputImage(:,:,1);irow icol = size(temp);InImage = reshape(temp,irow*icol,1);Difference = double(InImage)-m; % Centered test imageProjectedTestImage = Eigenfaces*Difference; % Test image feature vector% Calculating Euclidean distances% Euclidean distances between the projected test image and the
21、projection% of all centered training images are calculated. Test image is% supposed to have minimum distance with its corresponding image in the% training database.Euc_dist = ;for i = 1 : Train_Number q = ProjectedImages(:,i); temp = ( norm( ProjectedTestImage - q ) )2; Euc_dist = Euc_dist temp;endE
22、uc_dist_min , Recognized_index = min(Euc_dist);OutputName = strcat(int2str(Recognized_index),.jpg);-example.m% A sample script, which shows the usage of functions, included in% PCA-based face recognition system (Eigenface method)% See also: CREATEDATABASE, EIGENFACECORE, RECOGNITION% Original version by Amir Hossein Omidvarnia, October 2007% Email: aomidvarece.ut.ac.ir clear allclcclose all% You can customize and fix initial directory pathsTrainDatabasePath = uigetdir(D:MATLAB
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 護(hù)理知識(shí)之健康教育
- 保險(xiǎn)客戶經(jīng)理制度
- 企業(yè)消防包保制度
- 交通過(guò)道制度
- 嚴(yán)格落實(shí)雙報(bào)告制度
- 2026年玉溪市生態(tài)環(huán)境局華寧分局編外辦公輔助(內(nèi)勤相關(guān))人員公開招聘?jìng)淇碱}庫(kù)完整參考答案詳解
- 護(hù)理健康科普營(yíng)養(yǎng)
- 2025至2030中國(guó)智能網(wǎng)聯(lián)汽車數(shù)據(jù)合規(guī)治理法律框架及企業(yè)應(yīng)對(duì)策略研究報(bào)告
- 遠(yuǎn)程醫(yī)療與用藥護(hù)理
- 東莞市公安局水上分局麻涌水上派出所2025年第1批警務(wù)輔助人員招聘?jìng)淇碱}庫(kù)及1套完整答案詳解
- 頸椎間盤突出癥的治療和護(hù)理講課件
- 大學(xué)之道故事解讀
- 外立面改造項(xiàng)目腳手架施工專項(xiàng)方案
- 2023年全國(guó)職業(yè)院校技能大賽-生產(chǎn)事故應(yīng)急救援賽項(xiàng)規(guī)程
- 廣東省建筑工程混凝土結(jié)構(gòu)抗震性能設(shè)計(jì)規(guī)程
- 切削液回收及處理合同模板
- 2023年移動(dòng)綜合網(wǎng)絡(luò)資源管理系統(tǒng)技術(shù)規(guī)范功能分冊(cè)
- 幼兒園大班班本課程-邂逅水墨課件
- 計(jì)算機(jī)輔助翻譯智慧樹知到期末考試答案章節(jié)答案2024年西華大學(xué)
- HGT 2520-2023 工業(yè)亞磷酸 (正式版)
- 閻良現(xiàn)代設(shè)施花卉產(chǎn)業(yè)園規(guī)劃設(shè)計(jì)方案
評(píng)論
0/150
提交評(píng)論