matlab版本为R2019b,界面采用的是matlab自带的app designer设计。
目录
licenseOCR.mlapp
process.mlapp
getword.m
qiege.m
界面展示
工程文件
classdef licenseOCR < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
LicenseOCRUIFigure matlab.ui.Figure
Button_2 matlab.ui.control.Button
UIAxes matlab.ui.control.UIAxes
UIAxes_2 matlab.ui.control.UIAxes
Button matlab.ui.control.Button
Button_4 matlab.ui.control.Button
Button_3 matlab.ui.control.Button
Label matlab.ui.control.Label
Label_2 matlab.ui.control.Label
TextArea matlab.ui.control.TextArea
end
properties (Access = public)
Image
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
delete('process\*.jpg');%删除处理过程
end
% Button pushed function: Button_2
function Button_2Pushed(app, event)
%=========================图像预处理=======================%
I=app.Image;
I1=rgb2gray(I); %将车牌图像转换为灰度图
imwrite(I1,'process\灰度图.jpg')
I2=edge(I1,'sobel',0.15,'both'); %在灰度图像中查找边缘
imwrite(I2,'process\1.算子边缘检测.jpg')
se=[1;1;1];
I3=imerode(I2,se); %腐蚀操作
imwrite(I3,'process\2.腐蚀后图像.jpg')
se=strel('rectangle',[25,25]);
I4=imclose(I3,se); %填充图像
imwrite(I4,'process\3.平滑图像的轮廓.jpg')
I5=bwareaopen(I4,2000); %删除二值化图像中像素小于2000的对象
imwrite(I5,'process\4.从对象中移除小对象.jpg')
%==========================车牌定位====================%
[y,x]=size(I5); %返回I5各维的尺寸,储存在[x,y]中
myI=double(I5); %将 I5 中的值转换为双精度
tic
Blue_y=zeros(y,1); %创建一个由零值组成的 y*1 矩阵
for i=1:y
for j=1:x
if(myI(i,j)==1) %如果myI的图像坐标为(i,j)的点值为1
Blue_y(i,1)= Blue_y(i,1)+1; %统计蓝色像素点
end
end
end
[Temp MaxY]=max(Blue_y);
%Y方向车牌区域确定
PY1=MaxY;
while ((Blue_y(PY1,1)>=5)&&(PY1>1))
PY1=PY1-1;
end
PY2=MaxY;
while ((Blue_y(PY2,1)>=5)&&(PY2PX1))
PX2=PX2-1;
end
PX1=PX1-1;%对车牌区域的校正
PX2=PX2+1;
dw=I(PY1:PY2-8,PX1:PX2,:);
G=toc;
imwrite(IY,'process\行方向合理区域.jpg')
imwrite(dw,'process\dw.jpg');
%========================字符切割======================%
a=imread('process\dw.jpg');
b=rgb2gray(a); %将车牌图像转换为灰度图
imwrite(b,'process\1.车牌灰度图像.jpg'); %写入灰度图
g_max=double(max(max(b)));
g_min=double(min(min(b)));
T=round(g_max-(g_max-g_min)/3); %T为二值化的阈值,向最近的方向取整
[m,n]=size(b);
d=(double(b)>=T); % d:二值图像
imwrite(d,'process\2.车牌二值图像.jpg');
%均值滤波前
h=fspecial('average',3);
%建立预定义的滤波算子,average为均值滤波,模板尺寸3x3
d=im2bw(round(filter2(h,d)));
imwrite(d,'process\4.均值滤波后.jpg');
se=eye(2); %产生m×n的单位矩阵
[m,n]=size(d); %返回信息矩阵
if bwarea(d)/m/n>=0.365 %计算二值图像中对象的总面积比整个面积是否大于0.365
d=imerode(d,se); %如果大于进行腐蚀操作
elseif bwarea(d)/m/n<=0.235 %计算二值图像中对象的总面积比整个面积是否小于0.235
d=imdilate(d,se); %如果小于进行膨胀操作
end
imwrite(d,'process\5.膨胀或腐蚀处理后.jpg');
H=toc;
% 寻找连续有文字的块,若长度大于某阈值,则认为该块有两个字符组成需要分割
d=qiege(d);
[m,n]=size(d);
k1=1;k2=1;s=sum(d);j=1;
while j~=n
while s(j)==0
j=j+1;
end
k1=j;
while s(j)~=0 && j<=n-1
j=j+1;
end
k2=j-1;
if k2-k1>=round(n/6.5)
[val,num]=min(sum(d(:,k1+5:k2-5)));
d(:,k1+num+5)=0; % 判定有两个字符需要分割
end
end
% 再切割
d=qiege(d);
% 切割出 7 个字符
y1=10;y2=0.25;flag=0;word1=[];
while flag==0
[m,n]=size(d);
left=1;wide=0;
while sum(d(:,wide+1))~=0
wide=wide+1;
end
if widey2
flag=1;word1=temp; %切割出来的word1
end
d(:,1:wide)=0;d=qiege(d);
end
end
% 分割出第二到七个字符
[word2,d]=getword(d);
[word3,d]=getword(d);
[word4,d]=getword(d);
[word5,d]=getword(d);
[word6,d]=getword(d);
[word7,d]=getword(d);
[m,n]=size(word1);
% 归一化大小为 40*20
word1=imresize(word1,[40 20]);
word2=imresize(word2,[40 20]);
word3=imresize(word3,[40 20]);
word4=imresize(word4,[40 20]);
word5=imresize(word5,[40 20]);
word6=imresize(word6,[40 20]);
word7=imresize(word7,[40 20]);
imwrite(word1,'process\1.jpg');
imwrite(word2,'process\2.jpg');
imwrite(word3,'process\3.jpg');
imwrite(word4,'process\4.jpg');
imwrite(word5,'process\5.jpg');
imwrite(word6,'process\6.jpg');
imwrite(word7,'process\7.jpg');
liccode=char(['0':'9' 'A':'Z' '京津沪晋辽吉鲁苏浙皖鲁豫粤川陕新黑宁']);
%============================字符识别=============================%
JG=zeros(40,20); %产生一个40*20大小的零矩阵
l=1;
L=toc;
for I=1:7 %I为待识别的字符位
ii=int2str(I); %整形数据转化为字符串类型
t=imread(['process\',ii,'.jpg']);
MB=imresize(t,[40 20],'nearest'); %缩放处理
if l==1 %车牌号第一位为汉字识别,使用37-53号样本库
kmin=37;
kmax=53;
elseif l==2 %车牌号第二位为 A~Z 大写字母识别,使用11-36号样本库
kmin=11;
kmax=36;
else l>=3; %第三位以后是字母或数字识别,使用1-36号样本库
kmin=1;
kmax=36;
end
for k2=kmin:kmax
fname=strcat('样本库\',liccode(k2),'.bmp');
YB = imread(fname); %调用样本库图像文件
for i=1:40
for j=1:20
%将待识别图像与模板图像两幅图相减得到第三幅图
JG(i,j)=MB(i,j)-YB(i,j);
end
end
Dmax=0;
for k1=1:40
for l1=1:20
if ( JG(k1,l1) > 0 || JG(k1,l1) <0 )
Dmax=Dmax+1;
end
end
end
Error(k2)=Dmax;
end
Error1=Error(kmin:kmax);
MinError=min(Error1);
findc=find(Error1==MinError);
Code(l*2-1)=liccode(findc(1)+kmin-1);
Code(l*2)=' ';
l=l+1;
end
t=toc;
imshow('process\dw.jpg','Parent',app.UIAxes_2);
app.TextArea.Value = Code;
end
% Button pushed function: Button
function ButtonPushed(app, event)
[filename,pathname] = uigetfile({'*.jpg';'*.png'},'选择图片');
if isequal(filename,0)
f = msgbox('没有图片','error',app.UIAxes);
set(f,'position',[500 250 150 100])
else
pathfile=fullfile(pathname,filename);
end
app.Image=imread(pathfile);
imshow(app.Image,'Parent',app.UIAxes);
end
% Button pushed function: Button_4
function Button_4Pushed(app, event)
delete(app);%退出系统
end
% Button pushed function: Button_3
function Button_3Pushed(app, event)
process;
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create LicenseOCRUIFigure and hide until all components are created
app.LicenseOCRUIFigure = uifigure('Visible', 'off');
app.LicenseOCRUIFigure.Position = [100 100 730 480];
app.LicenseOCRUIFigure.Name = 'LicenseOCR';
% Create Button_2
app.Button_2 = uibutton(app.LicenseOCRUIFigure, 'push');
app.Button_2.ButtonPushedFcn = createCallbackFcn(app, @Button_2Pushed, true);
app.Button_2.FontSize = 14;
app.Button_2.FontWeight = 'bold';
app.Button_2.FontColor = [0 0.4471 0.7412];
app.Button_2.Position = [222 89 100 35];
app.Button_2.Text = '开始';
% Create UIAxes
app.UIAxes = uiaxes(app.LicenseOCRUIFigure);
title(app.UIAxes, '')
xlabel(app.UIAxes, '')
ylabel(app.UIAxes, '')
app.UIAxes.Box = 'on';
app.UIAxes.XTick = [];
app.UIAxes.XTickLabel = '';
app.UIAxes.YTick = [];
app.UIAxes.YTickLabel = '';
app.UIAxes.TitleFontWeight = 'bold';
app.UIAxes.Position = [13 174 346 210];
% Create UIAxes_2
app.UIAxes_2 = uiaxes(app.LicenseOCRUIFigure);
title(app.UIAxes_2, '')
xlabel(app.UIAxes_2, '')
ylabel(app.UIAxes_2, '')
app.UIAxes_2.Box = 'on';
app.UIAxes_2.XTick = [];
app.UIAxes_2.XTickLabel = '';
app.UIAxes_2.YTick = [];
app.UIAxes_2.YTickLabel = '';
app.UIAxes_2.TitleFontWeight = 'bold';
app.UIAxes_2.Position = [378 200 346 100];
% Create Button
app.Button = uibutton(app.LicenseOCRUIFigure, 'push');
app.Button.ButtonPushedFcn = createCallbackFcn(app, @ButtonPushed, true);
app.Button.FontSize = 14;
app.Button.FontWeight = 'bold';
app.Button.FontColor = [0 0.4471 0.7412];
app.Button.Position = [39 89 100 35];
app.Button.Text = '选择图片';
% Create Button_4
app.Button_4 = uibutton(app.LicenseOCRUIFigure, 'push');
app.Button_4.ButtonPushedFcn = createCallbackFcn(app, @Button_4Pushed, true);
app.Button_4.FontSize = 14;
app.Button_4.FontWeight = 'bold';
app.Button_4.FontColor = [0 0.4471 0.7412];
app.Button_4.Position = [597 89 100 35];
app.Button_4.Text = '退出';
% Create Button_3
app.Button_3 = uibutton(app.LicenseOCRUIFigure, 'push');
app.Button_3.ButtonPushedFcn = createCallbackFcn(app, @Button_3Pushed, true);
app.Button_3.FontSize = 14;
app.Button_3.FontWeight = 'bold';
app.Button_3.FontColor = [0 0.4471 0.7412];
app.Button_3.Position = [407 89 100 35];
app.Button_3.Text = '处理过程';
% Create Label
app.Label = uilabel(app.LicenseOCRUIFigure);
app.Label.HorizontalAlignment = 'center';
app.Label.FontSize = 18;
app.Label.FontWeight = 'bold';
app.Label.FontColor = [0 0.4471 0.7412];
app.Label.Position = [309 402 114 24];
app.Label.Text = '车牌识别系统';
% Create Label_2
app.Label_2 = uilabel(app.LicenseOCRUIFigure);
app.Label_2.HorizontalAlignment = 'right';
app.Label_2.FontSize = 14;
app.Label_2.Position = [378 339 61 22];
app.Label_2.Text = '车牌号:';
% Create TextArea
app.TextArea = uitextarea(app.LicenseOCRUIFigure);
app.TextArea.FontSize = 14;
app.TextArea.Position = [454 336 243 27];
% Show the figure after all components are created
app.LicenseOCRUIFigure.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = licenseOCR
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.LicenseOCRUIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.LicenseOCRUIFigure)
end
end
end
classdef process < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
processUIFigure matlab.ui.Figure
UIAxes matlab.ui.control.UIAxes
UIAxes_2 matlab.ui.control.UIAxes
UIAxes_3 matlab.ui.control.UIAxes
UIAxes_4 matlab.ui.control.UIAxes
UIAxes_5 matlab.ui.control.UIAxes
UIAxes_6 matlab.ui.control.UIAxes
UIAxes_7 matlab.ui.control.UIAxes
UIAxes_8 matlab.ui.control.UIAxes
UIAxes_9 matlab.ui.control.UIAxes
UIAxes_10 matlab.ui.control.UIAxes
UIAxes_11 matlab.ui.control.UIAxes
UIAxes_12 matlab.ui.control.UIAxes
UIAxes_13 matlab.ui.control.UIAxes
UIAxes_14 matlab.ui.control.UIAxes
UIAxes_15 matlab.ui.control.UIAxes
UIAxes_17 matlab.ui.control.UIAxes
UIAxes_19 matlab.ui.control.UIAxes
UIAxes_16 matlab.ui.control.UIAxes
UIAxes_18 matlab.ui.control.UIAxes
UIAxes_20 matlab.ui.control.UIAxes
Label matlab.ui.control.Label
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
set(app.processUIFigure,'position',get(0,'ScreenSize'));
imshow('process\灰度图.jpg','Parent',app.UIAxes);
plot(app.UIAxes_2,imhist(uint8('process\灰度图.jpg')));
imshow('process\1.算子边缘检测.jpg','Parent',app.UIAxes_3);
imshow('process\2.腐蚀后图像.jpg','Parent',app.UIAxes_4);
imshow('process\3.平滑图像的轮廓.jpg','Parent',app.UIAxes_5);
imshow('process\4.从对象中移除小对象.jpg','Parent',app.UIAxes_6);
imshow('process\行方向合理区域.jpg','Parent',app.UIAxes_7);
imshow('process\dw.jpg','Parent',app.UIAxes_8);
imshow('process\1.车牌灰度图像.jpg','Parent',app.UIAxes_9);
imshow('process\2.车牌二值图像.jpg','Parent',app.UIAxes_10);
imshow('process\2.车牌二值图像.jpg','Parent',app.UIAxes_11);
imshow('process\4.均值滤波后.jpg','Parent',app.UIAxes_12);
imshow('process\5.膨胀或腐蚀处理后.jpg','Parent',app.UIAxes_13);
imshow('process\1.jpg','Parent',app.UIAxes_14);
imshow('process\2.jpg','Parent',app.UIAxes_15);
imshow('process\3.jpg','Parent',app.UIAxes_16);
imshow('process\4.jpg','Parent',app.UIAxes_17);
imshow('process\5.jpg','Parent',app.UIAxes_18);
imshow('process\6.jpg','Parent',app.UIAxes_19);
imshow('process\7.jpg','Parent',app.UIAxes_20);
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create processUIFigure and hide until all components are created
app.processUIFigure = uifigure('Visible', 'off');
app.processUIFigure.Position = [100 100 1569 871];
app.processUIFigure.Name = 'UI Figure';
% Create UIAxes
app.UIAxes = uiaxes(app.processUIFigure);
title(app.UIAxes, '灰度图')
xlabel(app.UIAxes, '')
ylabel(app.UIAxes, '')
app.UIAxes.FontName = '微软雅黑';
app.UIAxes.FontSize = 14;
app.UIAxes.Box = 'on';
app.UIAxes.XTick = [];
app.UIAxes.YTick = [];
app.UIAxes.TitleFontWeight = 'bold';
app.UIAxes.Position = [390 580 255 158];
% Create UIAxes_2
app.UIAxes_2 = uiaxes(app.processUIFigure);
title(app.UIAxes_2, '灰度图直方图')
xlabel(app.UIAxes_2, '')
ylabel(app.UIAxes_2, '')
app.UIAxes_2.FontName = '微软雅黑';
app.UIAxes_2.FontSize = 14;
app.UIAxes_2.Box = 'on';
app.UIAxes_2.XTick = [];
app.UIAxes_2.YTick = [];
app.UIAxes_2.TitleFontWeight = 'bold';
app.UIAxes_2.Position = [103 580 255 158];
% Create UIAxes_3
app.UIAxes_3 = uiaxes(app.processUIFigure);
title(app.UIAxes_3, '1.算子边缘检测')
xlabel(app.UIAxes_3, '')
ylabel(app.UIAxes_3, '')
app.UIAxes_3.FontName = '微软雅黑';
app.UIAxes_3.FontSize = 14;
app.UIAxes_3.Box = 'on';
app.UIAxes_3.XTick = [];
app.UIAxes_3.YTick = [];
app.UIAxes_3.TitleFontWeight = 'bold';
app.UIAxes_3.Position = [685 580 255 158];
% Create UIAxes_4
app.UIAxes_4 = uiaxes(app.processUIFigure);
title(app.UIAxes_4, '2.腐蚀后图像')
xlabel(app.UIAxes_4, '')
ylabel(app.UIAxes_4, '')
app.UIAxes_4.FontName = '微软雅黑';
app.UIAxes_4.FontSize = 14;
app.UIAxes_4.Box = 'on';
app.UIAxes_4.XTick = [];
app.UIAxes_4.YTick = [];
app.UIAxes_4.TitleFontWeight = 'bold';
app.UIAxes_4.Position = [979 580 255 158];
% Create UIAxes_5
app.UIAxes_5 = uiaxes(app.processUIFigure);
title(app.UIAxes_5, '3.平滑图像的轮廓')
xlabel(app.UIAxes_5, '')
ylabel(app.UIAxes_5, '')
app.UIAxes_5.FontName = '微软雅黑';
app.UIAxes_5.FontSize = 14;
app.UIAxes_5.Box = 'on';
app.UIAxes_5.XTick = [];
app.UIAxes_5.YTick = [];
app.UIAxes_5.TitleFontWeight = 'bold';
app.UIAxes_5.Position = [1273 580 255 158];
% Create UIAxes_6
app.UIAxes_6 = uiaxes(app.processUIFigure);
title(app.UIAxes_6, '4.从对象中移除小对象')
xlabel(app.UIAxes_6, '')
ylabel(app.UIAxes_6, '')
app.UIAxes_6.FontName = '微软雅黑';
app.UIAxes_6.FontSize = 14;
app.UIAxes_6.Box = 'on';
app.UIAxes_6.XTick = [];
app.UIAxes_6.YTick = [];
app.UIAxes_6.TitleFontWeight = 'bold';
app.UIAxes_6.Position = [95 372 255 158];
% Create UIAxes_7
app.UIAxes_7 = uiaxes(app.processUIFigure);
title(app.UIAxes_7, '行方向合理区域')
xlabel(app.UIAxes_7, '')
ylabel(app.UIAxes_7, '')
app.UIAxes_7.FontName = '微软雅黑';
app.UIAxes_7.FontSize = 14;
app.UIAxes_7.Box = 'on';
app.UIAxes_7.XTick = [];
app.UIAxes_7.YTick = [];
app.UIAxes_7.TitleFontWeight = 'bold';
app.UIAxes_7.Position = [390 372 255 158];
% Create UIAxes_8
app.UIAxes_8 = uiaxes(app.processUIFigure);
title(app.UIAxes_8, '定位剪切后的彩色车牌图像')
xlabel(app.UIAxes_8, '')
ylabel(app.UIAxes_8, '')
app.UIAxes_8.FontName = '微软雅黑';
app.UIAxes_8.FontSize = 14;
app.UIAxes_8.Box = 'on';
app.UIAxes_8.XTick = [];
app.UIAxes_8.YTick = [];
app.UIAxes_8.TitleFontWeight = 'bold';
app.UIAxes_8.Position = [685 372 255 158];
% Create UIAxes_9
app.UIAxes_9 = uiaxes(app.processUIFigure);
title(app.UIAxes_9, '1.车牌灰度图像')
xlabel(app.UIAxes_9, '')
ylabel(app.UIAxes_9, '')
app.UIAxes_9.FontName = '微软雅黑';
app.UIAxes_9.FontSize = 14;
app.UIAxes_9.Box = 'on';
app.UIAxes_9.XTick = [];
app.UIAxes_9.YTick = [];
app.UIAxes_9.TitleFontWeight = 'bold';
app.UIAxes_9.Position = [979 372 255 158];
% Create UIAxes_10
app.UIAxes_10 = uiaxes(app.processUIFigure);
title(app.UIAxes_10, '2.车牌二值图像')
xlabel(app.UIAxes_10, '')
ylabel(app.UIAxes_10, '')
app.UIAxes_10.FontName = '微软雅黑';
app.UIAxes_10.FontSize = 14;
app.UIAxes_10.Box = 'on';
app.UIAxes_10.XTick = [];
app.UIAxes_10.YTick = [];
app.UIAxes_10.TitleFontWeight = 'bold';
app.UIAxes_10.Position = [1273 372 255 158];
% Create UIAxes_11
app.UIAxes_11 = uiaxes(app.processUIFigure);
title(app.UIAxes_11, '3.均值滤波前')
xlabel(app.UIAxes_11, '')
ylabel(app.UIAxes_11, '')
app.UIAxes_11.FontName = '微软雅黑';
app.UIAxes_11.FontSize = 14;
app.UIAxes_11.Box = 'on';
app.UIAxes_11.XTick = [];
app.UIAxes_11.YTick = [];
app.UIAxes_11.TitleFontWeight = 'bold';
app.UIAxes_11.Position = [95 165 255 158];
% Create UIAxes_12
app.UIAxes_12 = uiaxes(app.processUIFigure);
title(app.UIAxes_12, '4.均值滤波后')
xlabel(app.UIAxes_12, '')
ylabel(app.UIAxes_12, '')
app.UIAxes_12.FontName = '微软雅黑';
app.UIAxes_12.FontSize = 14;
app.UIAxes_12.Box = 'on';
app.UIAxes_12.XTick = [];
app.UIAxes_12.YTick = [];
app.UIAxes_12.TitleFontWeight = 'bold';
app.UIAxes_12.Position = [390 165 255 158];
% Create UIAxes_13
app.UIAxes_13 = uiaxes(app.processUIFigure);
title(app.UIAxes_13, '5.膨胀或腐蚀处理后')
xlabel(app.UIAxes_13, '')
ylabel(app.UIAxes_13, '')
app.UIAxes_13.FontName = '微软雅黑';
app.UIAxes_13.FontSize = 14;
app.UIAxes_13.Box = 'on';
app.UIAxes_13.XTick = [];
app.UIAxes_13.YTick = [];
app.UIAxes_13.TitleFontWeight = 'bold';
app.UIAxes_13.Position = [685 165 255 158];
% Create UIAxes_14
app.UIAxes_14 = uiaxes(app.processUIFigure);
title(app.UIAxes_14, '1')
xlabel(app.UIAxes_14, '')
ylabel(app.UIAxes_14, '')
app.UIAxes_14.FontName = '微软雅黑';
app.UIAxes_14.FontSize = 14;
app.UIAxes_14.Box = 'on';
app.UIAxes_14.XTick = [];
app.UIAxes_14.YTick = [];
app.UIAxes_14.TitleFontWeight = 'bold';
app.UIAxes_14.Position = [380 33 100 100];
% Create UIAxes_15
app.UIAxes_15 = uiaxes(app.processUIFigure);
title(app.UIAxes_15, '2')
xlabel(app.UIAxes_15, '')
ylabel(app.UIAxes_15, '')
app.UIAxes_15.FontName = '微软雅黑';
app.UIAxes_15.FontSize = 14;
app.UIAxes_15.Box = 'on';
app.UIAxes_15.XTick = [];
app.UIAxes_15.YTick = [];
app.UIAxes_15.TitleFontWeight = 'bold';
app.UIAxes_15.Position = [486 33 100 100];
% Create UIAxes_17
app.UIAxes_17 = uiaxes(app.processUIFigure);
title(app.UIAxes_17, '4')
xlabel(app.UIAxes_17, '')
ylabel(app.UIAxes_17, '')
app.UIAxes_17.FontName = '微软雅黑';
app.UIAxes_17.FontSize = 14;
app.UIAxes_17.Box = 'on';
app.UIAxes_17.XTick = [];
app.UIAxes_17.YTick = [];
app.UIAxes_17.TitleFontWeight = 'bold';
app.UIAxes_17.Position = [698 33 100 100];
% Create UIAxes_19
app.UIAxes_19 = uiaxes(app.processUIFigure);
title(app.UIAxes_19, '6')
xlabel(app.UIAxes_19, '')
ylabel(app.UIAxes_19, '')
app.UIAxes_19.FontName = '微软雅黑';
app.UIAxes_19.FontSize = 14;
app.UIAxes_19.Box = 'on';
app.UIAxes_19.XTick = [];
app.UIAxes_19.YTick = [];
app.UIAxes_19.TitleFontWeight = 'bold';
app.UIAxes_19.Position = [910 33 100 100];
% Create UIAxes_16
app.UIAxes_16 = uiaxes(app.processUIFigure);
title(app.UIAxes_16, '3')
xlabel(app.UIAxes_16, '')
ylabel(app.UIAxes_16, '')
app.UIAxes_16.FontName = '微软雅黑';
app.UIAxes_16.FontSize = 14;
app.UIAxes_16.Box = 'on';
app.UIAxes_16.XTick = [];
app.UIAxes_16.YTick = [];
app.UIAxes_16.TitleFontWeight = 'bold';
app.UIAxes_16.Position = [592 33 100 100];
% Create UIAxes_18
app.UIAxes_18 = uiaxes(app.processUIFigure);
title(app.UIAxes_18, '5')
xlabel(app.UIAxes_18, '')
ylabel(app.UIAxes_18, '')
app.UIAxes_18.FontName = '微软雅黑';
app.UIAxes_18.FontSize = 14;
app.UIAxes_18.Box = 'on';
app.UIAxes_18.XTick = [];
app.UIAxes_18.YTick = [];
app.UIAxes_18.TitleFontWeight = 'bold';
app.UIAxes_18.Position = [804 33 100 100];
% Create UIAxes_20
app.UIAxes_20 = uiaxes(app.processUIFigure);
title(app.UIAxes_20, '7')
xlabel(app.UIAxes_20, '')
ylabel(app.UIAxes_20, '')
app.UIAxes_20.FontName = '微软雅黑';
app.UIAxes_20.FontSize = 14;
app.UIAxes_20.Box = 'on';
app.UIAxes_20.XTick = [];
app.UIAxes_20.YTick = [];
app.UIAxes_20.TitleFontWeight = 'bold';
app.UIAxes_20.Position = [1015 33 100 100];
% Create Label
app.Label = uilabel(app.processUIFigure);
app.Label.FontSize = 24;
app.Label.FontWeight = 'bold';
app.Label.FontColor = [0 0.4471 0.7412];
app.Label.Position = [724 810 199 32];
app.Label.Text = '车牌识别处理过程';
% Show the figure after all components are created
app.processUIFigure.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = process
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.processUIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.processUIFigure)
end
end
end
function [word,result]=getword(d)
word=[];flag=0;y1=8;y2=0.5;
while flag==0
[m,n]=size(d);
wide=0;
while sum(d(:,wide+1))~=0 && wide<=n-2
wide=wide+1;
end
temp=qiege(imcrop(d,[1 1 wide m]));%返回图像的一个切割区域
[m1,n1]=size(temp);
if widey2
d(:,[1:wide])=0;
if sum(sum(d))~=0
d=qiege(d); % 切割出最小范围
else word=[];flag=1;
end
else
word=qiege(imcrop(d,[1 1 wide m]));
d(:,[1:wide])=0;
if sum(sum(d))~=0;
d=qiege(d);flag=1;
else d=[];
end
end
end
%end
result=d;
function e=qiege(d)
[m,n]=size(d);
top=1;bottom=m;left=1;right=n; % init
while sum(d(top,:))==0 && top<=m
top=top+1;
end
while sum(d(bottom,:))==0 && bottom>=1
bottom=bottom-1;
end
while sum(d(:,left))==0 && left<=n
left=left+1;
end
while sum(d(:,right))==0 && right>=1
right=right-1;
end
dd=right-left;
hh=bottom-top;
e=imcrop(d,[left top dd hh]);%该函数用于返回图像的一个裁剪区域
主界面
过程界面
工程网盘(提取码:41d6)