matlab车牌投影分割法,基于垂直投影的车牌字符分割matlab程序-程序员宅基地

技术标签: matlab车牌投影分割法  

function [seg] = character_segmentation(bw, DIGIT_WIDTH, MIN_AREA);

% character_segmentation: Returns the digit segments in the supplied binary image.

% The function uses the "segment" function, keeping only the seven

% segments in the result with largest area, and in case less than seven

% segments were found, it attempts to recall the function, making the

% separation between the already found segments clearer (by cleaning the

% bits which are there.

seg = segment(bw, DIGIT_WIDTH, MIN_AREA);

[x y] = size(seg);

% If we got less than 7 digits, we try to make the sepration between them

% clearer by cleaning the bits between them, and we call the "segment"

% function again:

if x < 7

for i = 1 : x

bw(:,seg(i,2))=0;

end;

seg = segment(bw, DIGIT_WIDTH, MIN_AREA);

end;

% Keeping in the results the seven segments with the largest area:

area = [];

for i = 1 : x

pic = bw(:, seg(i,1) : seg(i,2), :);

area(i) = bwarea(pic);   %bwarea函数计算对象面积

end;

area1 = sort(area);

seg = seg';

for j = 1:(length(area1)-7)

i = find(area == area1(j));

len = length(area);

if i == 1

area = [area(2:len)];

seg = [seg(:,2:len)];

elseif i == len

area = [area(1:i-1)];

seg = [seg(:,1:i-1)];

else

area = [area(1:i-1) area(i+1:len)];

seg = [seg(:,1:i-1) seg(:,i+1:len)];

end;

end;

seg = seg';

return;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [segmentation] = segment(im, digit_width, min_area);

% segment: Segment the pictures in digit images according to the variable

% "digit_width" and returns a matrix containing the two bounds of the each

% digit segment. The function keeps in the result only segment whose

% "rectangular" areas is more than "min_area".

segmentation = [];

% Summing the colums of the pic:

t = sum(im);

% Getting the segments in the pic:

seg = clean(find_valleys(t, 2, 1, digit_width), 3);

% Keeping in the result only the segments whose rectangular areas is more than min_area:

j = 1;

for i = 1 : (length(seg) - 1)

band_width = seg(i+1) - seg(i);

maxi = max(t(1, seg(i):seg(i+1)));

if(maxi * band_width > min_area)

segmentation(j, 1) = seg(i);

segmentation(j, 2) = seg(i+1);

j = j + 1;

end;

end;

return;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [s] = find_valleys(t, val, offset, digit_width);

% find_valleys: Uses the method named peak-to-valleyin order to segment the

% pictures in digit images getting the two bounds of the each digit segment

% according to the statistical parameter digit_width = 18.

% The function is recursive; it uses the vector of the sums of the columns

% in the LP binary image supplied in the parameter "t".

% The function passes over the graph corresponding to this vector from left

% to right, bottom-up, incrementing at each recursive step the height that

% is examined on the graph (val). It checks the bandwidth of the first part

% of the signal: if it is greater than DIGIT_WIDTH, the function is

% recursively called after incrementing the height which is examined on

% the graph, (val). Otherwise, if the bandwidth is good, the two bounds of

% the signal with this bandwidth are taken as a digit segment, and the

% function is recursively called for the part of the image which is at

% the right side of the digit segment just found. This is done until the

% whole width of the picture has been passed over.

% Determining the points which are inferior to the examined hieght:

s = find(t < val);

% If no more than one point is found, incrementing val and recursively calling the function again.

if(length(s) < 2)

s = find_valleys(t, val + 1, offset, digit_width);

return;

end;

% If no point is found terminating:

if length(s) == 0

return;

end;

% Arranging the boundaries, so that if we have a big value at the beginning

% or the end of the picture the algorithm still works: in this case, the

% algorithm includes also those points.

if((t(1,1) >= val) & s(1) ~= 1)  %&  ? &&

s = [1 s];

end;

if((t(1, length(t)) >= val) & s(length(s)) ~= length(t))

s = [s length(t)];

end;

% Updating the real coordinates according to offset:

s = add(s, offset - 1);

% Cleaning points which are very close each other keeping only one of them.

s = clean(s, 3);

% While there is a bad segment in "s", (starting from the left side):

while bad_segm(s, digit_width) == 1

for i = 1: (length(s) - 1)

if (s(i + 1) - s(i)) > digit_width

% The subvector which does not correspond to a valid digit

% segemnt:

sub_vec = t(1, s(i) - offset + 1 : s(i+1) - offset + 1);

% Recursively, separating this bad segment in two or more valid

% digit segments:

s = [s(1 : i) find_valleys(sub_vec, val + 1, s(i), digit_width) s(i+1 : length(s))];

end;

end;

end;

return;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [bool] = bad_segm(s, digit_width);

% bad_segm: Returns true (1) iff there is a bad digit segment in s, namely,

% two points that ar distant one from the other by more than "digit_width".

if length(s) == 0

bool = 0;

return;

end;

tmp = s(1);

bool = 0;

for i = 2 : length(s)

if(s(i) - tmp) > digit_width

bool = 1;

return;

end;

tmp = s(i);

end;

return;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [t] = clean(s, val);

% clean: Cleans form the vector s all the poins which are distant the one

% from the other by less than "val" keeping only one of them.

t = [];

len = length(s);

i = 2;

j = 1;

while i <= len

while(s(i) - s(i-1) <= val)

i = i + 1;

if(i > len)

return;

end;

end;

if j == 1 | (s(i-1) - t(j-1)) > val   %|| ?  |

t(j) = s(i-1);

j = j + 1;

end;

t(j) = s(i);

j = j + 1;

i = i + 1;

end;

return;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [t] = add(s, val); % add: Adds "val" to each one of the entries in the vector s and returns the new vector. len = length(s); t = []; for i = 1:len     t(i) = s(i) + val; end; return;

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_39725594/article/details/115891958

智能推荐

js引入kindeditor富文本编辑器的使用_kindeditor.js-程序员宅基地

文章浏览阅读1.9k次。1. 在官网上下载KindEditor文件,可以删掉不需要要到的jsp,asp,asp.net和php文件夹。接着把文件夹放到项目文件目录下。2. 修改html文件,在页面引入js文件:<script type="text/javascript" src="./kindeditor/kindeditor-all.js"></script><script type="text/javascript" src="./kindeditor/lang/zh-CN.js"_kindeditor.js

STM32学习过程记录11——基于STM32G431CBU6硬件SPI+DMA的高效WS2812B控制方法-程序员宅基地

文章浏览阅读2.3k次,点赞6次,收藏14次。SPI的详情简介不必赘述。假设我们通过SPI发送0xAA,我们的数据线就会变为10101010,通过修改不同的内容,即可修改SPI中0和1的持续时间。比如0xF0即为前半周期为高电平,后半周期为低电平的状态。在SPI的通信模式中,CPHA配置会影响该实验,下图展示了不同采样位置的SPI时序图[1]。CPOL = 0,CPHA = 1:CLK空闲状态 = 低电平,数据在下降沿采样,并在上升沿移出CPOL = 0,CPHA = 0:CLK空闲状态 = 低电平,数据在上升沿采样,并在下降沿移出。_stm32g431cbu6

计算机网络-数据链路层_接收方收到链路层数据后,使用crc检验后,余数为0,说明链路层的传输时可靠传输-程序员宅基地

文章浏览阅读1.2k次,点赞2次,收藏8次。数据链路层习题自测问题1.数据链路(即逻辑链路)与链路(即物理链路)有何区别?“电路接通了”与”数据链路接通了”的区别何在?2.数据链路层中的链路控制包括哪些功能?试讨论数据链路层做成可靠的链路层有哪些优点和缺点。3.网络适配器的作用是什么?网络适配器工作在哪一层?4.数据链路层的三个基本问题(帧定界、透明传输和差错检测)为什么都必须加以解决?5.如果在数据链路层不进行帧定界,会发生什么问题?6.PPP协议的主要特点是什么?为什么PPP不使用帧的编号?PPP适用于什么情况?为什么PPP协议不_接收方收到链路层数据后,使用crc检验后,余数为0,说明链路层的传输时可靠传输

软件测试工程师移民加拿大_无证移民,未受过软件工程师的教育(第1部分)-程序员宅基地

文章浏览阅读587次。软件测试工程师移民加拿大 无证移民,未受过软件工程师的教育(第1部分) (Undocumented Immigrant With No Education to Software Engineer(Part 1))Before I start, I want you to please bear with me on the way I write, I have very little gen...

深度神经网络在训练初期的“梯度消失”或“梯度爆炸”的问题解决:数据标准化(Data Standardization),权重初始化(Weight Initialization),Dropout正则化等_在人工神经网络研究的初始阶段,辛顿针对训练过程中常出现的梯度消失现象, 提供相-程序员宅基地

文章浏览阅读101次。1986年,深度学习(Deep Learning)火爆,它提出了一个名为“深层神经网络”(Deep Neural Networks)的新型机器学习模型。随后几年,神经网络在图像、文本等领域取得了惊艳成果。但是,随着深度学习的应用范围越来越广泛,神经网络在遇到新的任务时出现性能下降或退化的问题。这主要是由于深度神经网络在训练初期面临着“梯度消失”或“梯度爆炸”的问题。_在人工神经网络研究的初始阶段,辛顿针对训练过程中常出现的梯度消失现象, 提供相

kill进程的几种方式_如何kill掉一个进程-程序员宅基地

文章浏览阅读461次。我们会先使用 ps、top 等命令获得进程的 PID,然后使用 kill 命令来杀掉该进程。killall和pkill是相似的,不过如果给出的进程名不完整,killall会报错。当然我们可以向进程发送一个终止运行的信号,此时的 kill 命令才是名至实归。,这样结束掉的进程不会进行资源的清理工作,所以如果你用它来终结掉 vim 的进程,就会发现临时文件 *.swp 没有被删除。命令:pid of xx进程,显示进程的进程号,同上pgrep。这是 kill 命令最主要的用法,也是本文要介绍的内容。_如何kill掉一个进程

随便推点

C++如何做字符串分割(5种方法)_c++ 字符串分割-程序员宅基地

文章浏览阅读10w+次,点赞93次,收藏352次。1、用strtok函数进行字符串分割原型: char *strtok(char *str, const char *delim);功能:分解字符串为一组字符串。参数说明:str为要分解的字符串,delim为分隔符字符串。返回值:从str开头开始的一个个被分割的串。当没有被分割的串时则返回NULL。其它:strtok函数线程不安全,可以使用strtok_r替代。示例://借助strtok实现split#include <string.h>#include <stdio.h&_c++ 字符串分割

2013第四届蓝桥杯 C/C++本科A组 真题答案解析_2013年第四届c a组蓝桥杯省赛真题解答-程序员宅基地

文章浏览阅读2.3k次。1 .高斯日记 大数学家高斯有个好习惯:无论如何都要记日记。他的日记有个与众不同的地方,他从不注明年月日,而是用一个整数代替,比如:4210后来人们知道,那个整数就是日期,它表示那一天是高斯出生后的第几天。这或许也是个好习惯,它时时刻刻提醒着主人:日子又过去一天,还有多少时光可以用于浪费呢?高斯出生于:1777年4月30日。在高斯发现的一个重要定理的日记_2013年第四届c a组蓝桥杯省赛真题解答

基于供需算法优化的核极限学习机(KELM)分类算法-程序员宅基地

文章浏览阅读851次,点赞17次,收藏22次。摘要:本文利用供需算法对核极限学习机(KELM)进行优化,并用于分类。

metasploitable2渗透测试_metasploitable2怎么进入-程序员宅基地

文章浏览阅读1.1k次。一、系统弱密码登录1、在kali上执行命令行telnet 192.168.26.1292、Login和password都输入msfadmin3、登录成功,进入系统4、测试如下:二、MySQL弱密码登录:1、在kali上执行mysql –h 192.168.26.129 –u root2、登录成功,进入MySQL系统3、测试效果:三、PostgreSQL弱密码登录1、在Kali上执行psql -h 192.168.26.129 –U post..._metasploitable2怎么进入

Python学习之路:从入门到精通的指南_python人工智能开发从入门到精通pdf-程序员宅基地

文章浏览阅读257次。本文将为初学者提供Python学习的详细指南,从Python的历史、基础语法和数据类型到面向对象编程、模块和库的使用。通过本文,您将能够掌握Python编程的核心概念,为今后的编程学习和实践打下坚实基础。_python人工智能开发从入门到精通pdf

vscode打开markdown文件 不显示图片 预览markdown文件_vscodemarkdown图片无法显示-程序员宅基地

文章浏览阅读3.2k次,点赞3次,收藏4次。vscode打开markdown文件 不显示图片 预览markdown文件_vscodemarkdown图片无法显示

推荐文章

热门文章

相关标签