基于【图像识别】基于模板匹配实现蓝色、绿色、黄色车牌识别附matlab代码

车牌识别是智能交通系统的重要部分,主要涉及模式识别、数字图像处理、计算机应用和人工智能等学科。车牌识别过程主要由车牌定位、车牌字符分割和车牌字符识别组成。文中主要对车牌字符识别进行了研究,并在MATLAB环境下进行了相应的实验。文中在车牌字符识别过程中,主要采用了基于模板匹配的车牌字符识别方法。首先将字符的标准模板存储在电脑中备用,然后将待识别字符进行灰度化和二值化,然后将归一化后的待识别字符与存储在电脑中的标准字符模板进行匹配。文中选择的匹配方法是将待识别字符与标准模板进行逻辑“与”运算。进行运算后会得到一个新的字符模板,再根据预先设计好的判别函数对得到的新字符模板进行判断,从而得出识别结果。我国车牌字符由汉字、字母和数字组成。根据汉字、字母和数字结构的不同,在判别函数部分文中将整个车牌字符分为两部分进行研究。汉字为一部分,数字与字母为另一部分。在汉字识别部分,文中将求取标准模板、待识别字符和新字符模板三者标准差的最小值作为一个判别函数;将求取新字符模板最大值作为另一个判别函数。在数字与字母识别部分,文中将求取标准模板、待识别字符和新字符模板三者的标准差最小值作为一个判别函数;将求取新字符模板与标准模板比值的最大值作为另一个判别函数。

 部分代码

function varargout = Gui_Main(varargin)

%%%%%%%%%运行这个即可打开《车牌识别系统》%%%%%%%%

%GUI_MAIN MATLAB code for Gui_Main.fig

%      GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing

%      singleton*.

%

%      H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to

%      the existing singleton*.

%

%      GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local

%      function named CALLBACK in GUI_MAIN.M with the given input arguments.

%

%      GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the

%      existing singleton*.  Starting from the left, property value pairs are

%      applied to the GUI before Gui_Main_OpeningFcn gets called.  An

%      unrecognized property name or invalid value makes property application

%      stop.  All inputs are passed to Gui_Main_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 Gui_Main

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name',       mfilename, ...

                   'gui_Singleton',  gui_Singleton, ...

                   'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...

                   'gui_OutputFcn',  @Gui_Main_OutputFcn, ...

                   'gui_LayoutFcn',  [] , ...

                   'gui_Callback',   []);

if nargin && ischar(varargin{1})

    gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

    gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before Gui_Main is made visible.

function Gui_Main_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 Gui_Main (see VARARGIN)

% Choose default command line output for Gui_Main

clc;

axes(handles.axes1); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);

axes(handles.axes2); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);

axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);

axes(handles.axes4); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);

set(handles.text1, 'string', '');

handles.output = hObject;

handles.file = [];

handles.Plate = [];

handles.bw = [];

handles.words = [];

% Update handles structure

handles.type=1;%打开时,默认识别蓝色车牌

guidata(hObject, handles);

% UIWAIT makes Gui_Main wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = Gui_Main_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;

% --------------------------------------------------------------------

%工具栏:Save Figure

function uipushtool1_ClickedCallback(hObject, eventdata, handles)

% hObject    handle to uipushtool1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...

          '*.*','All Files' }, '保存结果', ...

          'Result\result.jpg');

if isempty(filename)

    return;

end

file = fullfile(pathname, filename);

f = getframe(gcf);

f = frame2im(f);

imwrite(f, file);

msgbox('保存结果图像成功!', '提示信息', 'help');

% --------------------------------------------------------------------

%工具栏:Open File

function uipushtool2_ClickedCallback(hObject, eventdata, handles)

% hObject    handle to uipushtool2 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% 载入车牌图像

axes(handles.axes1); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);

axes(handles.axes2); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);

axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);

axes(handles.axes4); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);

set(handles.text1, 'string', '');

