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

📄 nearestfeatureplaneclassifier.m

📁 用于空中目标识别的最近特征平面分类器子程序。
💻 M
字号:
% Nearest Feature Plane Classifier-NFP
function [NFPCrate]=NFPclassifier(features,test_features,trnum,tenum,classnum)

% features       the matrix that training samples projected on feature subspace(特征维数*训练样本数,列矢量)
% test_features  the matrix that test samples projected on feature subspace(特征维数*测试样本数,列矢量) 
% trnum          the number of training samples of each class
% tenum          the number of test samples of each class
% classnum       the number of classes

% NFPCrate       the output correct classification rate of each class and the total
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% decompose the features and test_features according to the class flag
for i=1:classnum
    subd(:,:,i) =features(:,(i-1)*trnum+1:i*trnum);      % 训练样本集
    subdd(:,:,i)=test_features(:,(i-1)*tenum+1:i*tenum); % 测试样本集
end

% number of NFP of each class
total=trnum*(trnum-1)*(trnum-2)/6;
% compute the parameter U (斜率) and the position P (垂点)
for m=1:classnum                     % 类别数
    for t=1:tenum                    % 测试样本数/类
        k=1;        
        for c=1:classnum             % 类别数
            for i=1:trnum            % 训练样本数/类
                for j=i+1:trnum      % 训练样本数/类
                    for h=j+1:trnum  % 训练样本数/类
                        Wijh=[subd(:,i,c),subd(:,j,c),subd(:,h,c)];
                        u=size(Wijh,2);
                        P=Wijh*inv(Wijh'*Wijh+(1e-3)*eye(u))*Wijh'*subdd(:,t,m);  % 垂足                        
                        dis(t,k,m)=norm(subdd(:,t,m)-P);            % 计算测试点到垂足的距离
                        k=k+1;       % 计算k条特征线(NFP)
                    end
                end
            end
        end       
    end    
end

% compute the correct recognition rate and the according mean value
CCrate=zeros(1,classnum);
for c=1:classnum
    dist=dis(:,:,c)';
    [Y,I]=min(dist);
    k=0;
    for i=1:tenum
        if ceil(I(i)/total)==c
            k=k+1;
        end
    end
    CCrate(c)=k/tenum;            
end
rtmean=sum(CCrate)/classnum;

% output
NFPCrate=zeros(1,classnum+1);
NFPCrate=[CCrate,rtmean];

⌨️ 快捷键说明

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