基于matlab的人脸识别源代码

上传人:回**** 文档编号:124162445 上传时间:2022-07-24 格式:DOC 页数:14 大小:37.50KB
收藏 版权申诉 举报 下载
基于matlab的人脸识别源代码_第1页
第1页 / 共14页
基于matlab的人脸识别源代码_第2页
第2页 / 共14页
基于matlab的人脸识别源代码_第3页
第3页 / 共14页
资源描述:

《基于matlab的人脸识别源代码》由会员分享,可在线阅读,更多相关《基于matlab的人脸识别源代码(14页珍藏版)》请在装配图网上搜索。

1、function varargout = FR_Processed_histogram(varargin)%这种算法是基于直方图解决旳措施%The histogram of image is calculated and then bin formation is done on the%basis of mean of successive graylevels frequencies. The training is done on odd images of 40 subjects (200 images out of 400 images) %The results of the im

2、plemented algorithm is 99.75 (recognition fails on image number 4 of subject 17)gui_Singleton = 1;gui_State = struct(gui_Name, mfilename, . gui_Singleton, gui_Singleton, . gui_OpeningFcn, FR_Processed_histogram_OpeningFcn, . gui_OutputFcn, FR_Processed_histogram_OutputFcn, . gui_LayoutFcn, , . gui_C

3、allback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);end if nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT %-% - Executes just before FR_Processed_histogram is made visi

4、ble.function FR_Processed_histogram_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 co

5、mmand line arguments to FR_Processed_histogram (see VARARGIN) % Choose default command line output for FR_Processed_histogramhandles.output = hObject; % Update handles structureguidata(hObject, handles); % UIWAIT makes FR_Processed_histogram wait for user response (see UIRESUME)% uiwait(handles.figu

6、re1);global total_sub train_img sub_img max_hist_level bin_num form_bin_num; total_sub = 40;train_img = 200;sub_img = 10;max_hist_level = 256;bin_num = 9;form_bin_num = 29;%-% - Outputs from this function are returned to the command line.function varargout = FR_Processed_histogram_OutputFcn(hObject,

7、 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 structurevarar

8、gout1 = handles.output; %-% - Executes on button press in train_button. function train_button_Callback(hObject, eventdata, handles)% hObject handle to train_button (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)

9、 global train_processed_bin;global total_sub train_img sub_img max_hist_level bin_num form_bin_num; train_processed_bin(form_bin_num,train_img) = 0;K = 1;train_hist_img = zeros(max_hist_level, train_img); for Z=1:1:total_sub for X=1:2:sub_img %train on odd number of images of each subject I = imread

10、( strcat(ORLS,int2str(Z),int2str(X),.bmp) ); rows cols = size(I); for i=1:1:rows for j=1:1:cols if( I(i,j) = 0 ) train_hist_img(max_hist_level, K) = train_hist_img(max_hist_level, K) + 1; else train_hist_img(I(i,j), K) = train_hist_img(I(i,j), K) + 1; end end end K = K + 1; end end r c = size(train_

11、hist_img);sum = 0;for i=1:1:c K = 1; for j=1:1:r if( (mod(j,bin_num) = 0 ) sum = sum + train_hist_img(j,i); train_processed_bin(K,i) = sum/bin_num; K = K + 1; sum = 0; else sum = sum + train_hist_img(j,i); end end train_processed_bin(K,i) = sum/bin_num;end display (Training Done)save train train_pro

12、cessed_bin; %-% - Executes on button press in Testing_button. function Testing_button_Callback(hObject, eventdata, handles)% hObject handle to Testing_button (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global

13、 train_img max_hist_level bin_num form_bin_num;global train_processed_bin;global filename pathname I load traintest_hist_img(max_hist_level) = 0;test_processed_bin(form_bin_num) = 0; rows cols = size(I); for i=1:1:rows for j=1:1:cols if( I(i,j) = 0 ) test_hist_img(max_hist_level) = test_hist_img(max

14、_hist_level) + 1; else test_hist_img(I(i,j) = test_hist_img(I(i,j) + 1; end end end r c = size(test_hist_img); sum = 0; K = 1; for j=1:1:c if( (mod(j,bin_num) = 0 ) sum = sum + test_hist_img(j); test_processed_bin(K) = sum/bin_num; K = K + 1; sum = 0; else sum = sum + test_hist_img(j); end end test_

15、processed_bin(K) = sum/bin_num; sum = 0;K = 1; for y=1:1:train_img for z=1:1:form_bin_num sum = sum + abs( test_processed_bin(z) - train_processed_bin(z,y) ); end img_bin_hist_sum(K,1) = sum; sum = 0; K = K + 1; end temp M = min(img_bin_hist_sum); M = ceil(M/5); getString_start=strfind(pathname,S);

16、getString_start=getString_start(end)+1; getString_end=strfind(pathname,); getString_end=getString_end(end)-1; subjectindex=str2num(pathname(getString_start:getString_end); if (subjectindex = M) axes (handles.axes3) %image no: 5 is shown for visualization purpose imshow(imread(STRCAT(ORLS,num2str(M),

17、5.bmp) msgbox ( Correctly Recognized); else display ( Error= Testing Image of Subject num2str(subjectindex) matches with the image of subject num2str(M) axes (handles.axes3) %image no: 5 is shown for visualization purpose imshow(imread(STRCAT(ORLS,num2str(M),5.bmp) msgbox ( Incorrectly Recognized);

18、end display(Testing Done)%-function box_Callback(hObject, eventdata, handles)% hObject handle to box (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 box as text%

19、str2double(get(hObject,String) returns contents of box as a double %-% - Executes during object creation, after setting all properties.function box_CreateFcn(hObject, eventdata, handles)% hObject handle to box (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empt

20、y - 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%-% - Executes on button pre

21、ss in Input_Image_button.function Input_Image_button_Callback(hObject, eventdata, handles)% hObject handle to Input_Image_button (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global filename pathname Ifilename,

22、 pathname = uigetfile(*.bmp, Test Image);axes(handles.axes1)imgpath=STRCAT(pathname,filename); I = imread(imgpath);imshow(I) %-% - Executes during object creation, after setting all properties.function axes3_CreateFcn(hObject, eventdata, handles)% hObject handle to axes3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: place code in OpeningFcn to populate axes3 %Programmed by Usman Qayyum

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!