人脸识别源码分享文档格式.docx
- 文档编号:13323495
- 上传时间:2022-10-09
- 格式:DOCX
- 页数:8
- 大小:17.41KB
人脸识别源码分享文档格式.docx
《人脸识别源码分享文档格式.docx》由会员分享,可在线阅读,更多相关《人脸识别源码分享文档格式.docx(8页珍藏版)》请在冰豆网上搜索。
运行“eigenfacecore"
函数产生基础人脸图像空间;
5.
运行“识别”功能得到参照组人脸图像数据库中等价图像的名称。
为了您的方便,我准备了实际测试和参照组人脸图像数据库,其中部分来自“Face94”埃塞克斯人脸数据库。
你只需要复制上述功能,指定实际测试和参照组人脸图像数据库的路径(比如Matlab工作路径)。
然后按照对话框提示输入图片编号,实例将运行实现。
希望您能喜欢它!
引用:
[1]P.N.Belhumeur,J.Hespanha,andD.J.Kriegman.Eigenfacesvs.Fisherfaces:
Recognition
usingclassspecificlinearprojection.InECCV
(1),pages45--58,1996.
[2]Availableat:
以下为源代码文件:
----------------------------------------------------------------------------------------------------------------------
CreateDatabase.m
functionT=CreateDatabase(TrainDatabasePath)
%Alignasetoffaceimages(thetrainingsetT1,T2,...,TM)
%
%Description:
Thisfunctionreshapesall2Dimagesofthetrainingdatabase
%into1Dcolumnvectors.Then,itputsthese1Dcolumnvectorsinarowto
%construct2Dmatrix'
T'
.
%
%Argument:
TrainDatabasePath
-Pathofthetrainingdatabase
%Returns:
T
-A2Dmatrix,containingall1Dimagevectors.
%
SupposeallPimagesinthetrainingdatabase
havethesamesizeofMxN.Sothelengthof1D
columnvectorsisMNand'
willbeaMNxP2Dmatrix.
%Seealso:
STRCMP,STRCAT,RESHAPE
%OriginalversionbyAmirHosseinOmidvarnia,October2007
Email:
***************.ac.ir
%%%%%%%%%%%%%%%%%%%%%%%%
TrainFiles=dir(TrainDatabasePath);
Train_Number=0;
fori=1:
size(Train)
ifnot(strcmp(TrainFiles(i).name,'
.'
)|strcmp(TrainFiles(i).name,'
..'
Thumbs.db'
))
Train_Number=Train_Number+1;
%Numberofallimagesinthetrainingdatabase
end
end
%%%%%%%%%%%%%%%%%%%%%%%%Constructionof2Dmatrixfrom1Dimagevectors
T=[];
fori=1:
Train_Number
%Ihavechosenthenameofeachimageindatabasesasacorresponding
%number.However,itisnotmandatory!
str=int2str(i);
str=strcat('
\'
str,'
.jpg'
);
str=strcat(TrainDatabasePath,str);
img=imread(str);
img=rgb2gray(img);
[irowicol]=size(img);
temp=reshape(img'
irow*icol,1);
%Reshaping2Dimagesinto1Dimagevectors
T=[Ttemp];
%'
growsaftereachturn
---------------------------------------------------------------------------------------------------------------------------
EigenfaceCore.m
function[m,A,Eigenfaces]=EigenfaceCore(T)
%UsePrincipleComponentAnalysis(PCA)todeterminethemost
%discriminatingfeaturesbetweenimagesoffaces.
Thisfunctiongetsa2Dmatrix,containingalltrainingimagevectors
%andreturns3outputswhichareextractedfromtrainingdatabase.
SupposeallPimagesinthetrainingdatabase
havethesamesizeofMxN.Sothelengthof1D
columnvectorsisM*Nand'
%
m
-(M*Nx1)Meanofthetrainingdatabase
Eigenfaces
-(M*Nx(P-1))Eigenvectorsofthecovariancematrixofthetrainingdatabase
A
-(M*NxP)Matrixofcenteredimagevectors
EIG
%%%%%%%%%%%%%%%%%%%%%%%%Calculatingthemeanimage
m=mean(T,2);
%Computingtheaveragefaceimagem=(1/P)*sum(Tj'
s)
(j=1:
P)
Train_Number=size(T,2);
%%%%%%%%%%%%%%%%%%%%%%%%Calculatingthedeviationofeachimagefrommeanimage
A=[];
temp=double(T(:
i))-m;
%ComputingthedifferenceimageforeachimageinthetrainingsetAi=Ti-m
A=[Atemp];
%Mergingallcenteredimages
%%%%%%%%%%%%%%%%%%%%%%%%SnapshotmethodofEigenfacemethos
%WeknowfromlinearalgebratheorythatforaPxQmatrix,themaximum
%numberofnon-zeroeigenvaluesthatthematrixcanhaveismin(P-1,Q-1).
%Sincethenumberoftrainingimages(P)isusuallylessthanthenumber
%ofpixels(M*N),themostnon-zeroeigenvaluesthatcanbefoundareequal
%toP-1.SowecancalculateeigenvaluesofA'
*A(aPxPmatrix)insteadof
%A*A'
(aM*NxM*Nmatrix).ItisclearthatthedimensionsofA*A'
ismuch
%largerthatA'
*A.Sothedimensionalitywilldecrease.
L=A'
*A;
%Listhesurrogateof
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 识别 源码 分享
![提示](https://static.bdocx.com/images/bang_tan.gif)