Skip to content

Bilateral filtering

Smooth nearby pixels only when their colours are also similar.

Try it on your image ↓

VISUAL WALKTHROUGHFiltering
REFERENCE INPUTNoisy or uneven image

The same scene stays here while the working view changes.

RESULTApply the rule at every pixel

The whole image has now been processed. The highlighted input value 156 becomes 152.9.

STEP 03 / 03

Combine both weights and normalize their weighted sum.

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 ↗

Smooth similar colours while preserving boundaries.

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

Reduce noise while retaining strong object boundaries, often before stylization or segmentation.

How it works

  1. 01Measure each neighbour’s spatial distance.
  2. 02Measure its colour distance from the centre.
  3. 03Combine both weights and normalize their weighted sum.

weight = spatial Gaussian × colour Gaussian

What to tune

sigmaSpace sets the spatial reach; sigmaColor sets how different colours may mix; d sets the diameter.

Where it breaks down

Large windows are expensive. Strong texture may be flattened, and weak edges can still blur.

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.