Extract Image from Mask List

Description

This operator extracts (or "crops") the region corresponding to each mask from a source image based on one or more input binary masks. You can control the extraction shape, such as using the precise mask contour, using its bounding rectangle, or extracting only the target edges.

Overview

Crops the original image based on mask regions, supporting cropping by polygon, minimum bounding rectangle, or extreme point range, with options to retain only edges or extract inversely.

Scenarios

After obtaining the mask of the target through segmentation or detection algorithms, this operator can be used to extract the image region of each target individually, for example, removing complex background information and displaying only the target image of interest.

Inputs and Outputs

Inputs

Image: A source image to be extracted.

Detection result mask image list: A list of one or more binary mask images. Each mask defines the region to extract from the source image.

Outputs

Masked Image List: An image list, where each image in the list is the result of the source image being extracted by the corresponding mask.

2D ROI: A 2x2 ROI list represented as [{min: [min_pixel_row, min_pixel_col], max: [max_pixel_row, max_pixel_col]}].

Parameters

Shape Type

Description

Selects the shape type for image extraction.

Tuning Instructions

  • Minimum Bounding Box: Extracts the image region based on the minimum rotated bounding box of the detection instance. Suitable for scenarios where the object shape is relatively regular, capable of framing the target with the smallest rectangle.

  • Mask: Extracts the image region based on the pixel-level mask of the detection instance. High precision, capable of accurately extracting the image region of objects of any shape, but the computational load is relatively large.

  • Min-Max: Extracts the image region based on the axis-aligned bounding box (horizontal and vertical rectangle) of the detection instance. Fastest calculation speed, suitable for scenarios with low requirements for the precision of the extraction region.

Parameter Range

Values/Range:

  • Minimum bounding rectangle

  • Polygon

  • Axis-aligned rectangle

Default: Minimum bounding rectangle

Bounding Box Scale Ratio

Description

Controls the scale ratio of the extracted region relative to the original bounding box.

Tuning Instructions

  • Greater than 1: Expand the extraction region outward.

  • Less than 1: Shrink the extraction region inward.

  • Equal to 1: Keep the original bounding box size.

Parameter Range

Values/Range: [0.01, 10000.0]

Default: 1.0

Mask Edge Only

Tuning Instructions

Used to analyze the contour features of the object. When enabled, the operator only extracts the image region at the mask contour edge, not the entire mask interior.

Parameter Range

Values/Range:

  • True

  • False

Default: False

Edge Thickness

Tuning Instructions

Sets the pixel width of the edge contour. The larger the value, the thicker the extracted edge band, containing more pixels.

Parameter Range

Values/Range: [1, 50]

Default: 1

Enable Invert

Tuning Instructions

Inverts the extraction logic. Disabled means extracting the image region inside the specified shape; enabled can be used to remove identified objects and retain the background.

Parameter Range

Default: False

Merge into One Result

Description

Whether to merge all mask-corresponding image regions into a single output result.

Parameter Range

Values/Range:

  • True

  • False

Default: False

Keep Original Image Size

Description

Preserve the original image dimensions. If True, the output matches the input image size; if False, outputs the cropped image region.

Parameter Range

Values/Range:

  • True

  • False

Default: True