LDA人脸识别地matlab程序

上传人:s9****2 文档编号:458269773 上传时间:2022-11-05 格式:DOC 页数:8 大小:74KB
返回 下载 相关 举报
LDA人脸识别地matlab程序_第1页
第1页 / 共8页
LDA人脸识别地matlab程序_第2页
第2页 / 共8页
LDA人脸识别地matlab程序_第3页
第3页 / 共8页
LDA人脸识别地matlab程序_第4页
第4页 / 共8页
LDA人脸识别地matlab程序_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《LDA人脸识别地matlab程序》由会员分享,可在线阅读,更多相关《LDA人脸识别地matlab程序(8页珍藏版)》请在金锄头文库上搜索。

1、实用文案point.%by SVD%Valid%0.1.%regularizati on%matrix%regularizati on%provided%nFea is%LDA人脸识别的matlab程序以下是LDA的m文件函数: 你稍稍改改就能用了!fun cti on eigvector, eigvalue, elapse = LDA(g nd,opti on s,data) % LDA: Lin ear Discrim inant An alysis% eigvector, eigvalue = LDA(g nd, optio ns, data)%In put:%data - Data m

2、atrix. Each row vector of fea is a datagnd - Colu nm vector ofthe label in formatio n for eachdata point.options - Struct value in Matlab. The fields in optionsthat can be set:Regu - 1: regularized soluti on,a* = argmax(aXWXa)/(aXXa+ReguAlpha*l)0: solve the sinu larity problemDefault: 0ReguAlpha - T

3、he regularization parameter.whe n Regu=1. Default value isReguType - Ridge: Tikho novCustom: User providedregularizati onDefault: RidgeregularizerR - (nFea x nF ea)matrix which should beif ReguType is Custom.the feature nu mber of data matrix标准文档%Fisherface-1: Fisherface approach%PCARatio = n Smp -

4、n Class%Default: 0%PCARatio - The perce ntage ofprin cipal%comp onent kept in the PCA%step. The perce ntage is%calculated based on the%eige nv alue. Default is 1%(100%, all the non-zero%eige nv alues%If PCARatio 1, the PCAstep%will keep exactlyPCARatio prin ciple%comp onents (does notexceed the%exac

5、t nu mber of non-zerowill be p onen ts).%Output:%eigvector - Each colu mn is an embedd ing fun cti on, for anew%datapoint (row vector) x, y = x*eigvector%will be the embedd ing result of x.%eigvalue - The sorted eigvalue of LDA eige n-problem.%elapse - Time spe nt on differe nt steps% Examples:% fea

6、 = ran d(50,70);% gnd = on es(10,1);o nes(15,1)*2;o nes(10,1)*3;o nes(15,1)*4;%optio ns =;%opti on s.Fisherface =1;%eigvector, eigvalue=LDA(g nd, opti ons, fea);%Y = fea*eigvector;% % See also LPP, con structW, LGE %Refere nee:% P. N. Belhumeur, J. P. Hespanha, and D. J. Kriegman,揈 igenfaces% vs. fi

7、sherfaces: recog niti on using class specific lin ear% projection,? IEEE Transactions on Pattern Analysis and Machine% Intelligenee, vol. 19, no. 7, pp. 711-720, July 1997.% Deng Cai, Xiaofei He, Yuxiao Hu, Jiawei Han, and Thomas Hua ng,% Lear ning a Spatially Smooth Subspace for Face Recog niti on,

8、CVPR2007% De ng Cai, Xiaofei He, Jiawei Han, SRDA: An Efficie nt Algorithm for% Large Scale Discrim inant An alysis, IEEE Tran sacti ons on Kno wledge and% Data Engin eeri ng, 2007.% version 2.1 -Ju ne/2007% version 2.0 -May/2007% version 1.1 -Feb/2006% version 1.0 -April/2004% Writte n by Deng Cai

9、(de ngcai2 AT cs.uiuc.edu)%if exist(data,var)global data;endif (exist(optio ns,var)opti ons =;endif isfield(options,Regu) | options.RegubPCA = 1;if isfield(optio ns,卩 CARatio)optio ns.PCARatio = 1;endelsebPCA = 0;if isfield(opti on s,ReguType)optio ns.ReguType = Ridge;endif isfield(opti on s,ReguAlp

10、ha)optio ns.ReguAlpha = 0.1;end end tmp_T = cputime;% = In itializati onn Smp ,nF ea = size(data); if len gth(g nd) = n Smperror(g nd and data mismatch!); end classLabel = uniq ue(g nd); n Class = len gth(classLabel); Dim = n Class - 1;if bPCA & isfield(optio ns,Fisherface) & opti on s.Fisherface op

11、ti on s.PCARatio = n Smp - n Class;end if issparse(data)data = full(data); endsampleMea n = mean( data,1);data = (data - repmat(sampleMea n,n Smp,1);bChol = 0;if bPCA & (n Smp nFea+1) & (optio ns.PCARatio = 1)DPrime =DPrime =data*data;=max(DPrime,DPrime);R,p = chol(DPrime);if p = 0 bPCA = 0; bChol =

12、 1;endend%= % SVD%= if bPCAif n Smp nFea ddata = data*data;ddata = max(ddata,ddata);eigvector_PCA, eigvalue_PCA = eig(ddata); eigvalue_PCA = diag(eigvalue_PCA); clear ddata;maxEigValue = max(abs(eigvalue_PCA); eigIdx = fin d(eigvalue_PCA/maxEigValue 1 idx = optio ns.PCARatio;if idx le ngth(eigvalue_PCA) eigvalue_PCA = eigvalue_PCA(1:idx); eigvector_PCA = eigvector_PCA(:,1:idx);endelseif options.PCARatio = sumEig break;endendeigvalue_PCA = eigvalue_PCA(1:idx); eigvector_PCA = eigvector_PCA(:,1:idx);end %=eigvalue_PCA = eigvalue_PCA.A-.5;dat

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 商业计划书

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号