Non-Maximum Suppression (NMS) Explained

Non-maximum suppression ( NMS ) is an algorithm for removing non-maximum values, which is often used in edge detection and object recognition in computer vision.

Algorithm flow :

Given a picture and many candidate boxes for object detection above (that is, each box may represent some kind of object), but these boxes are likely to have overlapping parts, all we have to do is to keep only the optimal box. Suppose there are N boxes, and the score calculated by the classifier for each box is Si, 1<=i<=N.

0. Build a set H for storing candidate frames to be processed, and initialize it to contain all N frames;

     Build a set M that stores the optimal boxes, and initialize it to an empty set.

1. Sort all the boxes in the set H, select the box m with the highest score, and move it from the set H to the set M;

2. Traverse the boxes in the set H, and calculate the intersection-over-union (IoU) ratio with the box m respectively. If it is higher than a certain threshold (usually 0~0.5), it is considered that this box overlaps with m, and the This box is removed from set H.

3. Go back to step 1 to iterate until the set H is empty. The boxes in set M are what we need.

Parameters to be optimized:

The threshold of IoU is an optimizable parameter, generally ranging from 0 to 0.5, and cross-validation can be used to select the optimal parameter.

Example:

For example, an example of face recognition:

5 candidate boxes have been identified, but we only need to keep the last two faces.

First select the box with the largest score (0.98), then traverse the remaining boxes and calculate the IoU. It will be found that the two green boxes on Ruth's face have a large overlap rate with the box of 0.98 and must be removed.

Then there are only two boxes left on Jack's face, select the largest box (0.81), and then traverse the remaining boxes (only 0.67 is left), and find that the 0.67 box and the IoU of 0.81 are also very large, so remove them.

So far all the boxes have been processed, and the algorithm results:


(picture from https://blog.csdn.net/shuzfan/article/details/52711706)





Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325968802&siteId=291194637