- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
ClassifyOnNN.m
资源名称:LBPV_GM.rar [点击查看]
上传用户:kandtrade
上传日期:2009-06-26
资源大小:12k
文件大小:2k
源码类别:
图形图象
开发平台:
Matlab
- % ClassifyOnNN computes the classification accuracy
- % CP=ClassifyOnNN(DM,trainClassIDs,testClassIDs) returns the classification accuracy
- % The input "DM" is a m*n distance matrix, m is the number of test samples, n is the number of training samples
- % 'trainClassIDs' and 'testClassIDs' stores the class ID of training and
- % test samples
- % Examples
- % --------
- % I1=imread('rice1.png');
- % I2=imread('rice2.png');
- % I3=imread('rice3.png');
- % I4=imread('rice4.png');
- % mapping=getmapping(8,'u2');
- % M(1,:)=LBPV(I1,1,8,mapping); % LBPV histogram in (8,1) neighborhood using uniform patterns
- % M(2,:)=LBPV(I2,1,8,mapping);
- % S(1,:)=LBPV(I3,1,8,mapping);
- % S(2,:)=LBPV(I4,1,8,mapping);
- % M = ConvertU2LBP(M,8); % convert u2 LBP or LBPV to meet the requirement of global matching scheme
- % S = ConvertU2LBP(S,8);
- % DM = distGMPDRN(M,S,8,2,3);
- % CP=ClassifyOnNN(DM,[1,1],[1,1]);
- function CP=ClassifyOnNN(DM,trainClassIDs,testClassIDs)
- % Version 1.0
- % Authors: Zhenhua Guo, Lei Zhang and David Zhang
- % Copyright @ Biometrics Research Centre, the Hong Kong Polytechnic University
- if nargin<3
- disp('Not enough input parameters.')
- return
- end
- rightCount = 0;
- for i=1:length(testClassIDs);
- [distNew, index]= min(DM(i,:)); % find Nearest Neighborhood
- if trainClassIDs(index) == testClassIDs(i) % judge whether the nearest one is correctly classified
- rightCount = rightCount+1;
- end
- end
- CP = rightCount/length(testClassIDs)*100;