Main Content

selectLabelsByType

Select ground truth labels by label type

Description

example

gtLabel = selectLabelsByType(gTruth,labelTypes) selects labels of the types specified by labelTypes from a groundTruth object, gTruth. The function returns a corresponding groundTruth object, gtLabel, that contains only the selected labels. If gTruth is a vector of groundTruth objects, then the function returns a vector of corresponding groundTruth objects that contain only the selected labels.

Examples

collapse all

Add the image directory to the MATLAB path.

imageDir = fullfile(matlabroot,'toolbox','vision','visiondata','stopSignImages');
    addpath(imageDir);

Load the groundTruth object.

load('stopSignsAndCarsGroundTruth.mat');

View the label definitions.

stopSignsAndCarsGroundTruth.LabelDefinitions
ans=3×3 table
        Name          Type        Group  
    ____________    _________    ________

    {'stopSign'}    Rectangle    {'None'}
    {'carRear' }    Rectangle    {'None'}
    {'carFront'}    Rectangle    {'None'}

Obtain the ground truth data for Rectangle labelType.

rectGroundTruth = selectLabelsByType(stopSignsAndCarsGroundTruth,labelType.Rectangle);

Remove the image directory from the path.

rmpath(imageDir);

Input Arguments

collapse all

Ground truth, specified as a groundTruth object or vector of groundTruth objects.

Label types, specified as a labelType enumeration or vector of labelType enumerations.

To view all label types in a groundTruth object, gTruth, enter this command at the MATLAB® command prompt.

unique(gTruth.LabelDefinitions.Type)

Example: labelType.Rectangle

Example: [labelType.Rectangle labelType.Line]

Output Arguments

collapse all

Ground truth with only the selected labels, returned as a groundTruth object or vector of groundTruth objects.

Each groundTruth object in gtLabel corresponds to a groundTruth object in the gTruth input. The returned objects contain only the labels that are of the types specified by the labelTypes input.

Limitations

  • Selecting sublabels by type is not supported.

Introduced in R2019a