光电图像处理课程设计车牌提取设计.docx
《光电图像处理课程设计车牌提取设计.docx》由会员分享,可在线阅读,更多相关《光电图像处理课程设计车牌提取设计.docx(19页珍藏版)》请在冰点文库上搜索。
光电图像处理课程设计车牌提取设计
光电图像处理课程设计说明书
题目 车牌提取设计
系(部)电子与通信工程系
专业(班级)09光电2班
姓名
学号
目录
摘要3
关键词3
1MATLAB简介4
2车牌定位的仿真4
2.1原始图像CALLBACK:
4
2.2灰度图CALLBACK:
4
2.3边缘检测图CALLBACK:
5
2.4腐蚀图CALLBACK:
5
2.5去噪图CALLBACK:
6
2.6填充图CALLBACK:
6
2.7行合理位置图CALLBACK:
7
2.8定位图CALLBACK:
8
2.9回原图CALLBACK:
9
3车牌定位的分析10
4车牌定位的界面设计10
4.1原始图像CALLBACK:
11
4.2定位图CALLBACK:
12
5心得体会13
参考文献13
摘要
关键词
车牌定位、灰度图、边缘检测图、腐蚀图、去噪图、填充图、Matlab
1MATLAB简介
2车牌定位的仿真
2.1原始图像CALLBACK:
functionpushbutton1_Callback(hObject,eventdata,handles)
[name,path]=uigetfile('*.*','');
file=[path,name];
x=imread(file);
axes(handles.axes1);
imshow(x);
handles.img=x;
guidata(hObject,handles);
出图:
2.2灰度图CALLBACK:
functionradiobutton1_Callback(hObject,eventdata,handles)
x=handles.img;
y=rgb2gray(x);
axes(handles.axes1);
imshow(y);
handles.img1=y;
guidata(hObject,handles);
出图:
2.3边缘检测图CALLBACK:
functionradiobutton2_Callback(hObject,eventdata,handles)
x=handles.img1;
y=edge(x,'robert',0.15,'both');
axes(handles.axes1);
imshow(y);
handles.img2=y;
guidata(hObject,handles);
出图:
2.4腐蚀图CALLBACK:
functionradiobutton3_Callback(hObject,eventdata,handles)
x=handles.img2;
se=[1;1;1];
y=imerode(x,se);
axes(handles.axes1);
imshow(y);
handles.img3=y;
guidata(hObject,handles);
出图:
2.5去噪图CALLBACK:
functionradiobutton4_Callback(hObject,eventdata,handles)
x=handles.img3;
se=strel('rectangle',[25,25]);
y=imclose(x,se);
axes(handles.axes1);
imshow(y);
handles.img4=y;
guidata(hObject,handles);
出图:
2.6填充图CALLBACK:
functionradiobutton5_Callback(hObject,eventdata,handles)
x=handles.img4;
y=bwareaopen(x,2000);
axes(handles.axes1);
imshow(y);
handles.img5=y;
guidata(hObject,handles);
出图:
2.7行合理位置图CALLBACK:
functionradiobutton6_Callback(hObject,eventdata,handles)
I=handles.img;
I1=rgb2gray(I);
I2=edge(I1,'robert',0.15,'both');
se=[1;1;1];
I3=imerode(I2,se);
se=strel('rectangle',[25,25]);
I4=imclose(I3,se);
I5=bwareaopen(I4,2000);
[y,x,z]=size(I5);
myI=double(I5);
tic
Blue_y=zeros(y,1);%y=zeros(450,1)
fori=1:
y
forj=1:
x
if(myI(i,j,1)==1)
Blue_y(i,1)=Blue_y(i,1)+1;
end
end
end
[tempMaxY]=max(Blue_y);
PY1=MaxY;
while((Blue_y(PY1,1)>=5)&&(PY1>1))
PY1=PY1-1;
end
PY2=MaxY;
while((Blue_y(PY2,1)>=5)&&(PY2PY2=PY2+1;
end
IY=I(PY1:
PY2,:
:
);
axes(handles.axes1);
imshow(IY);
出图:
2.8定位图CALLBACK:
functionpushbutton3_Callback(hObject,eventdata,handles)
x=handles.img;
axes(handles.axes1);
imshow(x);
functionradiobutton7_Callback(hObject,eventdata,handles)
I=handles.img;
I1=rgb2gray(I);
I2=edge(I1,'robert',0.15,'both');
se=[1;1;1];
I3=imerode(I2,se);
se=strel('rectangle',[25,25]);
I4=imclose(I3,se);
I5=bwareaopen(I4,2000);
[y,x,z]=size(I5);
myI=double(I5);
tic
Blue_y=zeros(y,1);%y=zeros(450,1)
fori=1:
y
forj=1:
x
if(myI(i,j,1)==1)
Blue_y(i,1)=Blue_y(i,1)+1;
end
end
end
[tempMaxY]=max(Blue_y);
PY1=MaxY;
while((Blue_y(PY1,1)>=5)&&(PY1>1))
PY1=PY1-1;
end
PY2=MaxY;
while((Blue_y(PY2,1)>=5)&&(PY2PY2=PY2+1;
end
IY=I(PY1:
PY2,:
:
);
Blue_x=zeros(1,x);
forj=1:
x
fori=PY1:
PY2
if(myI(i,j,1)==1)
Blue_x(1,j)=Blue_x(1,j)+1;
end
end
end
PX1=1;
while((Blue_x(1,PX1)<3)&&(PX1PX1=PX1+1;
end
PX2=x;
while((Blue_x(1,PX2)<3)&&(PX2>PX1))
PX2=PX2-1;
end
PX1=PX1-1;
PX2=PX2+1;
dw=I(PY1:
PY2-8,PX1:
PX2,:
);
axes(handles.axes1);
imshow(dw);
出图:
2.9回原图CALLBACK:
functionpushbutton3_Callback(hObject,eventdata,handles)
x=handles.img;
axes(handles.axes1);
imshow(x);
出图:
3车牌定位的分析
由数码相机拍摄的原始图像在形成传输或变换过程中,会受到光学系统失真、系统噪声、曝光不足或过量、相对运动等因素的影响,因此在图像处理之前必须进行预处理,包括去除噪声、边界增强、增加亮度等等。
原始图像的程序,首先通过路径、名字(path、name)保存在文件中,再经imread读取图片,最后用imshow显示图片。
其间为便于之后程序调用图像,用handles.img=x保存图片。
输入的彩色图像包含大量颜色信息,会占用较多的存储空间,且处理时也会降低系统的执行速度,因此常将彩色图像转换为灰度图像,灰度图调用函数y=rgb2gray(x)。
边缘检测可以使图像的轮廓更加突出,调用函数y=edge(x,'robert',0.15,'both')。
腐蚀图使边缘化后的图像去掉周围不需提取的信息,调用函数se=[1;1;1];y=imerode(x,se)。
然后去噪图是进一步对图像信息的刷选,函数为se=strel('rectangle',[25,25]);y=imclose(x,se);填充图是对腐蚀图进行扩充,使需要的信息量增大,调用函数y=bwareaopen(x,2000),合理调整各个参数可以选择所需车牌信息的区域。
合理位置定位图是计算边缘图像的投影面积,寻找峰谷点,大致确定车牌位置,最后再计算此连通域内的宽高比,剔除不在域值范围内的连通域,最后确定定位图。
4车牌定位的界面设计
界面图:
4.1原始图像CALLBACK:
functionpushbutton1_Callback(hObject,eventdata,handles)
[name,path]=uigetfile('*.*','');
file=[path,name];
x=imread(file);
axes(handles.axes1);
imshow(x);
handles.img=x;
guidata(hObject,handles);
出图:
4.2定位图CALLBACK:
functionpushbutton3_Callback(hObject,eventdata,handles)
x=handles.img;
axes(handles.axes1);
imshow(x);
functionradiobutton7_Callback(hObject,eventdata,handles)
I=handles.img;
I1=rgb2gray(I);
I2=edge(I1,'robert',0.15,'both');
se=[1;1;1];
I3=imerode(I2,se);
se=strel('rectangle',[25,25]);
I4=imclose(I3,se);
I5=bwareaopen(I4,2000);
[y,x,z]=size(I5);
myI=double(I5);
tic
Blue_y=zeros(y,1);%y=zeros(450,1)
fori=1:
y
forj=1:
x
if(myI(i,j,1)==1)
Blue_y(i,1)=Blue_y(i,1)+1;
end
end
end
[tempMaxY]=max(Blue_y);
PY1=MaxY;
while((Blue_y(PY1,1)>=5)&&(PY1>1))
PY1=PY1-1;
end
PY2=MaxY;
while((Blue_y(PY2,1)>=5)&&(PY2PY2=PY2+1;
end
IY=I(PY1:
PY2,:
:
);
Blue_x=zeros(1,x);
forj=1:
x
fori=PY1:
PY2
if(myI(i,j,1)==1)
Blue_x(1,j)=Blue_x(1,j)+1;
end
end
end
PX1=1;
while((Blue_x(1,PX1)<3)&&(PX1PX1=PX1+1;
end
PX2=x;
while((Blue_x(1,PX2)<3)&&(PX2>PX1))
PX2=PX2-1;
end
PX1=PX1-1;
PX2=PX2+1;
dw=I(PY1:
PY2-8,PX1:
PX2,:
);
axes(handles.axes1);
imshow(dw);
出图:
5心得体会
参考文献
1、张弘.数字图像处理[M].机械工业出版社;
2、含数值计算、绘图、界面仿真内容的MATLAB书籍;
3、相关网站。