Fine tab on a machined metal part inspected beside a few loose specks.

What you need

Use binary masks containing true small features and representative noise. Work on copies of the original masks.

Nominal kernel support at 0.1 mm/pixel. 3 pixels: 0.3 mm; 5 pixels: 0.5 mm; 7 pixels: 0.7 mm.
Nominal kernel support at 0.1 mm/pixel. Original Academy diagram using illustrative values; not a measured hardware result.
Read the diagram as a data table
Values used in the illustration
Condition or componentmm
3 pixels0.3
5 pixels0.5
7 pixels0.7

The calculation

w_kernel ≈ k_pixels × s

k_pixels is kernel width and s is mm/pixel. This expresses nominal spatial support; the actual effect also depends on kernel shape and object geometry.

Worked example

Illustrative numbers. Replace them with your measured inputs.

At 0.1 mm/pixel, a 3-pixel kernel spans about 0.3 mm and a 7-pixel kernel about 0.7 mm. A narrow 0.5 mm feature can disappear under aggressive processing even though the cleaned mask looks smoother.

Try it step by step

  1. Keep the raw mask as a reference and mark the smallest feature that must remain visible for the robot task.
  2. Apply opening with a small kernel and compare removed noise with lost real structures.
  3. Test closing separately for unwanted holes or gaps; do not assume an opening-closing sequence is always appropriate.
  4. Measure centroid, area and connectivity before and after processing across the complete validation set.

How to check the result

Accept the operation only if it reduces nuisance detections without losing required geometry or shifting the target beyond the task tolerance.

Common mistake to avoid

A visually clean mask can be geometrically wrong. Increasing kernel size is not a substitute for fixing illumination or focus.

Reference reading

Primary references for the underlying models, APIs or application context. The worked numbers and plots above are educational calculations, not results reported by these sources.

Read our methods, limitations and safety notes.