handles.file = [];

handles.Plate = [];

handles.bw = [];

handles.words = [];

[filename, pathname, filterindex] = uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...

    '*.*','All Files' }, '选择待处理图像', ...

    'images');

if filename == 0

    return;

end

file = fullfile(pathname, filename);

Img = imread(file);

[y, ~, ~] = size(Img);

if y > 800

    rate = 800/y;

    Img1 = imresize(Img, rate);

else

    Img1 = Img;

end

axes(handles.axes1);

imshow(Img1); title('原图像', 'FontWeight', 'Bold');

handles.Img = Img;

handles.file = file;

guidata(hObject, handles);

% --- 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)

if isempty(handles.file)

    msgbox('请载入待识别图像', '提示信息', 'error');

    return;

end

row = Loc.row;

col = Loc.col;

axes(handles.axes2); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);

imshow(Plate, []); title('车牌定位图像', 'FontWeight', 'Bold');

handles.Plate = Plate;

guidata(hObject, handles);%储存handles

% --- If Enable == 'on', executes on mouse press in 5 pixel border.

% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton1.

function pushbutton1_ButtonDownFcn(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)

% --- Executes on mouse press over axes background.

function axes1_ButtonDownFcn(hObject, eventdata, handles)

% hObject    handle to axes1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --- Executes on mouse press over axes background.

function axes2_ButtonDownFcn(hObject, eventdata, handles)

% hObject    handle to axes2 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --- Executes on mouse press over axes background.

function axes3_ButtonDownFcn(hObject, eventdata, handles)

% hObject    handle to axes3 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --- Executes on mouse press over axes background.

function axes4_ButtonDownFcn(hObject, eventdata, handles)

% hObject    handle to axes4 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --- 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)

axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);

imshow(bw, []); title('车牌二值图像', 'FontWeight', 'Bold');

handles.bw = bw;

guidata(hObject, handles);%储存handles

% --- 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)

switch (handles.type)

    case 1       

        %蓝色车牌

        words_display = [words.word1 words.word2 words.word3 words.word4 words.word5 words.word6 words.word7];

    case 2

        

        %绿色车牌

        words_display = [words.word1 words.word2 words.word3 words.word4 words.word5 words.word6 words.word7 words.word8];

    case 3

       

        %黄色车牌

        words_display = [words.word1 words.word2 words.word3 words.word4 words.word5 words.word6 words.word7];

end

imshow(words_display, []); title('车牌字符图像', 'FontWeight', 'Bold');

handles.words = words;

guidata(hObject, handles);%储存handles

% --- 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)

switch (handles.type)

    case 1

        str = Pattern_Recog(handles.words);%模板匹配

    case 2

        str = Pattern_Recog02(handles.words);%模板匹配

    case 3

        str = Pattern_Recog_Yellow(handles.words);%模板匹配

end

set(handles.text1, 'string', str);

% --- Executes on button press in radiobutton1.

function radiobutton1_Callback(hObject, eventdata, handles)

% hObject    handle to radiobutton1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton1

handles.type=1;

guidata(hObject, handles);

% --- Executes on button press in radiobutton2.

function radiobutton2_Callback(hObject, eventdata, handles)

% hObject    handle to radiobutton2 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton2

handles.type=2;

guidata(hObject, handles);

% --- Executes on button press in radiobutton5.

function radiobutton5_Callback(hObject, eventdata, handles)

% hObject    handle to radiobutton5 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton5

handles.type=3;

guidata(hObject, handles);

 参考文献

[1]谷秋頔. 基于模板匹配的车牌字符识别及其判别函数的研究[D]. 中北大学.[2]刘忠杰, 宋小波, 何锋,等. 基于MATLAB 的车牌识别系统设计与实现[J]. 微型机与应用, 2011, 30(14):4.❤️ 关注我领取海量matlab电子书和数学建模资料❤️部分理论引用网络文献,若有侵权联系博主删除

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/903574.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

