Main Content

blockedImageAutomationAlgorithm

Implements the blocked image automation algorithm

    Description

    res= blockedImageAutomationAlgorithm(algObj,bstruct)computes labels based on the algorithm you specify in this method. TheImage Labelerapp invokes this method on each image you choose for blocked image automation in the app.algObjis avision.labeler.AutomationAlgorithmobject.bstructis a structure. The format of the output,res, depends on the type of automation algorithm specified.

    Examples

    Sample Blocked Image Algorithm Automation Function

    • Here is an example of a blocked image algorithm automation function.

      functionres = blockedImageAutomationAlgorithm(algObj,bstruct)% Detect people using aggregate channel featuresdetector = peopleDetectorACF('inria-100x41'); [bboxes, scores] = detect(detector, bstruct.Data,。..'SelectStrongest', false);% Apply non-maximum suppression to select the strongest bounding boxes.[selectedBboxes, selectedScores] = selectStrongestBbox(bboxes, scores,。..'RatioType','Min',。..'OverlapThreshold', 0.65);% Consider only detections that meet specified score thresholdselectedBboxes = selectedBboxes(selectedScores > 0, :); selectedBboxes(:,1) = selectedBboxes(:,1)+bstruct.Start(2); selectedBboxes(:,2) = selectedBboxes(:,2)+bstruct.Start(1);ifalgObj.SelectedLabelDefinitions.Type =="Rectangle"% Add the selected label at the bounding box position(s)res = struct(。..'Type', labelType.Rectangle,。..'Name', algObj.SelectedLabelDefinitions.Name,。..'Position', selectedBboxes);endend

    Input Arguments

    collapse all

    Automation algorithm, specified as avision.labeler.AutomationAlgorithmobject.

    Structure of data passed to the blocked imageapplyobject function, specified as a scalarstructwith these fields.

    Field Description
    Data A block of array data from the blocked image.
    Start Array subscripts of the first element in the block. IfBorderSizeis specified, this subscript can be out-ot-bounds for edge blocks.
    End Array subscripts of the last element in the block. IfBorderSizeis specified, this subscript can be out-of-bounds for edge blocks.
    Blocksub The block subscripts of the current block
    BorderSize The value of theBorderSizeparameter
    BlockSize The value of theBlockSizeparameter. Note: size(data) can be less than this value for border blocksPadPartialValueis false.
    BatchSize The value of theBatchSizeparameter

    Output Arguments

    collapse all

    Result of processing, returned as a scalarstruct。结构取决于类型的格式of automation algorithm.

    For automation algorithms without pixel labels, thestructhas fields described in this table.

    Field Description
    Type AlabelTypeenumeration that defines the type of label. Type can have values:Rectangle,Line,Projected cuboid,Cuboid, orScene
    Name A character vector specifying a label name that returnstrueforcheckLabelDefinition。Only existing label names previously defined in theImage Labelerapp can be used.
    Position

    位置的标签。不同类型的标签nes the format of the position data.

    Label Type Description
    Rectangle P-by-1 cell array specifyingPRectangles, each containing a 1-by-4 vector specifying position of the bounding box locations as[x y w h]or multiple Rectangle ROIs specified as an M-by-4 matrix.
    Line P-by-1 cell array specifyingPpolylines each containingN-by-2 vector specifyingNpoints along each polyline as:[x1,y1; x2,y2;...xN,yN]
    Polygons P-by-1 cell array specifyingPpolygons each containingN-by-2 vector specifyingNpoints along each polygon as:[x1,y1; x2,y2;...xN,yN]
    Projected Cuboid P-by-1 cell array specifyingPprojected cuboids each containing 1-by-8 vector specifying position of primary and secondary faces as:[x1 y1 w1 h1 x2 y2 w2 h2]or multiple projected cuboid ROIs can be specified as an M-by-8 matrix.
    Attributes An array ofstructsrepresenting the attributes contained by the automated labels. Each attribute is specified as a field of thestructwith the name of the field representing the name of the attribute and the value of the field representing the value of the attribute. This is an optional field, only present if the labels defined have attributes.

    For automation algorithms with pixel labels,resis acategoricallabel matrix, where each category represents a pixel label.

    Tips

    • For automation algorithms without pixel labels, thePositionfield inresmust be in a world coordinate system. This can be achieved by adding theXandYindices in thebstruct.Startfield to the output of the automation algorithm. To get the correctXcoordinate, addbstruct.Start(2)to get the position of the automation output in world coordinates. To get the correctYcoordinate, addbstruct.Start(1)to get the position of the automation output in world coordinates.

    Introduced in R2021a