🟧 Image Connected Component Analysis

Function Description

This operator performs connected component analysis on input binary images, identifying all independent white pixel regions (connected components) in the image. For each identified connected component, the operator can output its contour, center point, and independent mask image, and filter by area size.

Usage Scenarios

  • Object detection and segmentation: Separate each independent object instance and obtain their positions and contours.

  • Noise removal: Through area filtering, effectively remove small area noise points generated after binarization.

  • Defect detection: Detect scratches, stains, dents and other defects on product surfaces. Usually defects form independent connected regions after binarization.

Input Output

Input

Binary Image: One or more binary images.

Output

Detection Results: A list of detection results, where each element represents a detected connected component, containing information such as the region’s contour, category, confidence score, etc.

Result Center Point List: A list containing center point coordinates [x, y] of each identified connected component that passes area screening.

Result Mask Images: Only when the parameter "Whether to Return Mask List" is enabled does this port output a list of binary images. Each image in the list corresponds to a detected connected component, where that region is white and the rest is black.

Parameter Description

Result Type

Parameter Description

Set how the contour of each detection object is represented.

Parameter Adjustment

  • Minimum Bounding Box (Default): The operator calculates the smallest rectangle that can completely enclose it for each connected component. This method is fast to calculate and results are regular, suitable for most scenarios that only need approximate target position and size.

  • Mask: The operator extracts the precise contour of each connected component, forming a possibly irregular polygon. Suitable for scenarios requiring precise shape analysis or area calculation, but computational load is larger and contour points may be very numerous.

Connected Component Type

Parameter Description

Rules used in the image to determine which neighboring pixels are considered "connected". Common types are 4-connected and 8-connected.

Parameter Adjustment

  • 8-connected: A pixel is considered connected to its surrounding 8 pixels (up, down, left, right, and 4 diagonal directions). This is the more commonly used setting. If two white regions only touch at corner points, this mode will consider them as one whole.

  • 4-connected: A pixel is only considered connected to its up, down, left, and right 4 neighboring pixels. In this mode, two regions that only touch at corner points will be considered as two independent objects.

Minimum Pixel Area

Parameter Description

Set an area threshold where all connected components with pixel count (area) smaller than this value will be filtered out.

Parameter Adjustment

After binary processing, images often contain some tiny white spots caused by noise. By setting an appropriate minimum area, these meaningless noise points can be removed. When adjusting, observe the approximate pixel area of normal targets in the binary image and set this parameter to a value smaller than the smallest normal target but larger than most noise.

For example, if normal targets all have areas above 200 pixels while noise points are mostly below 50 pixels, this value can be set to 100.

Parameter Range

[5, 400000], Default value: 100

Maximum Pixel Area

Parameter Description

Set an area threshold where all connected components with pixel count (area) larger than this value will be filtered out.

Parameter Adjustment

This parameter can be used to exclude abnormally large area regions. For example, if due to lighting or improper threshold settings, most of the background is incorrectly identified as white regions, these can be filtered out through this parameter. Usually can be set to a value much larger than the maximum area that normal targets might have.

Parameter Range

[5, 4000000], Default value: 300000

Return Mask List

Parameter Description

Control whether to generate and output an independent mask image for each detected connected component.

Parameter Adjustment

  • Off (Default): Do not generate independent mask image lists, output is empty. This approach saves memory and computational resources, suitable for most application scenarios that only need contours and center points.

  • On: Generate an independent binary mask image of the same size as the original image for each connected component that passes screening, and combine them into a list for output. Only enable this option when subsequent operators explicitly need this input.