资源简介
对获取到的车牌图像用MATLAB进行预处理(包括灰度化处理,二值化处理,中值滤波 等)边缘化处理、形态学处理来确定车牌的位置。
代码片段和文件信息
close all;
clear all;
clc;
pic=imread(‘che1.jpg‘);
figure(1);
imshow(pic);
picR=pic(::1);
picG=pic(::2);
picB=pic(::3);
g=rgb2gray(pic);
gmed=medfilt2(g);
[rc]=size(g);
figure(2);
imshow(gmed);
edgpic=edge(gmed‘roberts‘0.01);
figure(3);
imshow(edgpic);
data=edgpic;
%形态学处理
pic2=bwmorph(edgpic‘clean‘);
pic2=imclose(pic2strel(‘rectangle‘[830]));
pic2=imopen(pic2strel(‘rectangle‘[519]));
pic2=bwmorph(pic2‘dilate‘3);
figure(4);
imshow(pic2);
%车牌定位
for i=1:3
red(i)=0;gre(i)=0;blu(i)=0;
end
poz=zeros(rc);
dayblue=0;
%记录色彩比对像素点
%%利用色彩模型比对
for i=1:r
for j=1:c
if(picR(ij)>=0&&picR(ij)<25)
red(1)=1;
end
if(picG(ij)>20&&picG(ij)<80)
gre(1)=1;
end
if(picB(ij)>40&&picB(ij)<180)
blu(1)=1;
end
if(red(1)==1&&gre(1)==1&&blu(1)==1)
poz(ij)=255;
dayblue=dayblue+1;
end
for k=1:3
red(k)=0;gre(k)=0;blu(k)=0;
end
end
end
% if(red(1)==1&&gre(1)==1&&blu(1)==1)
% poz(ij1)=255;dayblue=dayblue+1;
% end
dilatenum=2;
figure(5);
imshow(poz(::));
%title(‘位置信息矩阵B‘);
pic3=zeros(rc);
for i=1:r
for j=1:c
if(pic2(ij)==1&&poz(ij)==255)
pic3(ij)=1;
end
end
end
%figure;
%imshow(pic3);
pic3=bwmorph(pic3‘clean‘3);
pic3=bwmorph(pic3‘dilate‘1);
pic3=imclose(pic3strel(‘rectangle‘[830]));
pic3=imopen(pic3strel(‘rectangle‘[519]));
pic3=bwmorph(pic3‘dilate‘dilatenum);
%%计算联通区域面积
figure(6);
imshow(pic3);
%title(‘位置信息矩阵C‘);
%确定端点坐标
pozitionR1=0;
pozitionR2=0;
for i=1:r
RR(i)=sum(pic3(i:));
end
judgeR=40;
k=0;
for i=1:r
if(pozitionR1==0&&RR(i)~=0)
pozitionR1=i;
end
if(pozitionR1~=0&&pozitionR2==0&&RR(i)==0)
pozitionR2=i;
k=pozitionR2-pozitionR1;
end
if(k~=0&&k pozitionR1=0;
pozitionR2=0;
k=0;
end
if(k>judgeR)
break;
end
end
pozitionC1=0;
pozitionC2=0;
for i=1:c
CC(i)=sum(pic3(:i));
end
judgeC=180;
k=0;
for i=1:c
if(pozitionC1==0&&CC(i)~=0)
pozitionC1=i;
end
if(pozitionC1~=0&&pozitionC2==0&&CC(i)==0)
pozitionC2=i;
k=pozitionC2-pozitionC1;
end
if(k~=0&&k pozitionC1=0;
pozitionC2=0;
k=0;
end
if(k>judgeC)
break;
end
end
chepaitu=zeros([pozitionR2-pozitionR1pozitionC2-pozitionC13]‘uint8‘);
for i=pozitionR1:pozitionR2
for j=pozitionC1:pozitionC2
chepaitu(i-pozitionR1+1j-pozitionC1+11)=picR(ij);
chepaitu(i-pozitionR1+1j-pozitionC1+12)=picG(ij);
chepaitu(i-pozitionR1+1j-pozitionC1+13)=picB(ij);
end
end
figure(7);
imshow(chepaitu);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6354689 2019-09-17 18:58 车牌定位\che1.jpg
文件 2975 2019-10-09 14:37 车牌定位\L1.m
相关资源
- Canny边缘检测Matlab代码
- matlab车牌定位识别,完整案例
- 联合双边滤波代码matlab
- GVFSnake(matlab)边缘检测和图像分割
- 机动车辆车牌定位检测算法研究
- 基于数字图像处理对蔬菜叶面积的测
- Matlab完整版车牌定位识别
- 基于MATLAB的图像边缘检测算法的仿真
- 形态学边缘检测
- 基于matlab车牌识别
- 图像处理-边缘检测和特征提取MATLAB源
- 基于边缘直方图的图像检索
- 指纹识别数字图像处理+模式识别+机器
- 8邻域算法边缘跟踪
- 基于MATLAB中GUI的完整的车牌识别程序
- MATLAB开发了一套车牌识别系统,完成
- Matlab图像处理-图像去噪边缘增强
- matlab车牌定位识别,完整案例(基于
- edges-master
- 论文研究-基于MATLAB的数字图像边缘检
- 基于Matlab的几种常用边缘检测算子的
- 亚像素边缘检测的matlab代码,比一般
- matlab图像边缘检测GUI
- matlab 车牌边缘检测
- 车牌定位及字符识别的MATLAB程序
- 基于阈值分割的车牌定位识别的matl
- matlab车牌定位程序
- 基于matlab的八个方向sobel图像边缘检测
- 灰度图求边缘点
- matlab实验显示RGB分量图像,边缘检测
评论
共有 条评论