2D Blob Alignment

You are currently viewing the documentation for the latest version (2.2.0). To access a different version, click the "Switch version" button located in the upper-right corner of the page.

■ If you are not sure which version of the product you are currently using, please feel free to contact Mech-Mind Technical Support.

Function

This Step is used to detect blobs in an image, filter them based on specified geometric features (e.g., area, circularity), and align the image so that the blob centroid coincides with the original image center.

Usage Scenario

This Step is used to detect and align blobs in 2D images in measurement scenarios.

Input Description

Input item Description

Image

This port inputs the image that will be used for blob analysis.

Alignment Parameter Group

Optional input. Used to adjust the ROI’s pose in sync with the target object’s pose changes.

Parameter Description

Parameter Description

ROI Settings

Parameter description: This parameter is used to limit the image processing region. If no ROI is set, the Step will process the entire image.
Tuning instructions: Click the icon, then press and hold the left mouse button and drag in the data visualization area to draw an ROI of the corresponding shape.

Mask Settings

Parameter description: This parameter is used to set one or more masks so that image areas covered by the masks are ignored during blob detection.
Tuning instructions: Click the icon, then left-click in the data visualization area to add vertices and draw a polygonal mask.

Detection Settings

Parameter Description

Blob Polarity

Parameter description: This parameter defines which pixel regions are identified as blobs based on their contrast to the background.

Value list:

  • Dark on light: Selects connected pixels that are darker than the background.

  • Light on dark: Selects connected pixels that are lighter than the background.

Threshold Type

Parameter description: This parameter specifies the method for calculating the binarization threshold. Pixels with gray values above the threshold are classified as foreground; those below are classified as background.

Value list:

  • Manual: Set a fixed global threshold manually.

  • Auto: The system automatically calculates the optimal threshold.

Neighborhood

Parameter description: This parameter specifies the connectivity rule between pixels, determining which pixels are grouped into a single blob.

Value list:

  • 4-neighbor: Pixels connected only through their horizontal and vertical neighbors are grouped into the same blob.

  • 8-neighbor: Pixels connected through their horizontal, vertical, and diagonal neighbors are grouped into the same blob.

Contour Retrieval Mode

Parameter description: This parameter specifies the retrieval method for blob contour extraction.

Value list:

  • External contours: Detects and extracts only the outermost contours, ignoring all internal holes and nested contours.

  • All contours: Detects all contours and builds a complete hierarchy tree.

Filter Settings

This parameter is used to set filter conditions to select blobs that match specific geometric features. Click the Open the editor button to set the relevant parameters in the "Filter Settings" window.

Parameter Description

Logic Between Conditions

Parameter description: This parameter specifies the logical filtering rule. It is used to set the logic (AND/OR) between multiple filter conditions (e.g., area, aspect ratio of bounding rectangle, circularity). Different condition items are combined by the "Logic Between Conditions" setting (AND/OR); when the same condition item is added multiple times, it is always combined with OR logic, regardless of the "Logic Between Conditions" setting.
Value list: AND, OR

Tuning instructions: Click the Add condition button and select the condition to filter from the drop-down list, then set the logic between conditions. For definitions and descriptions of conditions, see Filter Condition Descriptions. You can set the "Filter value range" based on the "Reference value range". Additionally, each condition can be individually enabled/disabled or deleted.

Sorting Settings

Parameter Description

Sort By

Parameter description: This parameter specifies the sorting criterion for the detected blobs.
Value list: Area, Total area, Bounding rectangle width, Bounding rectangle height, Aspect ratio of bounding rectangle, Principal axis angle, Circularity, Bounding rectangle center X, Bounding rectangle center Y, Inradius, Circumradius, Inscribed rectangle width, Inscribed rectangle height, Centroid X, Centroid Y, Bounding rectangle top-left X, Bounding rectangle top-left Y, Bounding rectangle bottom-right X, Bounding rectangle bottom-right Y, Rotated bounding rectangle width, Rotated bounding rectangle height, Z shape
Tuning instructions: When Z shape is selected, you need to set the Primary Sorting Direction, Secondary Sorting Direction, Layer Interval and Reference Position.

Sort Order

Parameter description: This parameter specifies the sorting direction.
Value list: Ascending, Descending

Primary Sorting Direction

Parameter description: This parameter specifies the primary sorting direction for Z-shape sorting.

