Main Content

blockLocationsWithROI

Select image block locations that contain bounding box ROIs

Since R2025a

Description

[locationSet,bldsNew] = blockLocationsWithROI(blset,blds) selects block locations that contain bounding box ROIs specified by blds. The function returns the block locations as a blockLocationSet object, locationSet, and corresponding bounding boxes as a boxLabelDatastore object, bldsNew.

[locationSet,bldsNew] = blockLocationsWithROI(blset,blds,Name=Value) specifies options using one or more name-value arguments. For example, OverlapThreshold=0.5 specifies the overlap threshold between a bounding box and an image block as 0.5.

Input Arguments

collapse all

Block locations, specified as a blockLocationSet object. Select blocks from blocked images using the selectBlockLocations function.

Bounding box label datastore of blocked images, specified as a boxLabelDatastore object. The boxLabelDatastore object must contain only axis-aligned rectangle ROIs of size M-by-4 or rotated rectangle ROIs of size M-by-4-by-5. M is the number of axis-aligned or rotated rectangles.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: OverlapThreshold=0.5 specifies the overlap threshold between a bounding box and an image block as 0.5.

Object classes, specified as a cell array of character vectors, a string vector, or a categorical vector.

Overlap threshold between a bounding box and image block, specified as a scalar in the range [0,1]. When the overlap between a bounding box ROI and an image block is greater than or equal to this threshold, the blockLocationsWithROI function consider the block location, specified by the blset argument, to contain an object. For example, when the OverlapThreshold is 0.5, the blockLocationsWithROI function, by default, selects image blocks with at least 50% overlap with an object ROI. Meanwhile, any image block that has less than a 50% overlap with an object ROI is a background image block, and is not selected.

The amount of overlap between a bounding box ROI and an image block is defined as the area of intersection between bboxA and an image block, divided by the minimum area between bboxA and the image block.

area(bboxAblock)min(area(bboxA),area(block))

Background image block selection, specified as a numeric or logical 1 (true) or 0 (false). Set this value to true or 1 to select block locations that do not contain any ROIs.

Discard bounding box ROIs below the overlap threshold, specified as a numeric or logical 1 (true) or 0 (false). Set this argument as true or 1 to automatically remove all bounding box ROIs with an overlap threshold below the OverlapThreshold value from the bounding box datastore returned by the bldsNew argument.

Output Arguments

collapse all

Block locations containing object ROIs, returned as a blockLocationSet object. By default, the blockLocationsWithROI function selects block locations that contain bounding box ROIs which have an overlap threshold higher than or equal to the value specified by the OverlapThreshold name-value argument.

Tip

Specify the SelectBackgroundImageBlocks name-value argument as true to create blockLocationSet objects which contain only the background image blocks.

Bounding box ROIs that overlap with block locations, returned as a boxLabelDatastore object.

Note

If you specify the SelectBackgroundImageBlocks name-value argument as true, bldsNew returns an empty array for each background image block.

Tip

To discard any bounding box ROIs with an overlap threshold below the value specified by the OverlapThreshold name-value argument, specify the DiscardROIsBelowThreshold name-value argument as true or 1.

Version History

Introduced in R2025a