IMAGE-PROCESSING
uniform_filter
Multidimensional uniform filter.
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 uniform_filter; 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 sample: named industrial inspection image.
image_data = {'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)'}
# DataLens.ai example — uniform_filter 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.uniform_filter(image, size=3)
# Expected output: verify the defined numerical and shape properties.
assert result.shape == image.shape and np.isclose(result.sum(), image.sum(), atol=1e-6)
print("Expected output verified")
# DataLens.ai example — uniform_filter 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.uniform_filter(image, size=3)
# Expected output: verify the defined numerical and shape properties.
assert result.shape == image.shape and np.isclose(result.sum(), image.sum(), atol=1e-6)
print("Expected output verified")