2D Blob Analysis

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 and filter them based on specified geometric features (e.g., area, circularity).

Usage Scenario

This Step is used to detect 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.

Output Settings

Parameter Description

Max Number of Output Results

Parameter description: When selected, the Step outputs the merged Blob mask image.

Output Merged Mask

Parameter description: This parameter specifies the maximum number of Blobs that can be output. Only the top N Blobs after sorting are output (N is the value of this parameter). If the actual number of Blobs is less than N, all Blobs are output.

Output True If Blob Is Detected

Parameter description: This parameter specifies the Boolean result output when blobs are detected.

  • Selected: When at least one Blob is detected in the current image, the Step outputs True. If no Blob is detected, the Step outputs False.

  • Not selected: When at least one Blob is detected in the current image, the Step outputs False. If no Blob is detected, the Step outputs True.

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: Detecting Circular Parts

  • Scenario: Detect circular parts (e.g., washers, bearings), with a clean background, focusing on filtering circular targets.

  • Tuning approach:

    1. First determine the Blob polarity by selecting "Light on dark" or "Dark on light" based on the brightness relationship between the part and the background.

    2. Manually set the threshold range to effectively segment the target objects.

    3. Add a circularity filter condition to select approximately circular blobs.

    4. Add an area filter condition to exclude noise and overly large interference.

    5. Sort by area in descending order to prioritize processing larger parts.

  • 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

    Sort By

    Area

    Sort Order

    Descending

Case 2: Detecting Rectangular Parts

  • Scenario: Detect rectangular or square parts (e.g., chips, circuit boards, cards), requiring precise filtering of targets with near-rectangular shapes, with possible lighting variations.

  • Tuning approach:

    1. Use auto threshold to quickly adapt to different lighting conditions.

    2. Use 4-neighbor connectivity to ensure clear rectangular boundaries.

    3. Filter by aspect ratio of bounding rectangle to select rectangular objects.

    4. Set a minimum area to exclude tiny noise.

    5. Sort by X coordinate for orderly left-to-right processing.

  • 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

    Sort By

    Bounding Rectangle Center X

    Sort Order

    Ascending

Case 3: Detecting Small Objects

  • Scenario: Detect small-sized objects (e.g., screws, bolts, small parts), requiring noise avoidance to ensure detection reliability.

  • Tuning approach:

    1. Set the appropriate Blob polarity based on background brightness.

    2. Increase the lower threshold limit to effectively separate small targets from the dark background.

    3. Use 8-neighbor connectivity to ensure the contour connectivity of small targets.

    4. Use both area and circumradius conditions for constraint to improve filtering accuracy.

    5. Sort by Y coordinate to suit top-to-bottom processing scenarios.

  • Parameter settings:

    Parameter Setting

    Blob Polarity

    Light on dark

    Threshold Type

    Manual

    Threshold Range

    150 ~ 255

    Neighborhood

    8-neighbor

    Contour Retrieval Mode

    External contours

    Filter Condition (Condition 1)

    Area ≥ 50 and ≤ 500

    Filter Condition (Condition 2)

    Circumradius ≥ 3 and ≤ 15

    Logic Between Conditions

    AND

    Sort By

    Centroid Y

    Sort Order

    Ascending

    Max Number of Output Results

    Selected (set the output result count)

Case 4: Target Detection in Complex Backgrounds

  • Scenario: Complex or changing backgrounds (stacked materials, mixed items, etc.) where target objects may have holes, requiring ROI and masks to limit the detection range.

  • Tuning approach:

    1. Use ROI settings to limit the detection region and reduce subsequent processing complexity.

    2. Draw masks to cover obvious interfering regions (e.g., strong reflections, shadow areas).

    3. Use the "All contours" mode to detect targets with holes.

    4. Set a wider threshold range to adapt to lighting variations.

    5. Use AND logic to combine multiple conditions for strict filtering of qualifying blobs.

    6. Use Z-shape sorting to suit regularly arranged items.

  • 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

    Sort By

    Z shape

    Primary Sorting Direction

    Row-first, left to right

    Secondary Sorting Direction

    Top to bottom

    Layer Interval

    50

Case 5: High-Contrast Background with Precise Control of Detection Results

  • Scenario: High contrast between the target and background, but the number and quality of output results need to be strictly controlled, e.g., only the top N largest blobs are needed.

  • Tuning approach:

    1. Use auto threshold to quickly obtain basic segmentation results.

    2. Set contour retrieval to "External contours" to improve processing efficiency.

    3. Exclude abnormal shapes using a combination of aspect ratio of bounding rectangle and circularity conditions.

    4. Select "Max Number of Output Results" to control the output count.

    5. Sort by area in descending order to ensure the largest targets are output.

    6. Select "Output True If Blob Is Detected" to enable logic-based judgment.

  • Parameter settings:

    Parameter Setting

    Blob Polarity

    Light on dark

    Threshold Type

    Auto

    Neighborhood

    8-neighbor

    Contour Retrieval Mode

    External contours

    Filter Condition (Condition 1)

    Aspect ratio of bounding rectangle ≥ 0.5 and ≤ 2.0

    Filter Condition (Condition 2)

    Circularity ≥ 0.5

    Logic Between Conditions

    OR

    Sort By

    Area

    Sort Order

    Descending

    Max Number of Output Results

    Selected

    Output Result Count

    10

    Output True If Blob Is Detected

    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.