基于FPGA的脫機(jī)手寫體漢字識(shí)別系統(tǒng)
2.4仿真識(shí)別結(jié)果(以數(shù)字測(cè)試)
本文引用地址:http://cafeforensic.com/article/265048.htm附:
(部分matlab主要程序代碼)
主程序:main.m
clear
clc
global X; %圖像特征矩陣
global S; %樣本特征矩陣
sample_training; %訓(xùn)練樣本
E=imread('6_1.jpg'); %待識(shí)別圖像讀入
%A=gca;
imshow(E);%axis(A);
initial(E);
i=0;j=0;d=0;
Dm=zeros(10,15);
for i=1:10
for j=1:15
Dm(i,j)=abs(S(i,j)-X(1,j));
end
end
D=sum(Dm,2);
Position=find(D==min(D));
% i=Position;
if Position==10
Position=0;
else break;
end
set(handles.edit1,'String',Position);
預(yù)處理程序:initial.m
function initial(RGB)
GRAY=rgb2gray(RGB);
%高斯濾波
g=fspecial('gaussian',3,3);
GRAY1=imfilter(GRAY,g);
%切割圖像
BW=im2bw(GRAY1);
[m,n]=size(BW);
%豎直投影
I1=sum(BW);
L=max(I1);
L1=L-2;
x1=0;x2=0;k=0;
for k=1:m
if I1(k)
x1=k;break;
else
k=k+1;
end
end
for k=x1:m
if I1(k)>L1
x2=k;break;
else
k=k+1;
end
end
%水平投影
BW1=BW';
I2=sum(BW1);
L=max(I2);
L2=L-2;
y1=0;y2=0;k=0;
for k=1:n
if I2(k)
y1=k;break;
else
k=k+1;
end
end
for k=y1:n
if I2(k)>L2
y2=k;break;
else
k=k+1;
end
end
%行,子切分
BW2=BW(y1:y2,x1:x2);
%圖像歸一化
NOR=imresize(BW2,[120 90]);
%特征提取
X=zeros(1,15);
X(1)=bwarea(NOR(1:40,1:30))/10800;
X(2)=bwarea(NOR(1:40,31:60))/10800;
X(3)=bwarea(NOR(1:40,61:90))/10800;
X(4)=bwarea(NOR(41:80,1:30))/10800;
X(5)=bwarea(NOR(41:80,31:60))/10800;
X(6)=bwarea(NOR(41:80,61:90))/10800;
X(7)=bwarea(NOR(81:120,1:30))/10800;
X(8)=bwarea(NOR(81:120,31:60))/10800;
X(9)=bwarea(NOR(81:120,61:90))/10800;
X(10)=X(1)+X(2)+X(3);
X(11)=X(4)+X(5)+X(6);
X(12)=X(7)+X(8)+X(9);
X(13)=X(1)+X(4)+X(7);
X(14)=X(2)+X(5)+X(8);
X(15)=X(3)+X(6)+X(9);
fpga相關(guān)文章:fpga是什么
絕對(duì)值編碼器相關(guān)文章:絕對(duì)值編碼器原理 全息投影相關(guān)文章:全息投影原理
評(píng)論