Value list:

  • Row-first, left to right

  • Row-first, right to left

  • Column-first, top to bottom

  • Column-first, bottom to top

Secondary Sorting Direction

Parameter description: This parameter specifies the secondary sorting direction (cross-row or cross-column) for Z-shape sorting.

Value list:

  • Top to bottom

  • Bottom to top

  • Left to right

  • Right to left

Layer Interval

Parameter description: This parameter divides blobs into layers based on the specified interval. When the sorting method is row-first, this parameter indicates the row interval; when column-first, it indicates the column interval.

Reference Position

Parameter description: This parameter specifies the starting position used for layering. For example, when sorting row-first, the system places the first row at this reference position, and then arranges subsequent rows above or below it based on the specified layer interval.

Parameter Description

Principal Axis Angle Range

Parameter description: This parameter specifies the normalized angular range used to determine the Blob’s principal axis.
Value list: ±90°, ±45°
Default value: ±90°

Align and Crop

Parameter description: This parameter sets the image processing mode. When this parameter is selected, the system will align the image so that the blob centroid coincides with the original image center, and crop the image to the blob’s minimum bounding rectangle. If it is not selected, no alignment is performed, and areas outside the blob are filled with black.
Default value: Selected

Output Description

Output item Description

Blob Detected

Boolean result of the Blob detection. The specific Boolean result depends on the setting of the "Output True If Blob Is Detected" parameter.

Blob Count

Number of detected blobs.

Blob Masks

The mask image of the detected blobs.

Blob(n) pose

The position and orientation of the blob(n) in the image.

Bounding Rectangle

The bounding rectangle of the blob.

Bounding Rectangle Center X

The X coordinate of the blob’s bounding rectangle center.

Bounding Rectangle Center Y

The Y coordinate of the blob’s bounding rectangle center.

Principal Axis Angle

The rotation angle of the blob’s principal axis relative to the horizontal axis, in degrees (°).

Area

The area of the blob in pixels.

Total area

The total area of the Blobs.

Bounding Rectangle Width

The width of the blob’s bounding rectangle.

Bounding Rectangle Height

The height of the blob’s bounding rectangle.

Aspect Ratio of Bounding Rectangle

Aspect ratio of bounding rectangle = Bounding rectangle width / Bounding rectangle height

Circularity

Circularity = Blob area / Area of a circle with the same perimeter as the blob.

Inradius

The inradius of the blob.

Circumradius

The circumradius of the blob.

Inscribed Rectangle Width

The width of the blob’s inscribed rectangle.

Inscribed Rectangle Height

The height of the blob’s inscribed rectangle.

Centroid X

The X coordinate of the blob’s centroid. The centroid is the geometric center of the blob, represented as a point whose coordinates indicate its position in the image.

Centroid Y

The Y coordinate of the blob’s centroid. The centroid is the geometric center of the blob, represented as a point whose coordinates indicate its position in the image.

Bounding Rectangle Top-Left X

The X coordinate of the blob’s bounding rectangle top-left corner.

Bounding Rectangle Top-Left Y

The Y coordinate of the blob’s bounding rectangle top-left corner.

Bounding Rectangle Bottom-Right X

The X coordinate of the blob’s bounding rectangle bottom-right corner.

Bounding Rectangle Bottom-Right Y

The Y coordinate of the blob’s bounding rectangle bottom-right corner.

Rotated Bounding Rectangle Width

The width of the blob’s rotated bounding rectangle.

Rotated Bounding Rectangle Height

The height of the blob’s rotated bounding rectangle.

Parameter Tuning Examples

Case 1: Aligning Circular Parts for Subsequent Dimensional Measurement

  • Scenario: Detect circular parts (e.g., washers, bearings) with a clean background. The target object needs to be translated to the image center for consistent subsequent measurement and display.

  • Tuning approach:

    1. First select the appropriate Blob polarity based on the brightness relationship between the part and the background.

    2. Use manual threshold to stably segment the target region, then combine circularity and area filters to select the target blob.

    3. Since circular parts are insensitive to rotation direction, the default Principal Axis Angle Range can be kept.

    4. If subsequent Steps only need to process the target region, it is recommended to select Align and Crop to reduce the influence of irrelevant background.

  • Parameter settings:

    Parameter Setting

    Blob Polarity

    Light on dark

    Threshold Type

    Manual

    Threshold Range

    100 ~ 255

    Neighborhood

    8-neighbor

    Contour Retrieval Mode

    External contours

    Filter Condition (Condition 1)

    Circularity ≥ 0.75

    Filter Condition (Condition 2)

    Area ≥ 500 and ≤ 10000

    Logic between Conditions

    AND

    Principal Axis Angle Range

    ±90°

    Align and Crop

    Selected

