⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mindismain.m

📁 PCA、LDA人脸检测
💻 M
字号:
function [errorrate,result]=MINDISmain()
% this function is used to simulate the process of minimum distance
% classification

data=zeros(56*46*400,1);
fid=fopen('facedata','r');
[data,count]=fread(fid,inf,'uint8');
if count~=56*46*400
    error('data read error');
end
fclose(fid);
data=reshape(data,56*46,400);

n=56*46;
m=200;
sampleset=zeros(56*46,200);
for i=1:m
    j=i;
    k=0;
    while j>5
        j=j-5;
        k=k+1;
    end
    sampleset(:,i)=data(:,10*k+j);
end

classcenter=zeros(n,40);
for i=1:40
    classcenter(:,i)=(sampleset(:,5*i-4)+sampleset(:,5*i-3)+sampleset(:,5*i-2)+sampleset(:,5*i-1)+sampleset(:,5*i))/5;
end
errornum=0;
term=zeros(200,3);
for i=1:m
    j=i;
    k=0;
    while j>5
        j=j-5;
        k=k+1;
    end
    class=MinDisClassifier(n,40,classcenter,data(:,10*k+j+5));
    term(i,:)=[k+1,10*k+j+5,class];
    if k+1~=class 
        errornum=errornum+1;
    end
end
errorrate=errornum/m;
result=term;

⌨️ 快捷键说明

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