Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

selectStrongestBbox

Select strongest bounding boxes from overlapping clusters

Syntax

[selectedBbox,selectedScore] = selectStrongestBbox(bbox,score)
[selectedBbox,selectedScore,index] = selectStrongestBbox(bbox,score)
[selectedBbox,selectedScore,index] = selectStrongestBbox(___,Name,Value)

Description

example

[selectedBbox,selectedScore] = selectStrongestBbox(bbox,score) returns selected bounding boxes that have a high confidence score. The function uses nonmaximal suppression to eliminate overlapping bounding boxes from the bbox input.

[selectedBbox,selectedScore,index] = selectStrongestBbox(bbox,score) additionally returns the index vector associated with selectedBbox. This vector contains the indices of the selected boxes in the bbox input.

[selectedBbox,selectedScore,index] = selectStrongestBbox(___,Name,Value) uses additional options specified by one or more Name,Value pair arguments.

Examples

collapse all

Load the pretrained people detector and disable bounding box merging.

peopleDetector = vision.PeopleDetector('ClassificationThreshold',...
        0,'MergeDetections',false);

Read an image, run the people detector, and then insert bounding boxes with confidence scores.

I = imread('visionteam1.jpg'); 
[bbox,score] = step(peopleDetector,I); 
I1 = insertObjectAnnotation(I,'rectangle',bbox,...
        cellstr(num2str(score)),'Color','r');

Run nonmaximal suppression on the bounding boxes.

[selectedBbox,selectedScore] = selectStrongestBbox(bbox,score); 
I2 = insertObjectAnnotation(I,'rectangle',selectedBbox,...
        cellstr(num2str(selectedScore)),'Color','r');

Display detection before and after suppression.

figure, imshow(I1); ...
title('Detected people and detection scores before suppression'); 

figure, imshow(I2); ...
title('Detected people and detection scores after suppression');

Input Arguments

collapse all

Bounding boxes, specified as an M-by-4 matrix with M bounding boxes. Each row of the bbox input represents a bounding box, specified in the format [x y width height], where x and y correspond to the upper left corner of the bounding box. The bbox input must be real, finite, and nonsparse.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Confidence score, specified as an M-by-1 vector. The Mth score in the score input corresponds to the Mth bounding box in the bbox input . The score input must be real, finite, and nonsparse. The function uses nonmaximal suppression to eliminate overlapping bounding boxes and associate the confidence score with the boxes. A higher score represents a higher confidence in keeping the bounding box.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'RatioType','Union' sets the 'RatioType' property to 'Union'.

collapse all

Ratio type, specified as the character vector 'Union' or 'Min'.

  • Set the ratio type to 'Union' to compute the ratio as the area of intersection between bboxA and bboxB, divided by the area of the union of the two.

  • Set the ratio type to 'Min' to compute the ratio as the area of intersection between bboxA and bboxB, divided by the minimum area of the two bounding boxes.

Data Types: char

Overlap ratio threshold, specified as the comma-separated pair consisting of 'OverlapThreshold' and a scalar in the range [0 1]. When the overlap ratio is above the threshold you set, the function removes bounding boxes around the reference box. Decrease this value to reduce the number of selected bounding boxes. However, if you decrease the overlap ratio too much, you might eliminate boxes that represent objects close to each other in the image.

Data Types: single | double

Output Arguments

collapse all

Selected bounding boxes, returned as an M-by-4 matrix. The selectedBbox output returns the selected bounding boxes from the bbox input that have the highest confidence score. The function uses nonmaximal suppression to eliminate overlapping bounding boxes.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Scores of selected bounding boxes, returned as an M-by-1 vector. The Mth score in the selectedScore output corresponds to the Mth bounding box in the selectedBbox output.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Index of selected bounding boxes, returned as an M-by-1 vector. The index vector contains the indices to the selected boxes in the bbox input.

Data Types: double

Extended Capabilities

Introduced in R2014b