SpringAOP:对于同一个切入点,不同切面不同通知的执行顺序

目录 1. 问题描述2. 结论结论1:"对于同一个切入点,同一个切面不同类型的通知的执行顺序"结论2:"对于同一个切入点,不同切面不同类型通知的执行顺序" 3. 测试环境:SpringBoot 2.3.4.RELEASE测试集合…

jeecgbootvue2菜单路由配置静态文件夹(public)下的html

需求:想要在菜单配置src/assets/iconfont/chart.html显示页面(目的是打包上线以后运维依然可以修改数据) 官网没有相关数据:菜单配置说明 JeecgBoot 开发文档 看云 问题现象: 我把文件放在src/assets/iconfont/chart.html然后在vue中作为 iframe 的 src 属性&am…

CD34:揭开祖细胞的身份之谜

前 言 CD34是广泛存在于各种干细胞或祖细胞表面的糖蛋白,被确定为造血干细胞(HSC)和造血祖细胞(HPC)的生物标志物,具有粘附分子的作用。CD34作为多种非造血细胞标志物,同时也在多种癌症干细胞…

#渗透测试#红蓝对抗#Src漏洞挖掘 介绍-Yakit(3)

免责声明 本教程仅为合法的教学目的而准备,严禁用于任何形式的违法犯罪活动及其他商业行为,在使用本教程前,您应确保该行为符合当地的法律法规,继续阅读即表示您需自行承担所有操作的后果,如有异议,请立即停…

ArcGIS必会的选择要素方法(AND、OR、R、IN等)位置选择等

今天来看看ArcGIS中的几个选择的重要使用方法 1、常规选择、 2、模糊查询、 3、组合复合条件查询(AND、OR、IN), 4、空值NULL查询 5、位置选择 推荐学习: 以梦为马,超过万名学员学习ArcGIS入门到实战的应用课程…

3211、生成不含相邻零的二进制字符串-cangjie

