# DLDA.rar

• PUDN用户
了解作者
• matlab
开发工具
• 1KB
文件大小
• rar
文件格式
• 0
收藏次数
• 1 积分
下载积分
• 70
下载次数
• 2008-05-13 20:56
上传日期

DLDA.rar
• DLDA.m
3.4KB
• www.pudn.com.txt
218B

function [eigvectors, eigvalues, newTrainData,newTestData] = DLDA(trainData,testData,height,width,gnd,numvecs) % DLDA: Two dimensional linear discriminant analysis % Input: % trainData - Data matrix. Each row vector of fea is a data point % testData - Data matrix. Each row vector of fea is a data point % height - height of the original image matrix % width - width of the original image matrix % gnd - Colunm vector of the label information for each train % data point. % numvecs - the needed number eigenvectors % % Output: % eigvectors - Each column is an embedding function, for a new % data point (row vector) x, % y = reshape(reshape(x,height,width)*eigvectors,1,height*width) % will be the embedding result of x. % eigvalues - The eigvalues of LDA eigen-problem. % % % [eigvectors, eigvalues, newTrainData,newTestData] = TDLDA(trainData,testData,height,width,gnd,numvecs) % % newTrainData&newTestData: The embedding results, Each row vector is a data point. % newTrainData(i,:) = reshape(reshape(trainData(i,:),height,width)*eigvectors,1,height*numvecs) % newTestData(i,:) = reshape(reshape(testData(i,:),height,width)*eigvectors,1,height*numvecs) % % % Reference paper: H.Kong,X.Li,L.Wang,E.K.Teoh,J.G.Wang,and % R.Venkateswards.Two dimesiional fisher discriminant % analysis:Forget about small sample size problem.In % Proceddings of ICASSP,2005. % % ====== Initialization [nSmp,nFea] = size(trainData); classLabel = unique(gnd); nClass = length(classLabel); sampleMean = mean(trainData); B = zeros(width, width); % Between-class matrix W = zeros(width, width); % Within-class matrix for i = 1:nClass, index = find(gnd==classLabel(i)); classMean = mean(trainData(index, :)); % calculate between-class matrix dummyMat = reshape((classMean-sampleMean),height,width); B = B + dummyMat'*dummyMat; % calculate within-class matrix Beg = index(1); End = index(1) + length(index) - 1; for j = Beg:End dummyMat = reshape((trainData(j,:)-classMean),height,width); W = W + dummyMat'*dummyMat; end end B = B/nClass; W = W/nSmp; W = (W + W')/2; B = (B + B')/2; fprintf(1,'Calculating generalized eigenvectors and eigenvalues...\n'); [eigvectors, eigvalues] = eig(B,W); fprintf(1,'Sorting eigenvectors according to eigenvalues...\n'); [eigvectors,eigvalues] = sortem(eigvectors,eigvalues); eigvalues = diag(eigvalues); for i = 1:size(eigvectors,2) eigvectors(:,i) = eigvectors(:,i)./norm(eigvectors(:,i)); end eigvectors = eigvectors(:,1:numvecs); if nargout == 4 fprintf(1,'Feature extraction and calculating newData...\n'); newTrainData = zeros(nSmp,height*numvecs); for i = 1:nSmp dummyMat = reshape((trainData(i,:)-sampleMean),height,width); newTrainData(i,:) = reshape(dummyMat*eigvectors,1,height*numvecs); end nSam1 = size(testData,1); newTestData = zeros(nSam1,height*numvecs); for i = 1:nSam1 dummyMat = reshape((testData(i,:)-sampleMean),height,width); newTestData(i,:) = reshape(dummyMat*eigvectors,1,height*numvecs); end end

相关推荐
• 2DLDA.rar
二维的LDA人脸识别matlab程序,非常好用。
• 2DLDALDA.rar
实现2DLDALDA人脸识别的比较，有论文和相应的程序，matlab编写
• LDA2D-2.rar
人脸识别中2DLDA算法的matlab程序，使用最近邻分类器进行识别。
• 2dlda-twosides.rar
这是一个基于人脸识别的双边2DLDA代码，我看到一般写的2DLDA都是单边的，所以上传一个双边的，大家参考一下
• 2DLDA.rar
人脸识别2DLDA程序,比LDA识别率跟高。
• 2D-LDA.rar
LDA人脸识别程序，用matlab加以实现
• 3DLDA.rar
这是一个2D的LDA人脸识别源代码，matlab的，如果要用的话就赶紧下载吧！
• 2DLDA 二维线性鉴别分析
二维的LDA人脸识别matlab程序,非常好用。-Two-dimensional LDA face recognition matlab program, very easy to use.
• codesforimageprocessing.rar
实现简单图像处理，包括256色转灰度图、Hough变换、Walsh变换、中值滤波、二值化变换、亮度增减、傅立叶变换、反色、取对数、取指数、图像平移、图像旋转、图像细化、图像缩放、图像镜像、均值滤波、对比度拉伸、拉普拉斯锐化（边缘检测）、方块编码、梯度锐化、灰度均衡、直方图均衡、离散余弦变换、维纳滤波处理、逆滤波处理、阈值变换、高斯平滑。
• matlab.rar
基于MATLAB-GUI图形界面的数字图像处理软件 本系统设计基于GUI图形界面，用matlab语言编写代码，实现功能包括图象的读取、存储、显示、直方图均衡化、阈值化、小波分解、小波重构、加噪、去噪、平滑、锐化、边缘检测、图像分割等