Sei sulla pagina 1di 12

Chapter 3 Practical Work and Results

Chapter 3 Practical Work and Results

This chapter is a practical work of the Traffic signs detection and recognition
and final result.

3.1 Graphical User Interface (GUI) design form before running:

Figure 3-1 GUI Form before running

This form including:

1. Six axes.
2. Three Button.
3. Six static text.

18
Chapter 3 Practical Work and Results

3.2 Graphical User Interface (GUI) design form after running:

Figure 3-2 GUI Form after running

3.3 All functions using in this project:

Figure 3-3 Functions

19
Chapter 3 Practical Work and Results

Steps of implementing:

3.4 Color Detection

3.4.1 Extract red pixels from original image and changed to grayscale:

imgRed=imsubtract(imgStart(:,:,1),rgb2gray(imgStart));

a. Original Image b. Gray Scale Image


Figure 3-4.1 Extract red pixels

3.4.2 Extract blue pixels from original image and changed to grayscale:

imgBlue=imsubtract(imgStart(:,:,3),rgb2gray(imgStart));

a. Original Image b. Gray Scale Image


Figure 3-4.2 Extract blue pixels

20
Chapter 3 Practical Work and Results

3.4.3 Changed grayscale of red to binary image:

imgRedBW=im2bw(imgRed,0.13);

a. Grayscale of red b. Binary Image


Figure 3-4.3 Binary image (Red)

3.4.4 Changed grayscale of blue to binary image:

imgBlueBW=im2bw(imgBlue,0.13);

a. Grayscale of blue b. Binary Image


Figure 3-4.4 Binary image (Blue)

21
Chapter 3 Practical Work and Results

3.4.5 Fill red binary image:

ImgFillRed = imfill(imgRedBW,'holes');

a. Binary Image b. Filled Binary Image


Figure 3-4.5 Fill red image

3.4.6 Fill blue binary image:

ImgFillBlue = imfill(imgBlueBW,'holes');

a. Binary Image b. Filled Binary Image


Figure 3-4.6 Fill blue image

22
Chapter 3 Practical Work and Results

3.4.7 Remove noise of red image:

ImgDelAreaRed=bwareaopen(ImgFillRed,300);

a. Filled Binary Image b. Binary Image without noise


Figure 3-4.7 Remove noise of red image

3.4.8 Remove noise of blue image:

imgBlueBW=im2bw(imgBlue,0.13);

a. Filled Binary Image b. Binary Image without noise


Figure 3-4.8 Remove noise of blue image

23
Chapter 3 Practical Work and Results

3.4.9 Merge the red and blue image:

imgMergRB = imadd(imgRedBW, imgBlueBW);

a. Binary Image without noise (Red) b. Binary Image without noise (Blue)

Figure 3.4.9 Merge red and blue image

24
Chapter 3 Practical Work and Results

3.5 Shape Detection

3.5.1 Determine the number of detected image:

[img, num] = bwlabel(InputImg,4);

Output:

num=2 (Detected two objects).

3.5.2 Obtain the properties of detected objects:

f=regionprops(img,'BoundingBox','Area','Perimeter');

BoundingBox Returns the smallest rectangle containing the region


Area Returns a scalar that specifies the actual number of pixels in the region.
Perimeter Returns a scalar that specifies the distance around the boundary of the region.
Table 3-5.2 Properties of detected object

3.5.3 Detect shapes rules:

1 Circle (Perimeter^2)/(4*pi*Area) < 1.1

2 Square (a*b)-Area) = 0

3 Triangle (a*b)/2)-Area) = 0

Table 3-5.3 Detect shapes rules

25
Chapter 3 Practical Work and Results

3.5.4 Detect traffic signs:

rectangle('position',Boxes(i).Box,'EdgeColor','y','LineWidth',3);

a. Filled Binary Image b. Binary Image without noise


Figure 3-5.4 Detect traffic signs

26
Chapter 3 Practical Work and Results

3.6 Segmentation

3.6.1 Extract detected traffic sign of image:

subImage= imcrop(InputImg, Boxes(i).Box);

3.6.2 Resize extracted traffic sign of image:

resize=imresize(subImage,[128,128]);

a. Circle traffic sign b. Circle traffic sign


Figure 3-6.2 Resize extracted traffic sign of image

27
Chapter 3 Practical Work and Results

3.7 Recognition

3.7.1 Extract edge from segmented image:

grayImage = rgb2gray(resize);
cannyImage = edge(grayImage,'canny');

Figure 3-7.1 Extract edge from segmented image

3.7.2 Getting information from database:

img=struct('edge',[],'name',[]);
rootDir = pwd;
imgFiles = dir(fullfile(rootDir,'Train','*.jpg'));
for i=1:size(imgFiles,1)
RGB = imread(strcat(fullfile(rootDir,'Train/'),imgFiles(i).name));
name= strtok(imgFiles(i).name,'.');
img(i).name= strtok(name,'(');
grayImage = rgb2gray(RGB);
cannyImage = edge(grayImage,'canny');
img(i).edge=cannyImage;
end

28
Chapter 3 Practical Work and Results

3.7.3 Match extracted signs with database and getting information about sign

size(find(imgRec(j).edge~=cannyImage),1)<500;

a. Circle traffic sign b. Circle traffic sign


Name:50 Kilometer Name: Keep Left
Figure 3-7.3 Match extracted sign

3.8 Result of the work

Figure 3.8 Result of the work

29

Potrebbero piacerti anche