pcaclassifier.m

来自「PCA、LDA人脸检测」· M 代码 · 共 28 行

M
28
字号
function k=PCAClassifier(n,m,classcenter,x)
% PCACLASSIFIER is the implementation of the classifier based on PCA
% n denotes the dimension of the problem
% m is the number of classes
% classcenter is a matrix(n*m),classcenter(i,j) represents the i-th 
% component of the j-th class
% x is a incoming pattern
% 
% the function will return the number k into which x is classified 
if nargout>1
    error('Too many output arguments.');
end
if nargin~=4
    error('Wrong number of input arguments.');
end
[cn,cm]=size(classcenter);
if cm~=m | cn~=n
    error('Wrong input data.');
end

%从相应文件读取变换矩阵Wt
fid=fopen('pcawt','r');
[eignum,count]=fread(fid,1,'short');
[Wt,count]=fread(fid,[eignum,n],'float');
Wt=reshape(Wt,eignum,n);
fclose(fid);

k=MinDisClassifier(eignum,m,Wt*classcenter,Wt*x);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?