%訓練
%lx=x'*x
clear;
clc;
train_path='..\data\trainingset\';
phi=zeros(64*64,20);
for i=1:20
path=strcat(train_path,num2str(i),'.bmp');
image=imread(path);
image=imresize(image,[64,64]);
phi(:,i)=double(reshape(image,1,)');
end;
%mean
mean_phi=mean(phi,2);
mean_face=reshape(mean_phi,64,64);
image_mean=mat2gray(mean_face);
imwrite(image_mean,'meanface.bmp','bmp');
%demean
for i=1:19
x(:,i)=phi(:,i)-mean_phi;
endlx=x'*x;
tic;
[eigenvector,eigenvalue]=eigs(lx,19);
toc;
%normalization
for i=1:19
%k-l變換
ul(:,i)=x*eigenvector(:,i)/sqrt(eigenvalue(i,i));
end%display eigenface
for i=1:19
eigenface=reshape(ul(:,i),[64,64]);
figure(i);
imshow(mat2gray(eigenface));
end
得到的均值影象mean_face: PCA檢測人臉的簡單示例 matlab實現
pca檢測人臉的簡單示例,matlab r2009b上實現 訓練 訓練用的20副人臉 訓練 lx x x clear clc train path data trainingset phi zeros 64 64,20 for i 1 20 path strcat train path,num2st...
人臉檢測原理及示例 OpenCV Python
opencv是intel開源計算機視覺庫 computerversion 它由一系列c函式和少量 c 類構成,實現了影象處理和計算機視覺方面的很多通用演算法。opencv 擁有包括 300 多個c函式的跨平台的中 高層 api。它不依賴於其它的外部庫 儘管也可以使用某些外部庫。opencv 對非商業...
python 簡單實現人臉檢測
目錄 一 準備 二 實現 三 結果 四 python 3.7版本 其他版本也可以 matplotlib 畫圖工具,安裝方式 pip install matplotlibpil 影象處理 安裝方式 pip install pillow client id 為官網獲取的ak,client secret ...