Main Content

select

Select point or region features during code generation

Since R2024b

    Description

    indexedPoints = select(points,ind) selects one or more sets of point or region features using the specified indices ind.

    example

    Examples

    collapse all

    Read an image into the MATLAB® workspace.

    I = imread("cameraman.tif");

    Define the helperGetSubsetOfPoints function, which detects and selects SURF points. You must save the helper function as a MATLAB script file with a .m extension.

    function indexedLocation = helperGetSubsetOfPoints(I)
        points = detectSURFFeatures(I);
        indexedPoints = select(points,30:100);
        indexedLocation = indexedPoints.Location;
    end

    Create a configuration object for generating a MEX function.

    cfg = coder.config("mex");

    Generate the MEX function from the helper function helperGetSubsetOfPoints using the configuration cfg. The helperGetSubsetOfPoints function detects SURF features in the input image and selects a specified set of point features using the select object function of the SURFPoints object. The helperGetSubsetOfPoints function outputs the locations of the selected SURF point features in the image. You can use the select function only for code generation.

    codegen -config cfg helperGetSubsetOfPoints -args {I}
    Code generation successful.
    

    Call the generated MEX function with the image I as input. Because code generation cannot return objects as outputs, the helperGetSubsetOfPoints function outputs the locations of the selected SURF point features.

    locations = helperGetSubsetOfPoints_mex(I);

    Convert the output locations to SURFPoints objects.

    points = SURFPoints(locations);

    Display the selected SURF point features.

    figure
    imshow(I)
    hold on
    plot(points)

    hold off

    Input Arguments

    collapse all

    Input features, specified as an MSERRegions, SURFPoints, ORBPoints, KAZEPoints, BRISKPoints, SIFTPoints, or cornerPoints object.

    Indices of the features to be selected from the input, specified as a scalar or vector.

    Output Arguments

    collapse all

    Output features, returned as an MSERRegions, SURFPoints, ORBPoints, KAZEPoints, BRISKPoints, SIFTPoints, or cornerPoints object. The indexedPoints output object type matches the type of object specified to the points input argument.

    Version History

    Introduced in R2024b