智能网联汽车概论课程设计3交通标志识别.docx

上传人:b****3 文档编号:2807712 上传时间:2022-11-15 格式:DOCX 页数:12 大小:250.17KB
下载 相关 举报
智能网联汽车概论课程设计3交通标志识别.docx_第1页
第1页 / 共12页
智能网联汽车概论课程设计3交通标志识别.docx_第2页
第2页 / 共12页
智能网联汽车概论课程设计3交通标志识别.docx_第3页
第3页 / 共12页
智能网联汽车概论课程设计3交通标志识别.docx_第4页
第4页 / 共12页
智能网联汽车概论课程设计3交通标志识别.docx_第5页
第5页 / 共12页
点击查看更多>>
下载资源
资源描述

智能网联汽车概论课程设计3交通标志识别.docx

《智能网联汽车概论课程设计3交通标志识别.docx》由会员分享,可在线阅读,更多相关《智能网联汽车概论课程设计3交通标志识别.docx(12页珍藏版)》请在冰豆网上搜索。

智能网联汽车概论课程设计3交通标志识别.docx

智能网联汽车概论课程设计3交通标志识别

课程设计——交通标志识别

交通标志如图1所示,编写MATLAB程序,识别图1中的限速50标志。

图1限速标志

解:

本例交通标志识别步骤如下。

(1)读取原始图像。

(2)颜色空间转换。

(3)图像二值化。

(4)图像优化处理。

(5)图像特征提取。

(6)裁剪目标区域。

利用MATLAB编写交通标志识别程序如下。

序号

程序

功能

1

2

3

4

5

6

clearall

closeall

I=imread('C:

\DocumentsandSettings\h6.jpg');

figure

(1)

imshow(I)

title('交通标志原始图像')

读取交通标志图像

7

8

9

10

Hsv=rgb2hsv(I);

figure

(2)

imshow(Hsv)

title('Hsv图像')

颜色空间转换

11

12

13

14

15

16

17

18

19

20

I1=Hsv(:

:

1);

figure(3)

imshow(I1)

title('提取亮度后的图像')

BW=roicolor(I1,0.0277,0.032);

figure(4)

imshow(BW)

title('二值化图像');

se=strel('disk',10);

BW1=imclose(BW,se);

图像二值化

21

22

23

24

25

26

27

28

29

SE=ones(10);

PZ=imdilate(BW1,SE);

figure(5)

imshow(PZ)

title('膨胀后的图像')

TC=bwfill(PZ,'holes');

figure(6)

imshow(TC)

title('填充后的图像')

图像优化处理

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

 

85

86

87

 

88

89

90

 

91

92

93

 

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

L=bwlabeln(TC);

S=regionprops(L,'Area','Centroid','BoundingBox');

cent=cat(1,S.Centroid);

boud=cat(1,S.BoundingBox);

Len=length(S);

t2=0;t4=0;t7=0;t8=0;

fori=1:

3

Max(i)=0;

MR(i)=0;

MX(i)=0;

MY(i)=0;

end

Max1=0;Max2=0;Max3=0;ttq=0;

fori=1:

Len

if(S(i).Area>=Max1)

Max3=Max2;Max(3)=Max

(2);

Max2=Max1;Max

(2)=Max

(1);

Max1=S(i).Area;Max

(1)=i;

elseif(S(i).Area>=Max2)

Max3=Max2;Max(3)=Max

(2);

Max2=S(i).Area;Max

(2)=i;

elseif(S(i).Area>=Max3)

Max3=S(i).Area;Max(3)=i;

end

end

end

end

if((Max

(1)&&Max

(2)&&Max(3))==0)

imshowage=0;

errordlg('没有路标!

','基本信息');

else

imshowage=1;

fori=1:

3

tz(i)=0;

Mblen(i)=0;

Mbwid(i)=0;

end

[hang,lie,r]=size(BW);

fori=1:

3

X=cent(Max(i),1);Y=cent(Max(i),2);

MX(i)=round(X);MY(i)=round(Y);

bx=boud(Max(i),1);

by=boud(Max(i),2);

blen=boud(Max(i),4);

bwid=boud(Max(i),3);

bx1=round(bx);

by1=round(by);

Mblen(i)=round(blen);

Mbwid(i)=round(bwid);

if(blen>=bwid)

MR=bwid;

else

MR=blen;

end

if(MX(i)+round(MR/4)<=lie&&MY(i)+round(MR/6)<=hang&&TC(MY(i)+round(MR/6),MX(i)+round(MR/4))==1)

t2=1;

end

if(MX(i)-round(MR/4)>0&&MY(i)-round(MR/6)>0&&TC(MY(i)-round(MR/6),MX(i)-round(MR/4))==1)

t4=1;

end

if(MY(i)+round(MR/6)<=hang&&MX(i)-round(MR/4)>0&&TC(MY(i)+round(MR/6),MX(i)-round(MR/4))==1)

t7=1;

end

if(MY(i)-round(MR/6)>0&&MX(i)+round(MR/4)<=lie&&TC(MY(i)-round(MR/6),MX(i)+round(MR/4))==1)

t8=1;

end

if(t2&&t4&&t7&&t8&&S(Max(i)).Area/(hang*lie)>0.01)

tz(i)=1;

t2=0;t4=0;t7=0;t8=0;

end

end

end

iftz(3)==1

YC=bwareaopen(TC,Max3);

elseiftz

(2)==1

YC=bwareaopen(TC,Max2);

elseiftz

(2)==0

YC=bwareaopen(TC,Max1);

figure(7)

imshow(YC)

title('提取待测目标图像')

else

(((tz

(1)+tz

(2)+tz(3))==0));

imshowage=0;

errordlg('没有路标!

','基本信息');

end

flag=[000];

fori=1:

3

if(tz(i)==1)

high=Mblen(i);

liezb=round(MX(i)-Mbwid(i)/2);

hangzb=round(MY(i)-Mblen(i)/2);

width=Mbwid(i);

flag(i)=1;

Iresult=imcrop(I,[liezbhangzbwidthhigh]);

if(i==1)

imwrite(Iresult,'result_1.bmp','bmp');

elseif(i==2)

imwrite(Iresult,'result_2.bmp','bmp');

elseif(i==3)

imwrite(Iresult,'result_3.bmp','bmp');

end

end

end

图像特征提取

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

ifimshowage==1

fori=1:

3

if(flag

(1)==1)

figure;imshow('result_1.bmp')

end

if(flag

(2)==1)

figure;imshow('result_2.bmp')

end

if(flag(3)==1)

figure;imshow('result_3.bmp')

end

end

else

imshow('err.jpg')

end

裁剪目标区域

输出结果如图2~9所示。

图2道路交通标志原始图像

图3道路交通标志的Hsv图像

图4道路交通标志提取亮度后的图像

图5道路交通标志二值化图像

图6道路交通标志膨胀后图像

图7道路交通标志充填后图像

图8道路交通标志待测目标图像

图9道路交通标志识别结果

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1