Datalens.ai
← All algorithms

IMAGE-PROCESSING

binary_fill_holes

Fill the holes in binary objects.

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_fill_holes; 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_fill_holes 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.
enclosed = np.ones((7, 7), dtype=bool); enclosed[3, 3] = False
result = ndi.binary_fill_holes(enclosed)
# Expected output: verify the defined numerical and shape properties.
assert result[3, 3] and result.all()
print("Expected output verified")