- 1
- 0
- 约9.03千字
- 约 17页
- 2021-06-20 发布于湖南
- 举报
。
基于 Matlab 的车牌定位与分割
经典算法
I=imread(car.jpg); %读取图像
figure(); subplot(3,2,1),imshow(I), title( 原始图像 );
I1=rgb2gray(I);% 转化为灰度图像
subplot(3,2,2),imshow(I1),title( 灰度图像 );
I2=edge(I1,robert,0.09,both);% 采用 robert 算子进行边缘检
测
-可编辑修改 -
。
subplot(3,2,3),imshow(I2),title( 边缘检测后图像 );
se=[1;1;1]; % 线型结构元素
I3=imerode(I2,se); %腐蚀图像
subplot(3,2,4),imshow(I3),title( 腐蚀后边缘图像 );
se=strel(rectangle,[25,25]); 矩形结构元素
I4=imclose(I3,se);% 图像聚类、填充图像
subplot(3,2,5),imshow(I4),title( 填充后图像 );
-可编辑修改 -
。
I5=bwareaopen(I4,2000);% 去除聚团灰度值小于 2000 的部分
subplot(3,2,6),imshow(I5),title( 形态滤波后图像 );
[y,x,z]=size(I5);
I6=double(I5);
Y1=zeros(y,1);
for i=1:y
for j=1:x
-可编辑修改 -
。
if(I6(i,j,1)==1)
Y1(i,1)= Y1(i,1)+1;
end
end
end
[temp MaxY]=max(Y1);
figure();
subplot(3,2,1),plot(0:y-1,Y1),title( 行方向像素点灰度值累计
和),xlabel( 行值 ),ylabel( 像素 );
% 求的车牌的行起始位置和终止位置
PY1=MaxY;
while ((Y1(PY1,1)=50)(PY11))
PY1=PY1-1;
end
PY2=MaxY;
while ((Y1(PY2,1)=50)(PY2y))
-可编辑修改 -
。
PY2=PY2+1;
end
IY=I(PY1:PY2,:,:);
X1=zeros(1,x);
for j=1:x
for i=PY1:PY2
if(I6(i,j,1)==1)
X1(1,j)= X1(1,j)+1;
end
end end
subplot(3,2,2),plot(0:x-1,X1),title( 列方向像素点灰度值累计
和),xlabel( 列值 ),y
原创力文档

文档评论(0)