题目 3211、生成不含相邻零的二进制字符串 思路 dfs 代码 class Solution {let numRune [r0, r1]func dfs(arr: ArrayList<Rune>, ans: ArrayList<String>,n: Int64):Unit{if(arr.size > n){ans.insert(0, String(arr))// println("insert ${String(…

数据结构 ——— 二叉树的概念及结构

目录 二叉树的概念 特殊的二叉树 一、满二叉树 二、完全二叉树 二叉树的概念 二叉树树示意图&#xff1a; 从以上二叉树示意图可以看出&#xff1a; 二叉树每个节点的度不大于 2 &#xff0c;那么整个二叉树的度也不大于 2 &#xff0c;但是也不是每个节点都必须有 2 个…

【vs2022】windows可用的依赖预编译库

ffmpeg 、x264 、x265 等。obs是基于qt6+vs2022+64bit obs的官网传统构建已经不用了obs的s2022构建OBS Deps Build 2024-09-12FFmpeg4.4 库,x64 可用。

TinTin Web3 动态精选:Vitalik 探讨以太坊协议,Solana ETN 开启质押功能

TinTin 快讯由 TinTinLand 开发者技术社区打造&#xff0c;旨在为开发者提供最新的 Web3 新闻、市场时讯和技术更新。TinTin 快讯将以周为单位&#xff0c; 汇集当周内的行业热点并以快讯的形式排列成文。掌握一手的技术资讯和市场动态&#xff0c;将有助于 TinTinLand 社区的开…

Kubernetes:(二)K8Sv1.20二进制部署

文章目录 一、k8s项目架构二、二进制搭建 Kubernetes v1.20 &#xff08;单master节点&#xff09;1.操作系统初始化配置2.部署 docker引擎3. etcd的概念4. 证书认证5. node01 节点操作&#xff08;192.168.44.10&#xff09;6. node02 节点操作&#xff08;192.168.44.40&…

SAP-MM委外订单的退货处理

【案例描述】这是我们公司之前的一个案例&#xff0c;关于供应商托工&#xff08;或称&#xff1a;委外&#xff09;发退料的问题&#xff01;大致的流程如下&#xff1a;由于公司本身的加工能力有限&#xff0c;以及出于成本的考虑&#xff0c;需要将公司的一些原材料由供应商…

八大排序算法——堆排序

目录 前言 一、向上调整算法建堆 二、向下调整算法建堆 三、堆排序 前言 堆排序是基于堆结构的一种排序思想&#xff0c;因此要为一个乱序的数组进行排序的前提是数组必须要是一个堆&#xff0c;所以要先对数组进行建堆操作 一、向上调整算法建堆 时间复杂度&#xff1a;O…

2024年医疗人工智能研究报告-生成式AI爆发,医疗人工智能走到新的十字路口(附下载)

前言 2024的医疗AI&#xff0c;既是坎坷&#xff0c;又是新生。 快速发展的大语言模型&#xff0c;携着生成式AI掠过医疗领域。过往的互联网医疗、医学影像、新药研发……一个一个场景经由新一代AI重塑&#xff0c;焕发出前所未有的价值。 不过&#xff0c;发现价值并不意味着…

微信小程序25__实现卡片变换

先看效果图 实现代码如下&#xff1a; <view class"page" style"filter:hue-rotate({{rotation}}deg)"><view class"prev" catchtap"toPrev">《《《</view><view class"next" catchtap"toNext&q…

115页PPT华为管理变革:制度创新与文化塑造的核心实践

集成供应链&#xff08;ISC&#xff09;体系 集成供应链&#xff08;ISC&#xff09;体系是英文Integrated Supply Chain的缩写&#xff0c;是一种先进的管理思想&#xff0c;它指的是由相互间提供原材料、零部件、产品和服务的供应商、合作商、制造商、分销商、零售商、顾客等…

C++进阶-->多态(Polymorphism)

1. 多态的概念 多态&#xff0c;顾名思义多种形态&#xff1b;多态分为编译时多态&#xff08;静态多态&#xff09;和运行时多态&#xff08;动态多态&#xff09;&#xff0c;静态多态就是就是我们前面讲的函数重载和函数模板&#xff0c;可以通过传不同类型&#xff0c;然后…

stm32教程:keil5安装及stm32f1xx系列芯片包下载

早上好啊&#xff0c;大佬们&#xff0c;咱们这个专栏是来浅学一下stm32的内容&#xff0c;然后本篇是一个导言篇&#xff0c;主要是让大家安装好软件&#xff0c;能够正常的进入stm32的学习。 keil5安装包夸克网盘链接&#xff1a; 链接&#xff1a;https://pan.quark.cn/s/1…

保护压缩文件安全:为RAR文件添加密码的两种方法

在日常办公中&#xff0c;给RAR文件设置密码可以保护其中的敏感信息不被随意访问。想要给RAR文件设置密码&#xff0c;需要用到支持RAR格式的解压缩工具&#xff0c;比如WinRAR。本文将介绍WinRAR为RAR文件设置密码的两种常用方法&#xff0c;一起来看看吧&#xff01; 方法一…

【Java语言】类和对象

类 类是用来对一个对象进行描述的&#xff0c;主要描述这个对象哪些属性。 类需要class进行修饰&#xff0c;一个Java文件中可以存在多个类&#xff0c;但是只能存在一个public类且必须与Java文件名相同。eg&#xff1a;有一个Demo.Java文件&#xff0c;在文件中只能存在publi…

大模型系列——AlphaZero/强化学习/MCTS

AlphaGo Zero无需任何人类历史棋谱&#xff0c;仅使用深度强化学习&#xff0c;从零开始训练三天的成就已远远超过了人类数千年积累的围棋知识。 1、围棋知识 &#xff08;1&#xff09;如何简单理解围棋知识 &#xff08;2&#xff09;数子法分胜负&#xff1a;https://zhu…