[GA-HOG-GRNN multi-traffic sign detection] Matlab simulation of traffic sign detection and recognition in natural scenes - GRNN neural network algorithm based on HOG feature extraction and GA optimization

1. Software version

matlab2017b。

3. Relevant principles

Specific requirements:

1. Image input

2. Convert to grayscale image

3. Image edge detection

4. Image erosion

5. Image Fill

6. Remove distractions from pictures

7. Accurately locate the location of the traffic sign from the picture, and open a figure again to display it (cut out)

8. Convert the cutout traffic signs to grayscale images

9. Using dynamic threshold method to convert traffic signs into binary images

10. Process images with morphological filtering

11. Recognition process {1. Establish a template library, all of which are binary traffic signs

12. Match the traffic signs obtained above with the template library

13. Display a figure and output the name of the prompt traffic sign }

Common feature extraction scheme:

HOG feature method:

The principle is as follows:

1. HOG features :

       Histogram of Oriented Gradient ( HOG ) feature is a feature descriptor used for object detection in computer vision and image processing. It constructs features by computing and counting the gradient direction histograms of local regions of the image.

( 1 ) Main idea:

       In an image, the appearance and shape of local objects can be well described by gradients or edge directional density distributions. (Essential: statistics of gradients, and gradients mainly exist at the edges).

( 2 ) The specific implementation method is:

       The image is first divided into small connected regions, which we call cell units. Then the gradient or edge direction histogram of each pixel in the cell unit is collected. Finally, these histograms are combined to form a feature descriptor.

( 3 ) Improve performance:

       Contrast normalization ( contrast-normalized ) is performed on these local histograms in a larger range of the image (we call it an interval or block ) . The method used is: first calculate each histogram in this interval ( block ) The density in the interval is then normalized for each cell unit in the interval according to this density. After this normalization, you can get better effects on lighting changes and shadows.

( 4 ) Advantages:

       Compared with other feature description methods, HOG has many advantages. First of all, since HOG operates on the local grid cells of the image, it can maintain good invariance to the geometric and optical deformation of the image, which only appear in a larger spatial field. Secondly, under the conditions of coarse airspace sampling, fine direction sampling, and strong local optical normalization, as long as pedestrians can generally maintain an upright posture, pedestrians can be allowed to have some subtle body movements. It is ignored without affecting the detection effect. Therefore , the HOG feature is particularly suitable for human detection in images.

2. The implementation process of the HOG feature extraction algorithm:

Approximate process:

The HOG feature extraction method is to take an image (the target or scan window you want to detect):

1 ) Grayscale (see the image as a three-dimensional image of x, y, z (grayscale));

2 ) Use Gamma correction method to standardize the color space of the input image (normalization); the purpose is to adjust the contrast of the image, reduce the influence of local shadows and illumination changes in the image, and at the same time can suppress the interference of noise;

3 ) Calculate the gradient (including size and direction) of each pixel of the image; mainly to capture contour information, while further weakening the interference of illumination.

4 ) Divide the image into small cells (eg 6*6 pixels /cell );

5 ) Count the gradient histogram of each cell (the number of different gradients) to form the descriptor of each cell ;

6 ) Each several cells are formed into a block (for example, 3*3 cells /block ), and the feature descriptors of all cells in a block are connected in series to obtain the HOG feature descriptor of the block .

7 ) Concatenate the HOG feature descriptors of all blocks in the image image to get the HOG feature descriptor of the image (the target you want to detect) . This is the final feature vector that can be used for classification.

3. Part of the program

clc;
clear;
close all;
warning off;
addpath 'func\'
addpath 'func\hog_catch\'



load test_image.mat
load alg1.mat

 
    
if  isempty(X4) == 0 & isempty(X5) == 1 & isempty(X6) == 1;
    ftest  = func_feature1(X4);
    yout   = round(net1(ftest'));
    
    figure;
    subplot(121);
    imshow(X3);
    subplot(122);
    imshow(X4);
    if yout == 1
       title('识别结果为:非机动车行驶');    
    end
    if yout == 2
       title('减速让车');    
    end
    if yout == 3
       title('禁止鸣笛');    
    end
    if yout == 4
       title('禁止左转');    
    end
    if yout == 5
       title('慢');    
    end
    if yout == 6
       title('人行通道');    
    end
    if yout == 7
       title('限制速度');    
    end
    if yout == 8
       title('右转');    
    end
end





if  isempty(X4) == 0 & isempty(X5) == 0 & isempty(X6) == 1;
    ftest   = func_feature1(X4);
    yout1   = round(net1(ftest'));
    ftest   = func_feature1(X5);
    yout2   = round(net1(ftest')); 
    
    figure;
    subplot(131);
    imshow(X3);
    subplot(132);
    imshow(X4);
    if yout1 == 1
       title('识别结果为:非机动车行驶');    
    end
    if yout1 == 2
       title('减速让车');    
    end
    if yout1 == 3
       title('禁止鸣笛');    
    end
    if yout1 == 4
       title('禁止左转');    
    end
    if yout1 == 5
       title('慢');    
    end
    if yout1 == 6
       title('人行通道');    
    end
    if yout1 == 7
       title('限制速度');    
    end
    if yout1 == 8
       title('右转');    
    end
    
    subplot(133);
    imshow(X5);
    if yout2 == 1
       title('识别结果为:非机动车行驶');    
    end
    if yout2 == 2
       title('减速让车');    
    end
    if yout2 == 3
       title('禁止鸣笛');    
    end
    if yout2 == 4
       title('禁止左转');    
    end
    if yout2 == 5
       title('慢');    
    end
    if yout2 == 6
       title('人行通道');    
    end
    if yout2 == 7
       title('限制速度');    
    end
    if yout2 == 8
       title('右转');    
    end
    
    
    
end

4. Simulation test effect

The simulation results are shown in the following figure:

Then after splitting, the following results are obtained:

A10-37

5. How to obtain the complete source code

Method 1: Wechat or QQ to contact the blogger
Method 2: Subscription , free access to the tutorial case code and any 2 complete source code of this blog

 

Guess you like

Origin blog.csdn.net/ccsss22/article/details/124352872