【车牌识别】车牌识别【含Matlab源码 417期】

在这里插入图片描述

⛄一、获取代码方式(附实验题目说明)

获取代码方式1:
完整代码已上传我的资源:【车牌识别】基于matlab车牌识别【含Matlab源码 417期】
(https://download.csdn.net/download/TIQCmatlab/62925370)
点击上面蓝色字体,直接付费下载,即可。

获取代码方式2:
付费专栏Matlab图像处理(初级版)

备注:
点击上面蓝色字体付费专栏Matlab图像处理(初级版),扫描上面二维码,付费29.9元订阅海神之光博客付费专栏Matlab图像处理(初级版),凭支付凭证,私信博主,可免费获得1份本博客上传CSDN资源代码(有效期为订阅日起,三天内有效);
点击CSDN资源下载链接:1份本博客上传CSDN资源代码

⛄二、车牌识别简介

基于matlab 国内车牌识别步骤:原图像识别、列过滤、行过滤、分割结果、灰度、水平倾斜校正后、滤波二值化、字符分割。

⛄三、部分源代码

% clear
addpath(genpath(pwd)); %添加子文件夹下的所有文件
%%加载图像
start=6212;
% state=num+1;
% start=6540;
state=1;

% for num = state:294
close all
num = 1 ; %读取文件夹下的第num张图片
% 20
%

fname=['样本库\IMG_',num2str(start+num),'.jpg'];

% 有三个车牌文件夹:‘PlateImages/%d.jpg’ 或者’PlateImages/Image1/%d.jpg’ 或’PlateImages/Image2/%d.jpg’
filename = fullfile(pwd, fname);
Img = imread(filename);
%{
figure(5);
subplot(2,2,1);imshow(Img);title(‘原图’);I1=rgb2gray(Img);
subplot(2,2,2);imshow(I1);title(‘灰度图’);
subplot(2,2,3);imhist(I1);title(‘灰度图直方图’);I2=edge(I1,‘roberts’,0.15,‘both’);
subplot(2,2,4);imshow(I2);title(‘roberts算子边缘检测’)
se=[1;1;1];
I3=imerode(I2,se);
figure(6);
subplot(2,2,1);imshow(I3);title(‘腐蚀后图像’);se=strel(‘rectangle’,[25,25]);I4=imclose(I3,se);
subplot(2,2,2);imshow(I4);title(‘平滑图像的轮廓’);I5=bwareaopen(I4,2000);
subplot(2,2,3);imshow(I5);title(‘从对象中移除小对象’);
%}

GetDB;

%% 定位车牌
% 定位车牌:找出车牌在原始图片中的位置
% 输入参数Img: 读取的原始真彩色图像信息
% 输出参数plate:经过定位处理后,从原始真彩色图像(会进行压缩处理)截取到的车牌位置处的真彩色图像信息
plate = Pre_Process(Img);

%% 倾斜校正
% 倾斜校正:对待识别数字的倾斜校正,分别使用Radon变换和仿射函数处理水平倾斜校正和垂直倾斜校正
% 输入参数:plate为定位截取的真彩色车牌图像信息
% 输出参数:
plate = radon_repair(plate);

%% 车牌滤波
% 车牌滤波:剔除(像素值置0)车牌图片的边界图像信息
% 输入参数:plate为定位截取的真彩色车牌图像信息
% 输出参数:d为原始车牌图像滤波(即剔除上下边界外(和使用多边形区域剔除))后的图片,p为真彩色原始车牌图像plate逆时针旋转后的图片
[d, p] = Plate_Process(plate,fname);

%% 分割车牌
% 分割车牌:裁掉(删除)车牌图像信息的边界
% 输入参数:d为原始车牌图像滤波(即剔除上下边界外(和使用多边形区域剔除))后的图片,p为真彩色原始车牌图像plate逆时针旋转后的图片
% 输出参数:根据图像d的非0边界,裁剪出的输入图片:输入图片d裁剪后输出图片e,输入图片p裁剪后输出图片p
[e, p] = Segmation(d, p);
%% 去除噪声
function [result, plate] = Plate_Process(plate, fname, flag)
% 分割步骤
if nargin < 3
flag = 1;
end
% n = ndims(A) returns the number of dimensions in the array A.
if ndims(plate) == 3
% I = rgb2gray(RGB) converts the truecolor image RGB to the grayscale intensity image I.
% rgb2gray converts RGB images to grayscale by eliminating the hue and saturation information while retaining the luminance.
plate1 = rgb2gray(plate); % 将车牌原始图片信息转换成grayscale intensity image(灰度图像?为方便,下面都称为灰度图像)
else
plate1 = plate;
end
Im = plate1; % Im为灰度图像
plate = double(plate);
% B = mean2(A) computes the mean of the values in A.
% b = std2(A) computes the standard deviation of the values in A.
% 求出当前图片的[均值 标准差]矩阵,用于和数据库的[均值 标准差]矩阵进行计算,然后找出最适合用于处理当前图片的数据库参数信息
m = [mean2(plate(:,:,1)) mean2(plate(:,:,2)) mean2(plate(:,:,3)) std2(plate(:,:,1)) std2(plate(:,:,2)) std2(plate(:,:,3))];

% f = fullfile(filepart1,...,filepartN) builds a full file specification, f, from the folders and file names specified.
% f = fullfile('myfolder','mysubfolder','myfile.m') ===> f = myfolder\mysubfolder\myfile.m
load('model.mat');

ms = cat(1, M.m);   % 数据库中的[均值 标准差]矩阵

% B = repmat(A,m,n) creates a large matrix B consisting of an m-by-n tiling of copies of A.
% The size of B is [size(A,1)*m, (size(A,2)*n]. The statement repmat(A,n) creates an n-by-n tiling.
m = repmat(m, size(ms, 1), 1);  % 将当前图片的[均值 标准差]矩阵进行拓展,以便进行与数据库[均值 标准差]矩阵运算

% B = sum(A,dim) sums along the dimension of A specified by scalar dim. The dim input is an integer value from 1 to N, 
% where N is the number of dimensions in A. Set dim to 1 to compute the sum of each column, 2 to sum rows, etc.
% 按行求和
dis = sum((m - ms).^2, 2);  % 当前图片[均值 标准差]矩阵与数据库[均值 标准差]矩阵的方差
[~, id] = min(dis);         % 找出方差最小的那个,也就是说,找出最适合用于处理当前图片的数据库参数
if fname(6)=='s'
    ro = M(id).ro;              % 图片旋转的角度参数,单位为度
else
    ro=0;
end
th = M(id).th;              % 将灰度图像转换为二进制图像的门限,灰度图像中的值大于该门限则转换为1,否则转换为0
pts = M(id).pts;            % 定义图片的顶点

% B = imrotate(A,angle,method) rotates image A by angle degrees in a counterclockwise direction around its
% center point, using the interpolation method specified by method.
Im = imrotate(Im, ro, 'bilinear');          % 将灰度图片Im按照逆时针方向,旋转ro度,插值方法选择双线性插值
plate = imrotate(plate, ro, 'bilinear');    % 将车牌原始图像,也按照逆时针方向,旋转ro度,插值方法选择双线性插值

% BW = im2bw(I, level) converts the grayscale image I to a binary image. 
% The output image BW replaces all pixels in the input image with luminance(亮度) greater than level with the value 1 (white)
% and replaces all other pixels with the value 0 (black). Specify level in the range [0,1]. This range is relative to
% the signal levels possible for the image's class. Therefore, a level value of 0.5 is midway between black and white, regardless of class.
bw = im2bw(Im, th);     % 将灰度图像Im转换成二进制图像,转换门限为th

% h = fspecial('average', hsize) returns an averaging filter h of size hsize.
% The argument hsize can be a vector specifying the number of rows and columns in h, or it can be a scalar, in which case h is a square matrix.
h = fspecial('average', 2);     % 定义一个多维均值滤波器h,维度为2 x 2

% B = imfilter(A,h) filters the multidimensional array A with the multidimensional filter h.
% The array A can be logical or a nonsparse numeric array of any class and dimension. The result B has the same size and class as A.
% ___= imfilter(___,options,...) performs multidimensional filtering according to the specified options.
% 'replicate' ===> Input array values outside the bounds of the array are assumed to equal the nearest array border value.
bw1 = imfilter(bw, h, 'replicate');     % 使用多维均值滤波器h,对二进制图像bw进行滤波,滤波选项为replicate

% mask = Mask_Process(bw1); % 此方法功能是去除bw1图像的上下杂线,即使用特定算法,剔除二进制图像bw1的上下边界处的信息(这些行的像素值全设为0)
% 此处的mask可理解为:如果图像像素点在杂线上边界与车牌上边界之间或杂线下边界与车牌下边界之间,则这个像素点的值为0,
% 否则,如果图像像素点在杂线上边界和杂线下边界之间,则这个像素点的值为1
% bw2 = bw1 .* mask; % 这个.*操作可理解为:与运算,这样bw2就是利用mask矩阵剔除二进制图像bw1中干扰后的结果
bw2 = bw1;

% 除了通过Mask_Process()函数剔除杂线外,如果有定义车牌边界信息,则可进一步使用车牌边界信息进行图像处理

% if ~isempty(pts) % 如果pts不空(即,有外部边界顶点定义),则执行
% % BW = roipoly(I, c, r) returns the region of interest(ROI) specified by the polygon(多边形) described by vectors c and r,
% % which specify the column and row indices of each vertex(顶点), respectively. c and r must be the same size.
% % 根据二进制图片bw2,以及多边形的顶点pts(:, 1), pts(:, 2),得到二进制图像mask,顶点围起来的区域的值全为1,
% % 其它区域的值全为0,这样做的目的是剔除车牌边界的干扰
% mask = roipoly(bw2, pts(:, 1), pts(:, 2)); % 得到一个由pts顶点(可组成多边形)指定的二进制边界图像
% bw1 = bw1 .* mask; % bw1是只使用多边形剔除干扰后的二进制图像
% bw2 = bw2 .* mask; % bw2是使用Mask_Process()算法和多边形两种方法剔除干扰后的二进制图像
% end

⛄四、运行结果

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

⛄五、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1]呙润华,苏婷婷,马晓伟.BP神经网络联合模板匹配的车牌识别系统[J].清华大学学报(自然科学版),2013,53(9):1221-1226.
[2]鲁扬.基于BP神经网络的车牌识别算法研究[D].大庆:东北石油大学,2018.
[3]李强,张娟.一种改进的基于模板匹配的污损车牌识别方法[J].智能计算机与应用. 2019,9(03).
[4] 梁凯.基于MATLAB的汽车车牌识别系统的设计与实现[D] .哈尔滨:黑龙江大学, 2018.
[5]刘雄飞,朱盛春.车牌字符多特征提取与BP神经网络的识别算法[J].计算机仿真,2014,31(10):161-164,290.
[6] 曾泉, 谭北海.基于SVM和BP神经网络的车牌识别系统[J] .电子科技, 2016, 29(1) :98-101.

3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除

  • 22
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Matlab领域

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值