当前位置: 代码迷 >> 综合 >> 【图像识别】基于BP神经网络求解车牌识别问题matlab代码
  详细解决方案

【图像识别】基于BP神经网络求解车牌识别问题matlab代码

热度:70   发布时间:2023-12-03 22:19:49.0

?1 简介

随着信息时代的到来,现代智能交通系统能够很轻易的识别出汽车牌照,这是智能交通管理的标志之一。智能交通管理系统的牌照识别集合了图像采集和预处理、车牌定位技术、字符分割和字符识别等相关技术。其中,车牌定位、字符分割和字符识别是最关键的技术,也是本次毕业设计的难点所在。正确利用好这三种关键技术,将有助于牌照识别的实时性和准确性,对于智能交通系统的实现有着决定性作用。在MATLAB软件开发环境下,系统首先对图像进行预处理、然后将预处理后的图像进行定位分割,最后识别出相应牌照上的字符,这样就可以模拟设计出汽车牌照识别系统。本文的图像预处理模块是将图像灰度化和用Canny算子进行边缘检测,汽车牌照定位依据是它的颜色特征,使用MATLAB中的Radon函数和Imrotate函数来进行车牌矫正;分割字符时,需要先找到连续的文字块,然后根据长度大小来确定是否分割,假如所找到的连续文字块的长度大于阈值,那么就表示可以对此文字块进行分割。并且为了能对车牌上的字符进行正确的识别,本文将采用BP神经网络算法。最后设计GUI界面,使界面更加简洁明了,便于操作。根据实验得出的结论,这种方式可以对蓝色的车牌进行高效、精确的识别,同时,也对光照、旋转和噪声表现出很好的鲁棒性,定位精度和识别正确率甚至可以超过90%。

2 部分代码

function varargout = run(varargin)
% RUN MATLAB code for run.fig
%     RUN, by itself, creates a new RUN or raises the existing
%     singleton*.
%
%     H = RUN returns the handle to a new RUN or the handle to
%     the existing singleton*.
%
%     RUN('CALLBACK',hObject,eventData,handles,...) calls the local
%     function named CALLBACK in RUN.M with the given input arguments.
%
%     RUN('Property','Value',...) creates a new RUN or raises the
%     existing singleton*. Starting from the left, property value pairs are
%     applied to the GUI before run_OpeningFcn gets called. An
%     unrecognized property name or invalid value makes property application
%     stop. All inputs are passed to run_OpeningFcn via varargin.
%
%     *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
%     instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help run% Last Modified by GUIDE v2.5 07-May-2016 15:41:22% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...'gui_Singleton',  gui_Singleton, ...'gui_OpeningFcn', @run_OpeningFcn, ...'gui_OutputFcn',  @run_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback',   []);
if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});
endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
elsegui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT% --- Executes just before run is made visible.
function run_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject   handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
% varargin   command line arguments to run (see VARARGIN)% Choose default command line output for run
handles.output = hObject;
handles.cd0 = cd;
handles.Color = 0;
handles.I = [];axes(handles.axes1);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;axes(handles.axes2);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;%axes(handles.axes3);
%set(gca,'Xtick',[]);
%set(gca,'Ytick',[]);
%box on;axes(handles.axes4);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;axes(handles.axes5);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;axes(handles.axes6);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;axes(handles.axes8);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;axes(handles.axes9);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;axes(handles.axes12);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;
axes(handles.axes13);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;
axes(handles.axes14);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;
axes(handles.axes15);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;
axes(handles.axes16);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;
axes(handles.axes17);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;% Update handles structure
guidata(hObject, handles);% UIWAIT makes run wait for user response (see UIRESUME)
% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.
function varargout = run_OutputFcn(hObject, eventdata, handles) 
% varargout cell array for returning output args (see VARARGOUT);
% hObject   handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)% Get default command line output from handles structure
varargout{1} = handles.output;% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject   handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
%% 读图
[filename, cd1] = uigetfile( ...{'*.tif;*.TIF;*.JPG;*.jpg;*.bmp;*.BMP;*.jpeg;*.JPEG;','Image file';...'*.*', 'All file (*.*)'},'Pick an Image');
axes(handles.axes1);
cla;
axes(handles.axes2);
cla;
%axes(handles.axes3);
%cla;
axes(handles.axes4);
cla;
if filenamecd(cd1);d = imread(filename);cd(handles.cd0);handles.I = d;axes(handles.axes1);imshow(d);handles.filename = filename; box on;endhandles.Color = 0;
cd(handles.cd0);
set(handles.text2,'string','');
guidata(hObject, handles);% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject   handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
image =  handles.I; 
gray = rgb2gray(image);     % 图像灰度化
axes(handles.axes2);
imshow(gray);% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject   handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
%image = handles.I; 
%gray = rgb2gray(image);
%new_gray = histeq(gray); % 直方图均衡 ,图像增强
%axes(handles.axes3);
%imshow(new_gray);% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject   handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
image =  handles.I; 
gray = rgb2gray(image);     
new_gray = histeq(gray);  % 直方图均衡 ,图像增强
if size(new_gray,1)>1000new_gray_1 = imresize(new_gray,0.1);
elsenew_gray_1 =new_gray;
end
bw = edge(new_gray_1,'canny');                    
axes(handles.axes4);
imshow(bw);
guidata(hObject, handles); 
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject   handle to pushbutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
%% 字符识别
images_test_all = handles.testnum;
nnmain;
for i = 1:size(images_test_all,2) images_test = double(images_test_all(:,i));pred(i) = predict(Theta1, Theta2, images_test');   
end
chepai = [];
for i = 1:size(pred,2)if pred(i)>0 chepai = [chepai,Name{pred(i)}];end
end
% chepai(1) = '苏';set(handles.text2,'string',chepai);% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject   handle to pushbutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
%% 这个按钮关闭软件
close all;
clear;
clc;

3 仿真结果

4 参考文献

[1]冯知凡. 基于图像处理及BP神经网络的车牌识别技术的研究. Diss. 武汉科技大学, 2011.

部分理论引用网络文献,若有侵权联系博主删除。

5 MATLAB代码与数据下载地址

见博客主页头条

?

  相关解决方案