日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > pytorch >内容正文

pytorch

利用MATLAB实现人脸识别GUI程序设计

發布時間:2024/8/1 pytorch 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 利用MATLAB实现人脸识别GUI程序设计 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

利用MATLAB實現人臉識別GUI程序設計

%% 人臉識別 clc;clear;close all; %% 加載文件路徑 addpath(genpath('F:\課程\模式識別\')); %% --------- 訓練集圖像文件------- Train_file_path = 'F:\課程\模式識別\實驗四數據\TrainDatabase\ORL\'; Train_data_list = dir(strcat(Train_file_path)); %------訓練集圖像元胞分配內存-----% Train_image=cell(size(Train_data_list,1),8); Train_image_line=cell(8*size(Train_data_list,1),1); %--------遍歷得到訓練集圖像-------% k=1; for i=3:size(Train_data_list,1)img_file=Train_data_list(i).name;% 獲取文件夾名稱Train_img_list=dir(strcat(Train_file_path,img_file,'\*.jpg'));% 獲取文件夾下圖像img_num = length(Train_img_list);%獲取圖像總數量for j = 1:img_num %逐一讀取圖像Train_image_name = Train_img_list(j).name;% 圖像名image = imread(strcat(Train_file_path,img_file,'\',Train_image_name));Train_image{i,j}=image; % 存入元胞數組Train_image_line{k,1}=image; % 存入元胞數組k=k+1;fprintf('%d %d %s\n',i,j,strcat(Train_file_path,img_file,'\',Train_image_name));% 顯示正在處理的圖像名end end %---------刪除空余兩行---------% %---小括號刪除元素,大括號置空--% Train_image(1,:)=[]; Train_image(2,:)=[]; Train_image_line(321:336)=[];%% 圖像寬92,高112,8bit All_Train_img=zeros(8*(size(Train_data_list,1)-2),112*92); % 建立所有訓練集圖像矩陣 % for i=1:320 % Temp=Train_image_line{i,1}; % Temp=Temp';% 先轉置 % Temp=Temp(:);% 再行向化 % All_Train_img(i,:)=Temp; % end for i=1:320Temp=Train_image_line{i,1};Temp=Temp(:);Temp=Temp';All_Train_img(i,:)=Temp; end % 求所有圖片各像素平均值(平均臉) image_mean=mean(All_Train_img,1); % 求所有圖片像素點位-平均值(中心化) all_img_diff=zeros(320,92*112); for i=1:320all_img_diff(i,:)=All_Train_img(i,:)-image_mean; end % 求協方差矩陣 sigma_mat=all_img_diff*all_img_diff'; % 求特征值和特征向量 [U , D]=eig(sigma_mat);%為什么這里是已經排序好的特征值 % 對特征值進行排序 D_diag=diag(D); %取對角線元素 [D_sort,index]=sort(D_diag,'descend'); %以降序排序 Sum_D = sum(D_sort);%對所有特征值求和 temp = 0; for i = 1:size(All_Train_img,1)temp = temp + D_sort(i,1);m = i;if (temp/Sum_D >0.95)%特征值占比95%break;end end U1 = U(:,index);%按照特征值的索引排序特征向量 New_U = U1(:,1:m);% 選取95%對應的特征向量組成矩陣 % 特征臉 Feature_face=all_img_diff'*New_U; % 特征臉投影 Pn=All_Train_img*Feature_face; save('F:\課程\模式識別\Feature_face.mat','Feature_face'); save('F:\課程\模式識別\Pn.mat','Pn') save('F:\課程\模式識別\image_mean.mat','image_mean') function varargout = exp_4_GUI(varargin) % EXP_4_GUI MATLAB code for exp_4_GUI.fig % EXP_4_GUI, by itself, creates a new EXP_4_GUI or raises the existing % singleton*. % % H = EXP_4_GUI returns the handle to a new EXP_4_GUI or the handle to % the existing singleton*. % % EXP_4_GUI('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in EXP_4_GUI.M with the given input arguments. % % EXP_4_GUI('Property','Value',...) creates a new EXP_4_GUI or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before exp_4_GUI_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to exp_4_GUI_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 exp_4_GUI% Last Modified by GUIDE v2.5 10-Dec-2020 18:01:46% Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @exp_4_GUI_OpeningFcn, ...'gui_OutputFcn', @exp_4_GUI_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback', []); if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1}); endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); elsegui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT% --- Executes just before exp_4_GUI is made visible. function exp_4_GUI_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 exp_4_GUI (see VARARGIN)% Choose default command line output for exp_4_GUI handles.output = hObject;% Update handles structure guidata(hObject, handles);% UIWAIT makes exp_4_GUI wait for user response (see UIRESUME) % uiwait(handles.figure1);% --- Outputs from this function are returned to the command line. function varargout = exp_4_GUI_OutputFcn(hObject, eventdata, handles) 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) addpath(genpath('F:\課程\模式識別\實驗四數據\TestDatabase\')); [FileName,PathName] = uigetfile('F:\課程\模式識別\實驗四數據\TestDatabase\*.jpg','請選擇一幅圖像'); [picture_in_one,map]=imread(FileName);%imread函數實現圖像導入 axes(handles.axes1); %用axes命令設定當前操作的坐標軸 imshow(picture_in_one); title('測試人臉'); % handles.axes1=picture_in_one; handles.picture_in_one=picture_in_one; guidata(hObject,handles);%使用guidata函數保存該句柄結構% --- 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) % 通過句柄得到圖片 %picture=handles.axes1;% uint8的圖片 picture=handles.picture_in_one;% uint8的圖片 picture_line = double(picture(:)); % New_U=importdata('F:\課程\模式識別\New_U.mat'); Feature_face=importdata('F:\課程\模式識別\Feature_face.mat'); Pn=importdata('F:\課程\模式識別\Pn.mat'); P=(picture_line)' * Feature_face; % 最小距離法,尋找和待識別圖片最為接近的訓練圖片 dist=zeros(size(Pn,1),1); for k = 1:size(Pn,1)temp=(P - Pn(k,:)).^2;dist(k)= sqrt(sum(temp(:))); %歐氏距離 end [~,id]=sort(dist,'ascend'); %篩選出距離前三小的 % --------- 訓練集圖像文件------- Train_file_path = 'F:\課程\模式識別\實驗四數據\TrainDatabase\ORL\'; Train_data_list = dir(strcat(Train_file_path)); %------訓練集圖像元胞分配內存-----% Train_image=cell(size(Train_data_list,1),8); Train_image_line=cell(8*size(Train_data_list,1),1); %--------遍歷得到訓練集圖像-------% k=1; for i=3:size(Train_data_list,1)img_file=Train_data_list(i).name;% 獲取文件夾名稱Train_img_list=dir(strcat(Train_file_path,img_file,'\*.jpg'));% 獲取文件夾下圖像img_num = length(Train_img_list);%獲取圖像總數量for j = 1:img_num %逐一讀取圖像Train_image_name = Train_img_list(j).name;% 圖像名image = imread(strcat(Train_file_path,img_file,'\',Train_image_name));Train_image{i,j}=image; % 存入元胞數組Train_image_line{k,1}=image; % 存入元胞數組k=k+1;fprintf('%d %d %s\n',i,j,strcat(Train_file_path,img_file,'\',Train_image_name));% 顯示正在處理的圖像名end end %---------刪除空余兩行---------% %---小括號刪除元素,大括號置空--% Train_image_line(321:336)=[]; X1=Train_image_line{id(1,1),:}; X2=Train_image_line{id(2,1),:}; X3=Train_image_line{id(3,1),:}; axes( handles.axes2 ) imshow(X1); axes( handles.axes3 ) imshow(X2); axes( handles.axes4 ) imshow(X3);% --- Executes during object creation, after setting all properties. % 測試圖片 function axes1_CreateFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called set(gca,'XColor',get(gca,'Color')) ;% 這兩行代碼功能:將坐標軸和坐標刻度轉為白色 set(gca,'YColor',get(gca,'Color'));set(gca,'XTickLabel',[]); % 這兩行代碼功能:去除坐標刻度 set(gca,'YTickLabel',[]); % Hint: place code in OpeningFcn to populate axes1% 識別圖片 % --- Executes during object creation, after setting all properties. function axes2_CreateFcn(hObject, eventdata, handles) % hObject handle to axes2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called set(gca,'XColor',get(gca,'Color')) ;% 這兩行代碼功能:將坐標軸和坐標刻度轉為白色 set(gca,'YColor',get(gca,'Color'));set(gca,'XTickLabel',[]); % 這兩行代碼功能:去除坐標刻度 set(gca,'YTickLabel',[]); % Hint: place code in OpeningFcn to populate axes2% 識別圖片 % --- 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 set(gca,'XColor',get(gca,'Color')) ;% 這兩行代碼功能:將坐標軸和坐標刻度轉為白色 set(gca,'YColor',get(gca,'Color'));set(gca,'XTickLabel',[]); % 這兩行代碼功能:去除坐標刻度 set(gca,'YTickLabel',[]); % Hint: place code in OpeningFcn to populate axes3% 識別圖片 % --- Executes during object creation, after setting all properties. function axes4_CreateFcn(hObject, eventdata, handles) % hObject handle to axes4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called set(gca,'XColor',get(gca,'Color')) ;% 這兩行代碼功能:將坐標軸和坐標刻度轉為白色 set(gca,'YColor',get(gca,'Color'));set(gca,'XTickLabel',[]); % 這兩行代碼功能:去除坐標刻度 set(gca,'YTickLabel',[]); % Hint: place code in OpeningFcn to populate axes4





總結

以上是生活随笔為你收集整理的利用MATLAB实现人脸识别GUI程序设计的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产猛男猛女超爽免费视频 | 久久精品国产视频 | 青青草综合在线 | 成人网在线视频 | 香蕉国产在线视频 | 亚洲成人高清 | 综合视频一区二区 | 国产欧美日韩激情 | 欧美一级片a | 特一级黄色片 | 日本美女操 | 精品国产大片大片大片 | 欧美二级片 | 蜜桃av网站 | 国产丝袜网站 | 青青草一区二区 | 亚洲精品一区二区三区在线观看 | 久久天天东北熟女毛茸茸 | 精品欧美乱码久久久久久1区2区 | 国产精品羞羞答答在线 | 欧美精品久久久久久久 | 亚洲美女毛片 | 爱情岛亚洲品质自拍极速福利网站 | 中文精品无码中文字幕无码专区 | 99热3| 麻豆国产网站 | 先锋影音一区二区三区 | 免费看60分钟黄视频 | 人妻熟女一区二区三区 | www欧美日韩 | 日韩网站在线 | 色网站入口| 色噜噜狠狠一区二区三区牛牛影视 | 天天干天天拍 | 欧美精品在线第一页 | 午夜久久一区 | 熟睡人妻被讨厌的公侵犯 | 中文字幕乱码免费 | 最新av网址在线观看 | 国产在线观看免费av | 日韩电影一区二区三区四区 | 亚洲综合色在线 | 最新免费黄色网址 | 五月婷婷色丁香 | 窝窝视频在线观看 | 国产一区二区 | 国产精品一区二区在线播放 | 中文字幕在线三区 | 国产精品VideoSex性欧美 | 九九综合九九 | 水果视频污| 免费在线观看网址 | 美女av在线免费观看 | www.黄色网| 亚欧日韩av| 97色伦图片| 亚洲精品无码久久久久久久 | 中国字幕一色哟哟 | 韩国女主播一区 | 久久久999久久久 | 婷婷色亚洲 | 最新地址在线观看 | 上床视频在线观看 | 最近中文字幕免费视频 | 色综合久久综合 | 波多野结衣在线播放视频 | 美女在线网站 | sm国产在线调教视频 | 欧美视频第一区 | 精品国产乱码久久久久久1区二区 | 色汉综合 | 天天躁狠狠躁 | 九九热精品免费视频 | 亚洲av日韩av不卡在线观看 | 亚洲视频第一页 | 91麻豆精品国产91久久久无需广告 | 免费在线看视频 | 少妇高潮一区二区三区99刮毛 | 三级网站在线 | 国产精品国产馆在线真实露脸 | 草草影院第一页yycc.com | 亚洲精品动漫在线观看 | 快色污| 欧美女同在线 | 国产又黄又湿 | 摸丰满大乳奶水www免费 | 桃色成人 | 蜜桃精品视频在线 | 亚洲欧美强伦一区二区 | 久久作爱视频 | 中文字幕一区二区三区电影 | 国产二区视频在线观看 | 毛片在线免费观看网站 | 亚洲欧美一区二区三区在线观看 | 精品国产无码在线 | 亚洲逼院 | 欧美精品18videosex性欧美 | 女性向av免费网站 | 永久免费未满 |