Extract Image from Detection Results

Description

This operator extracts corresponding image regions from the original image based on 2D detection results (polygons/masks). It supports multiple extraction shapes and styles, aiding in visual localized analysis or data preparation for subsequent tasks.

Overview

Crops object regions from images using detection information.

Scenarios

  • Secondary recognition: Detect the approximate location of objects, crop them out, then run finer recognition or classification.

  • Defect detection: Extract only the object region and remove background clutter so that defect analysis can focus on the object in later steps.

  • Data cleansing: Extract and save specific targets for building training datasets.

Inputs and Outputs

Inputs

Detection Results: Returns a list containing class, score, polygon, and angle information.

Image: Image.

Outputs

Masked Image List: List of extracted images.

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 geometric shape rule used when extracting target regions.

Tuning Instructions

  • Minimum Bounding Rect: Uses the minimum rotated rectangle of the detection result. Efficient and includes small padding.

  • Polygon: Uses the precise pixel-level contour of the detection result.

  • Axis-Aligned Bounding Box (AABB): Uses the bounding box aligned with the image axes (horizontal/vertical).

Parameter Range

Values/Range:

  • Minimum bounding rectangle

  • Polygon

  • Axis-aligned rectangle

Default: Minimum bounding rectangle

Bounding Box Scale Ratio

Description

Controls the enlargement or shrinkage of the target region relative to the original detection area.

Tuning Instructions

  • Values > 1.0: Expands the region outward (e.g., 1.2 adds 20% margin).

  • Values < 1.0: Shrinks the region inward.

Parameter Range

Values/Range: [0.01, 10000.0]

Default: 1.0

Mask Edge Only

Description

Only extracts the pixels along the object’s contour edge instead of the entire mask interior. Active only when the shape type is 'Polygon'.

Parameter Range

Values/Range:

  • True

  • False

Default: False

Edge Thickness

Description

Sets the pixel width for contour extraction when 'Edge Only' is enabled.

Tuning Instructions

  • Parameter Range: [1, 50].

Parameter Range

Values/Range: [1, 50]

Default: 1

Enable Invert

Description

Inverts the image extraction logic.

Tuning Instructions

  • False (Default): Retains the image inside the detection box/polygon and removes the exterior (blacks it out).

  • True: Retains the image outside the detection box/polygon and removes the interior (blacks it out). Useful when you want to mask specific objects and analyze only the background.

Parameter Range

Default: False

Merge into One Result

Description

Controls the output list format when multiple objects are detected.

Tuning Instructions

  • False (Default): Generates an independent image for each detected object.

  • True: Merges all detected objects into a single output image.

Parameter Range

Values/Range:

  • True

  • False

Default: False

Keep Original Image Size

Description

Sets the output image size strategy (effective only when 'Reverse' is False).

Tuning Instructions

  • True (Default): Output dimensions match the input; selected objects stay in their original pixel locations with the rest blacked out. Useful for maintaining coordinate consistency.

  • False: Cropped small images containing only the target regions, reducing data volume for subsequent processing.

Parameter Range

Values/Range:

  • True

  • False

Default: True