【正文】
read(str)。%axes()。%imshow(im)。% 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 TrainDatabasePath 。global TestDatabasePath。global T。T = CreateDatabase(TrainDatabasePath)。%[m V_PCA V_Fisher ProjectedImages_Fisher] = FisherfaceCore(T)。% Executes on button press in pushbutton5.function pushbutton9_Callback(hObject, eventdata, handles)% hObject handle to pushbutton5 (see GCBO)22% eventdata reserved to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global im。[filename,pathname]=uigetfile({39。*.jpg39。39。*.bmp39。},39。選擇測試圖片...39。)。str=[pathname filename]。im=imread(str)。axes()。imshow(im)。% 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)%T = CreateDatabase(TrainDatabasePath)。global T。global im。global TrainDatabasePath 。[m V_PCA V_Fisher ProjectedImages_Fisher] = FisherfaceCore(T)。OutputName = Recognition(im, m, V_PCA, V_Fisher, ProjectedImages_Fisher)。SelectedImage = strcat(TrainDatabasePath,39。\39。,OutputName)。SelectedImage = imread(SelectedImage)。axes()。imshow(SelectedImage)。%title(39。Equivalent Image39。)。23% Executes on button press in pushbutton7.function pushbutton7_Callback(hObject, eventdata, handles)% hObject handle to pushbutton7 (see GCBO)% eventdata reserved to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)clear all。clcclose(gcf)。執(zhí)行上述代碼后效果如下圖所示:如上圖所示,當(dāng)我們選擇待識別照片后,點擊圖像匹配,可以快速匹配到與該測試圖像特征信息相符合的訓(xùn)練庫中的人臉圖像,效果圖如下:24結(jié)論圖像是人類日常生活和工作中獲取和交換信息的重要來源,人臉圖像的識別技術(shù)已經(jīng)應(yīng)用到了生活中的方方面面?;?Matlab 的人臉識別系統(tǒng)的仿真的研究很有意義。目前到處可見攝像頭,監(jiān)控錄像,這些的普及,使人臉識別具有重大商業(yè)價值。在本文圖像處理時,用到如灰度變化、格式轉(zhuǎn)換和濾波銳化等基本方法來實現(xiàn)圖像處理。通過對一些算法,方法的比較,選擇了比較合理的方法進(jìn)行圖像預(yù)處理。在比較人臉識別的幾種方法后,我們最終選擇了通過人臉圖像的直方圖差值進(jìn)行比較從而實現(xiàn)了人臉識別。事實證明,這種方法對人臉能更好的分類,但其對于人臉圖像的像素質(zhì)量等要求較高,而我們只是采用 Orl 標(biāo)準(zhǔn)的人臉數(shù)據(jù)庫中的圖像完成測試,因此可以得到較高的識別率。在對大量參考文獻(xiàn)資料的閱讀的基礎(chǔ)上,本設(shè)計對基于 Matlab 的人臉識別這一技術(shù)做了詳細(xì)的綜述。然而,在現(xiàn)實生活中由于受到采集距離、光線明暗、人臉角度等因素的影25響,采集到的人臉圖像與人臉庫進(jìn)行匹配識別時,識別率很難可以達(dá)到測試要求。因此,在實際應(yīng)用時還要根據(jù)具體情況進(jìn)行分析。本次基于 Matlab 的人臉識別系統(tǒng)的仿真設(shè)計到這里就結(jié)束了,在設(shè)計過程中,雖然對幾種方法進(jìn)行了對比選擇,但是還是有很多不足,可能很多問題想的不夠充分,設(shè)計中有些數(shù)據(jù)可能會有偏差,因此在今后的學(xué)習(xí)生活中要更加努力,不斷地提高自己的科學(xué)文化水平和各方面素質(zhì)。致謝在佳木斯大學(xué)的學(xué)習(xí)生活即將結(jié)束,現(xiàn)在想想對母校還是有很多留戀。在做畢業(yè)設(shè)計的這段時間里,我的老師、同學(xué)們對我給予了非常多的幫助,在這里,謹(jǐn)向他們致以最真誠的感謝!尤為感謝的,是我的導(dǎo)師周經(jīng)國老師。周老師學(xué)識淵博,思想敏銳,洞察力超強(qiáng),治學(xué)態(tài)度嚴(yán)謹(jǐn),平易近人。在我做畢業(yè)設(shè)計的這段時間里,常常會被一些難題所困擾,弄得焦頭爛額。是周老師教導(dǎo)我,激勵我,對我給予了細(xì)心地指導(dǎo)和悉心的教誨,讓我擺脫困境,重新找回自信心。同時,我也要感謝教導(dǎo)過我的所有老師。是你們毫無保留的指導(dǎo)和細(xì)致耐心的幫助,我才能順利完成這次畢業(yè)設(shè)計。最后,我還要感謝身邊的朋友和同學(xué),在大學(xué)生活的四年里,我在你們的陪伴中成長,謝謝你們在做畢業(yè)設(shè)計這段日子里給予我的幫助。真心的感謝所有在生活、學(xué)習(xí)中幫助過我的良師益友,謝謝你們!26參考文獻(xiàn)[1] 何東健,耿楠,(第二版).西安電子科技大學(xué)出版社,:1325[2] MATLAB ,:1218[3] 陳書海,2022[4] :電子工業(yè)出版社,1997[5] 何東健,1998[6] ,1999[7] :圖像處理和分析(上).清華大學(xué)出版社,1999[8] :圖像分析(中).清華大學(xué)出版社,2022[9] :圖像理解與計算機(jī)視覺(下).清華大學(xué)出版社,2022[10] 朱秀昌,劉峰,2022[11] [M].北京:電子工業(yè)出版社,2022[12] 數(shù)字圖像處理[M].北京:機(jī)械工業(yè)出版社,202227[13] 徐倩,鄧偉. 一種融合兩種主成分分析的人臉識別方法[J].計算機(jī)學(xué)報,2022[14] 郭文強(qiáng),2022[15] ,1999[16] MATLAB ,2022[17] Wangmeng Zuo,Kuanquan Wang,David Zhang,Hongzhi Zhang. Combination of two novel LDAbased methods for face recognition[C].Proceedings of the IEEE,2022[18] [J].計算機(jī)學(xué)報,2022[19] The User GUIdes[DB/OL].2022附錄 1 人臉識別的 MATLAB 源程序(1)色彩空間轉(zhuǎn)換:function [r,g]=rgb_RGB(Ori_Face)R=Ori_Face(:,:,1)。G=Ori_Face(:,:,2)。B=Ori_Face(:,:,3)。R1=im2double(R)。 % 將 uint8 型轉(zhuǎn)換成 double 型G1=im2double(G)。B1=im2double(B)。RGB=R1+G1+B1。row=size(Ori_Face,1)。 % 行像素column=size(Ori_Face,2)。 % 列像素for i=1:row28for j=1:column rr(i,j)=R1(i,j)/RGB(i,j)。 gg(i,j)=G1(i,j)/RGB(i,j)。endendrrr=mean(rr)。r=mean(rrr)。ggg=mean(gg)。g=mean(ggg)。(2)找區(qū)域邊界function [left, right, up, down] = bianjie(A)[m n] = size(A)。left = 1。right = 1。up = 1。down = 1。for j=1:n, for i=1:m, if (A(i,j) ~= 0) left = j。 break。 end。 end。 if (left ~= 1) break。 end。end。for j=n:1:1,for i=1:m,if (A(i,j) ~= 0) right = j。 break。29end。end。if (right ~= 1) break。 end。end。for i=1:m,for j=1:n, if (A(i,j) ~= 0) up = i。 break。 end。end。 if (up ~= 1) break。 end。end。for i=m:1:1, for j=1:n, if (A(i,j) ~= 0) down = i。 break。 end。 end。 if (down ~= 1) break。 end。end。(3)模板匹配function [ccorr, mfit, RectCoord] = mobanpipei(mult, frontalmodel,ly,wx,cx, cy, angle)frontalmodel=rgb2gray(frontalmodel)。 30model_rot = imresize(frontalmodel,[ly wx],39。bilinear39。)。 % 調(diào)整模板大小model_rot = imrotate(model_rot,angle,39。bilinear39。)。 % 旋轉(zhuǎn)模板[l,r,u,d] = bianjie(model_rot)。 % 求邊界坐標(biāo)bwmodel_rot=imcrop(model_rot,[l u (rl) (du