資源簡介
基于PCA主元分析法實現的手寫數字識別功能,附有Matlab代碼及解釋。
代碼片段和文件信息
%%%%%%%%%%%%程序名:手寫數字識別程序2016
%%%%%%%%%%%%功能:實現對手寫體數字的檢測與識別
%%%%%%%%%%%%時間:2016年10月25日21:43:59
clf;
clc;
clear;
load?long
clear?n;
r=0;
H=[];?%承載所有樣本數字特征的矩陣
train_num=24;
for?i=1:10
????for?j=1:train_num
????????a=imread(strcat(‘lib\‘num2str(i)‘\‘num2str(j)‘.jpg‘));
????????b=double(a(1:10304)‘);
????????H(:(i-1)*train_num+j)=b(:1);
????end
end
Hmean=mean(H2);
for?i=1:train_num*10
????e(:i)=H(:i)-Hmean();
end
C=e‘*e;
[V?D]=eig(C);
D1=diag(D);
[D_sort?D_index]=?sort(D1‘descend‘);
V_sort=V(:?D_index);
i=1;
while?(i<=train_num*10)
????w(:i)?=??e?*?V_sort(:i)/D_sort(i)^(1/2);??
????i?=?i?+?1;
end
F=w‘*H;
%%%%%%開始識別
[filenamepathname]=uigetfile(‘*.*‘‘2016手寫數字識別系統L1.0—選擇待識別的數字‘);??%選擇圖像
??????????????[imgmap]=imread(strcat(pathnamefilename));???????
subplot(211)imshow(img);
[xy]=size(img);
title(‘待識別的數字‘‘FontSize‘12‘FontWeight‘‘bold‘‘Color‘‘b‘)
[An]=Num_seg(img);
??for?cheng=1:n???
?a1=imread(strcat(‘Num_seg/‘‘Num_seg‘num2str(cheng)‘.jpg‘));
?b=a1(1:10304)‘;
?b=double(b);
?F1=w‘*b;
???for?k=1:train_num*10
?????G(k)=norm(F1-F(:k));
???end
?[h?G_index]=sort(G);
?r=ceil(G_index(1)/train_num);%分類?
?P=num2str(r);
???if?r==10
????r=0;??
???end
?????N(cheng)=r;?
??end
XU=num2str(N);
%?Sia(n);
save?Auto
Result;
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???29770416??2017-10-16?16:35??Handnumber_detect_pca1.0\auto.mat
?????文件???????1841??2016-10-25?22:05??Handnumber_detect_pca1.0\lib\1\1.jpg
?????文件???????1419??2016-10-27?09:08??Handnumber_detect_pca1.0\lib\1\10.jpg
?????文件???????1569??2016-10-26?16:51??Handnumber_detect_pca1.0\lib\1\11.jpg
?????文件???????1895??2016-10-25?21:50??Handnumber_detect_pca1.0\lib\1\12.jpg
?????文件???????1934??2016-10-26?08:59??Handnumber_detect_pca1.0\lib\1\13.jpg
?????文件???????1895??2016-10-26?08:59??Handnumber_detect_pca1.0\lib\1\14.jpg
?????文件???????1458??2016-10-26?09:53??Handnumber_detect_pca1.0\lib\1\15.jpg
?????文件???????1938??2016-10-26?10:35??Handnumber_detect_pca1.0\lib\1\16.jpg
?????文件???????1191??2016-10-26?10:16??Handnumber_detect_pca1.0\lib\1\17.jpg
?????文件???????2018??2016-10-27?09:20??Handnumber_detect_pca1.0\lib\1\18.jpg
?????文件???????1011??2016-11-01?12:33??Handnumber_detect_pca1.0\lib\1\19.jpg
?????文件???????1958??2016-10-25?22:24??Handnumber_detect_pca1.0\lib\1\2.jpg
?????文件???????1191??2016-11-01?12:38??Handnumber_detect_pca1.0\lib\1\20.jpg
?????文件????????976??2016-11-01?12:38??Handnumber_detect_pca1.0\lib\1\21.jpg
?????文件???????1530??2016-11-01?12:43??Handnumber_detect_pca1.0\lib\1\22.jpg
?????文件???????1216??2016-10-26?08:56??Handnumber_detect_pca1.0\lib\1\3.jpg
?????文件???????1189??2016-10-25?22:31??Handnumber_detect_pca1.0\lib\1\4.jpg
?????文件???????1239??2016-10-25?19:52??Handnumber_detect_pca1.0\lib\1\5.jpg
?????文件???????1532??2016-10-25?20:38??Handnumber_detect_pca1.0\lib\1\6.jpg
?????文件???????1876??2016-10-25?22:17??Handnumber_detect_pca1.0\lib\1\7.jpg
?????文件???????1634??2016-10-26?10:06??Handnumber_detect_pca1.0\lib\1\8.jpg
?????文件???????1934??2016-10-25?21:50??Handnumber_detect_pca1.0\lib\1\9.jpg
?????文件???????2790??2016-10-25?22:24??Handnumber_detect_pca1.0\lib\10\1.jpg
?????文件???????1905??2016-10-25?20:00??Handnumber_detect_pca1.0\lib\10\10.jpg
?????文件???????2783??2016-10-25?22:05??Handnumber_detect_pca1.0\lib\10\11.jpg
?????文件???????2328??2016-10-25?20:38??Handnumber_detect_pca1.0\lib\10\12.jpg
?????文件???????1545??2016-10-26?09:04??Handnumber_detect_pca1.0\lib\10\13.jpg
?????文件???????1500??2016-10-26?09:53??Handnumber_detect_pca1.0\lib\10\14.jpg
?????文件???????1895??2016-10-26?09:53??Handnumber_detect_pca1.0\lib\10\15.jpg
............此處省略503個文件信息
評論
共有 條評論