Datalens.ai
← All algorithms

IMAGE-PROCESSING

binary_erosion

Multidimensional binary erosion with a given structuring element.

Example of usage

Detect, enhance or quantify structures in a synthetic quality-inspection grayscale image.

Usage / limitations

+Use when: Transform and analyse images.

−Limitations: Check input requirements, mathematical assumptions and version-specific behaviour before using.

Mathematical formula

See mathematical definition for binary_erosion; this example verifies numerical properties.
Sample dataShow
{
  "variable": "image_data",
  "domain": "Industrial visual quality inspection",
  "feature_names": [
    "pixel_row",
    "pixel_column",
    "intensity_level"
  ],
  "pixels": [
    [
      0,
      0,
      0,
      0,
      0,
      0,
      0
    ],
    [
      0,
      0,
      0,
      0,
      0,
      0,
      0
    ],
    [
      0,
      0,
      2,
      3,
      2,
      0,
      0
    ],
    [
      0,
      0,
      3,
      9,
      3,
      0,
      0
    ],
    [
      0,
      0,
      2,
      3,
      2,
      0,
      0
    ],
    [
      0,
      0,
      0,
      0,
      0,
      0,
      0
    ],
    [
      0,
      0,
      0,
      0,
      0,
      0,
      0
    ]
  ],
  "pixel_unit": "relative grayscale intensity (0–9)"
}

Code example (Python)

# DataLens.ai example — binary_erosion for visual quality inspection.
# Input image_data is provided by Copy input + code + test.
import numpy as np
from scipy import ndimage as ndi
# Construct a small grayscale inspection image with a bright object.
image = np.asarray(image_data['pixels'], dtype=float)
mask = image > 0
# Apply the selected image processing algorithm.
result = ndi.binary_erosion(mask)
# Expected output: verify the defined numerical and shape properties.
assert np.count_nonzero(result) <= np.count_nonzero(mask)
print("Expected output verified")