資源簡介
基于SVM的手寫數字識別及數字圖像的特征提取
代碼片段和文件信息
function?f=feature_extraction(fileimage)
%???特征提取
I=imread(fileimage);
th=graythresh(I);
I=im2bw(Ith);
%imshow(I00);
[rowcol]=size(I);
f(1:31)=0;
%%?提取像素分布特征16個
%第一行塊
for?j=1:col/4
????for?i=1:row/4
????????if?I(ij)==1
????????????f(1)=f(1)+1;
????????end
????end
end
for?j=col/4+1:col/4*2
????for?i=1:row/4
????????if?I(ij)==1
????????????f(2)=f(2)+1;
????????end
????end
end
for?j=col/4*2+1:col/4*3
????for?i=1:row/4
????????if?I(ij)==1
????????????f(3)=f(3)+1;
????????end
????end
end?
for?j=col/4*3+1:col/4*4
????for?i=1:row/4
????????if?I(ij)==1
????????????f(4)=f(4)+1;
????????end
????end
end?
%第二行塊
for?j=1:col/4
????for?i=row/4+1:row/4*2
????????if?I(ij)==1
????????????f(5)=f(5)+1;
????????end
????end
end
for?j=col/4+1:col/4*2
????for?i=row/4+1:row/4*2
????????if?I(ij)==1
????????????f(6)=f(6)+1;
????????end
????end
end
for?j=col/4*2+1:col/4*3
????for?i=row/4+1:row/4*2
????????if?I(ij)==1
????????????f(7)=f(7)+1;
????????end
????end
end?
for?j=col/4*3+1:col/4*4
????for?i=row/4+1:row/4*2
????????if?I(ij)==1
????????????f(8)=f(8)+1;
????????end
????end
end?
%第三行塊
for?j=1:col/4
????for?i=row/4*2+1:row/4*3
????????if?I(ij)==1
????????????f(9)=f(9)+1;
????????end
????end
end
for?j=col/4+1:col/4*2
????for?i=row/4*2+1:row/4*3
????????if?I(ij)==1
????????????f(10)=f(10)+1;
????????end
????end
end
for?j=col/4*2+1:col/4*3
????for?i=row/4*2+1:row/4*3
????????if?I(ij)==1
????????????f(11)=f(11)+1;
????????end
????end
end?
for?j=col/4*3+1:col/4*4
????for?i=row/4*2+1:row/4*3
????????if?I(ij)==1
????????????f(12)=f(12)+1;
????????end
????end
end
%第四行塊
for?j=1:col/4
????for?i=row/4*3+1:row/4*4
????????if?I(ij)==1
????????????f(13)=f(13)+1;
????????end
????end
end
for?j=col/4+1:col/4*2
????for?i=row/4*3+1:row/4*4
????????if?I(ij)==1
????????????f(14)=f(14)+1;
????????end
????end
end
for?j=col/4*2+1:col/4*3
????for?i=row/4*3+1:row/4*4
????????if?I(ij)==1
????????????f(15)=f(15)+1;
????????end
????end
end?
for?j=col/4*3+1:col/4*4
????for?i=row/4*3+1:row/4*4
????????if?I(ij)==1
????????????f(16)=f(16)+1;
????????end
????end
end
fmax=max(f);
fmin=min(f);
for?i=1:16
????f(i)=(f(i)-fmin)/(fmax-fmin);
end
%%?提取交點特征6個
j=11;???%掃描第11列
for?i=1:row
????if?I(ij)==1
????????f(17)=f(17)+1;
????end
end
j=14;???%掃描第14列
for?i=1:row
????if?I(ij)==1
????????f(18)=f(18)+1;
????end
end
j=17;???%掃描第17列
for?i=1:row
????if?I(ij)==1
????????f(19)=f(19)+1;
????end
end
i=11;???%掃描第11行
for?j=1:row
????if?I(ij)==1
????????f(20)=f(20)+1;
????end
end
i=14;???%掃描第14行
for?j=1:row
????if?I(ij)==1
????????f(21)=f(21)+1;
????end
end
i=17;???%掃描第17行
for?j=1:row
????if?I(ij)==1
????????f(22)=f(22)+1;
????end
end
%%?字符輪廓特征提取9個
l(1:28)=0;r(1:28)=0;
for?i=1:row
????for?j=1:col
????????if(I(ij)==1)
????????????l(i)=j;
????????????break
????????end???????
????end
end
for?i=1:row
????for?j=col:-1:1
??
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????3577??2013-06-20?15:02??feature_extraction.m
?????文件????????1151??2013-06-21?00:27??SVM_Digital_recognition.m
- 上一篇:DFIG_wind_turbine
- 下一篇:獨立分量ICA圖像特征提取程序和圖片
評論
共有 條評論