Skip to content

Dilation

Algorithm atlasMorphology

Expand a bright mask by taking the maximum under a structuring element.

Try it on your image ↓

VISUAL WALKTHROUGHMorphology
REFERENCE INPUTBinary mask

Two objects and a single-pixel speck make growth, shrinkage and cleanup easy to compare.

RESULTChanged foreground

100 foreground pixels become 174. The 3 × 3 footprint expands the foreground by one pixel on each side.

STEP 03 / 03

Write the maximum and advance to the next position.

Computed teaching example on a 24 × 16 image. Small kernels and simplified settings keep each change visible; use the image laboratory for native OpenCV.

Try it on an image

YOUR IMAGE · REAL OPENCV

Experiment at pixel level

Open full lab ↗

Grow white regions in a thresholded mask.

The engine loads on your first run. Your images stay in this browser.

Input448 × 320
OutputWaiting for a result

Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.

Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Hover to inspect. Click to pin a pixel.
Input
Select a pixel

Output
Select a pixel

Sample models and licenses

When to use it

Connect nearby foreground regions, thicken lines, or expand a region of interest.

How it works

  1. 01Place the kernel at one output position.
  2. 02Look for any foreground within its footprint.
  3. 03Write the maximum and advance to the next position.

dilation(A,B)(x) = max over b∈B of A(x+b)

What to tune

Choose the structuring-element shape, anchor and number of iterations to match the scale of the gap.

Where it breaks down

Separate objects may merge. A large kernel can close a gap that carries important structure.

TypeScript API

Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.

All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.