matlab信号灯数字识别,模式识别数字识别matlab(Pattern recognition, digital recognition, matlab).doc...
[摘要]模式识别数字识别matlab(Pattern recognition, digital recognition, matlab) 清除所有 中图分类号 同济= 0; 1 = E:\ MATLAB R2009a便携式\树姿”;%图片文件夹 file2 =“BMP”文件类型;%。r=0.5; %%%%%%%%%%%%%%%%%%训练样本$$$$$$$$$$$$$$$$$$$$ 我= 0:1:1
[摘要]模式识别数字识别matlab(Pattern recognition, digital recognition, matlab) 清除所有 中图分类号 同济= 0; 1 = E:\ MATLAB R2009a便携式\树姿”;%图片文件夹 file2 =“BMP”文件类型;%。
r=0.5; %%%%%%%%%%%%%%%%%%训练样本$$$$$$$$$$$$$$$$$$$$ 我= 0:1:13; J = 1:30 a int2str(我); B = int2str(J); = imread(strcat(1,,',B,file2));%读文件 a_bw = im2bw(A,R);%二值化 【M,N =尺寸(a_bw)]; %%%%%%%%%%%矩阵分成4块,并统计每块1的个数%%%%%%%%%%%% X1=0; 对于k =(1:m / 2) 对于p =(1:n / 2) 如果a_bw(K,P)= = 1 X1=X1 + 1; 结束 结束 结束 x2=0; 对于k =(m / 2 + 1:m) 对于p =(1:n / 2) 如果a_bw(K,P)= = 1 x2=x2+1; 结束 结束 结束 X3 = 0; 对于k =(1:m / 2) 对于p =(n / 2 + 1:n) 如果a_bw(K,P)= = 1 X3 = x3±1; 结束 结束 结束 X4 = 0; 对于k =(m / 2 + 1:m) 对于p =(n / 2 + 1:n) 如果a_bw(K,P)= = 1 X4 = X4 + 1; 结束 结束 结束 S(J,:)= [ x1 x2 x3 x4 ];形成维向量% 4 结束 Q = 1:4 温度=平均(s(:,q));%求列平均值 M(Q)=温度';%类中心 结束 S(:,我+ 1)= m;%类中心矩阵9 * 14 结束 %%%%%%%%%%%%%%测试样本%%%%%%%%%%%%%%%%%%%%% 错误=0; Ⅱ= 0:13 JJ = 31:40 a int2str(II); B = int2str(JJ); = imread(strcat('填补,,',B,滤镜));%读测试文件 a_bw = im2bw(A,R);%二值化 【m,n ] =尺寸(a_bw);%矩阵分块 X1=0; 对于k =(1:m / 2) 对于p =(1:n / 2) 如果a_bw(K,P)= = 1 X1=X1 + 1; 结束 结束 结束 x2=0; 对于k =(m / 2 + 1:m) 对于p =(1:n / 2) 如果a_bw(K,P)= = 1 x2=x2+1; 结束 结束 结束 X3 = 0; 对于k =(1:m / 2) 对于p =(n / 2 + 1:n) 如果a_bw(K,P)= = 1 X3 = x3±1; 结束 结束 结束 X4 = 0; 对于k =(m / 2 + 1:m) 对于p =(n / 2 + 1:n) 如果a_bw(K,P)= = 1 X4 = X4 + 1; 结束 结束 结束 T = [ X1,X2,X3,X4为4维特征向量形成]; TT = [ X1、X2、X3、X4 ]; d_1 = 0; d_3 = inf; Y = 1:14 d_1 =总和((t - s(:,y))。
^ 2);%计算欧式距离 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUM1 = 0; For J = 1: 4 SUM1 SUM1 (TT = + (j) - S (J, y)) ^ 2; End Distance (y) = sqrt (SUM1 求测试样本与各个数字特征的欧式距离%); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% If D > 1% _ 3 d _ 计算最小距离 D = D 1 3 _ _; If < = 10 _ int2str D 2 = (- 1); End If y = = 11 N = 'a'; _ strcat D 2 = (n + and - 11); End If y = = 12 N = 'c'; _ strcat (n = D + 2 and - 12); End If y = = 13 N = 'd'; _ strcat (n = D + 2 and 13); End If y = = 14 E n = ''; _ strcat (n = D + 2 and 14); End Dd (1 + 1 _ II, JJ - 30 d) = 2% 输出判决结果 _; End if end% % 1: 14 and end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Cl
更多推荐
所有评论(0)