Case 2: Aligning Rectangular Parts to a Uniform Orientation for Recognition

  • Scenario: Detect rectangular or square parts (e.g., chips, circuit boards, cards). The goal is to rotate all targets to a uniform orientation for subsequent character recognition, dimensional comparison, or template matching.

  • Tuning approach:

    1. Use auto threshold to quickly adapt to on-site lighting variations.

    2. Filter out non-target regions using aspect ratio of bounding rectangle and area.

    3. For rectangular targets with an obvious long-edge direction, focus on adjusting the Principal Axis Angle Range to ensure stable principal axis direction output.

    4. If subsequent Steps only need to process the target region, it is recommended to select Align and Crop to reduce the influence of irrelevant background. If the full original image needs to be preserved, deselect this option.

  • Parameter settings:

    Parameter Setting

    Blob Polarity

    Dark on light

    Threshold Type

    Auto

    Neighborhood

    4-neighbor

    Contour Retrieval Mode

    External contours

    Filter Condition (Condition 1)

    Aspect ratio of bounding rectangle ≥ 0.8 and ≤ 1.2

    Filter Condition (Condition 2)

    Area ≥ 1000

    Logic between Conditions

    AND

    Principal Axis Angle Range

    ±45°

    Align and Crop

    Selected

Case 3: Aligning Elongated Workpieces to Avoid Angle Jumps

  • Scenario: Detect elongated targets (e.g., strips, connecting rods, slender labels) with a clear principal axis, but the angle may jump across different images, affecting alignment consistency in subsequent processing.

  • Tuning approach:

    1. First stably detect the unique target using threshold and area range.

    2. For elongated targets, further constrain the target shape using the aspect ratio of bounding rectangle.

    3. Focus on checking the Principal Axis Angle Range setting to ensure the target’s principal axis angle remains consistent after normalization, avoiding a 180° rotation difference of the same target across different images.

    4. If only the target body image needs to be extracted for subsequent processing, select Align and cropto reduce background interference.

  • Parameter settings:

    Parameter Setting

    Blob Polarity

    Light on dark

    Threshold Type

    Manual

    Threshold Range

    120 ~ 255

    Neighborhood

    8-neighbor

    Contour Retrieval Mode

    External contours

    Filter Condition (Condition 1)

    Aspect ratio of bounding rectangle ≥ 3.0

    Filter Condition (Condition 2)

    Area ≥ 300

    Logic between Conditions

    AND

    Principal Axis Angle Range

    ±45°

    Align and Crop

    Selected

Case 4: Aligning Targets in Complex Backgrounds While Preserving the Original Image Range

  • Scenario: Multiple interfering regions exist in a complex or changing background. The target needs to be located and aligned first, but subsequent Steps still require reference to the surrounding area information in the original image.

  • Tuning approach:

    1. Use ROI and masks to limit the detection range first, reducing the impact of complex backgrounds on blob detection.

    2. Filter out the target blob using conditions such as area, circularity, or aspect ratio.

    3. If the target direction determination is stable, the default **Principal Axis Angle Range** can be kept; if the direction is unstable, adjust it based on the actual distribution.

    4. In this scenario, it is recommended to unselect Align and Crop to align only the target position and keep the full image range, so that the context information can be used in subsequent steps.

  • Parameter settings:

    Parameter Setting

    ROI Settings

    Set (limit the processing region)

    Mask settings

    Set (cover interfering regions)

    Blob Polarity

    Light on dark

    Threshold Type

    Manual

    Threshold Range

    80 ~ 200

    Neighborhood

    8-neighbor

    Contour Retrieval Mode

    All contours

    Filter Condition (Condition 1)

    Area ≥ 800

    Filter Condition (Condition 2)

    Circularity ≥ 0.6

    Logic between Conditions

    AND

    Principal Axis Angle Range

    ±90°

    Align and Crop

    Not selected

Is this page helpful?

You can give a feedback in any of the following ways:

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.