✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
交通标志检测技术的研究,对于现代智能交通的发展具有重大意义.文中提出一种基于颜色检测的算法,首先,将原彩色图像转化为灰度图像,同时,利用RGB颜色模型中的阈值分割将原图像转化为二值图像,然后通过Canny算子实现边缘检测,再对边缘检测结果进行封闭区域填充处理并再次进行边缘检测,从而得到目标区域的坐标范围,进而实现图像中交通标志部分的准确定位,最后通过图像之间的算术运算去除背景,完成交通标志的检测.实验结果表明,该算法可以快速准确地检测出图像中的交通标志,准确率达到93.75%,具有速度快,准确度好,易于理解和实现等优点.
⛄ 部分代码
%To crop the segment from source Image
input = output;
values = unique(input(input~=0));
count = numel(values);
Area = zeros(count,1);
[row,col] = size(input);
%For all the idnetified segments
for indexing = 1:count
top_i = 0;
top_j = 0;
bottom_i = 0;
bottom_j = 0;
flag = 0;
%To identify, where the segment begins at the north (- top)
for i = 1:row
for j = 1:col
if(input(i,j) == values(indexing))
top_i = i;
top_j = j;
flag = 1;
break
end
end
if(flag == 1)
break
end
end
flag = 0;
%To identify, where the segment ends at the south (- bottom)
for i = row:-1:1
for j = 1:col
if(input(i,j) == values(indexing))
bottom_i = i;
bottom_j = j;
flag = 1;
break
end
end
if(flag == 1)
break
end
end
flag = 0;
%To identify, where the segment ends at from the east (-right)
for i = col:-1:1
for j = 1:row
if(input(j,i) == values(indexing))
right_i = j;
right_j = i;
flag = 1;
break
end
end
if(flag == 1)
break
end
end
flag = 0;
%To identify, where the segment begins starts at the west (-left)
for j = 1:col
for i = 1:row
if(input(i,j) == values(indexing))
left_i = i;
left_j = j;
flag = 1;
break
end
end
if(flag == 1)
break
end
end
%Borders of Square Calculation - To form square
square_right_row_top = top_i - 5;
square_right_col_top = right_j + 5;
square_left_row_top = square_right_row_top;
square_left_col_top = left_j - 5;
square_left_row_bottom = bottom_i + 5;
square_left_col_bottom = square_left_col_top;
square_right_row_bottom = square_left_row_bottom;
square_right_col_bottom = square_right_col_top;
%To plot the identified shape on the original image
width = square_right_col_top - square_left_col_top;
height = square_left_row_bottom - square_left_row_top;
Area(indexing) = width * height;
if(Area(indexing) > 2000)
figure
imshow(source)
rectangle('Position',[square_left_col_top,square_left_row_top,width,height],'LineWidth',5,'EdgeColor','r'),title('Identified Signage Information');
%To analyse the cropped Image
%Extracting the segment from the source
cropped_Image = source(square_left_row_top:square_right_row_bottom,square_left_col_top:square_right_col_bottom,:);
figure
imshow(cropped_Image),title('Extracted Image');
%To alarm, The sign has been identified
[y,fs] = audioread('Horn.wav');
sound = audioplayer(y,fs);
play(sound);
%Optical character Recognition
% text = ocr(cropped_Image);
end
end
⛄ 运行结果
⛄ 参考文献
[1]娄月新. 基于Matlab的交通标志识别系统设计与实现[J]. 电脑编程技巧与维护, 2014(6):2.