Skip to content

Gaussian and Laplacian pyramids

A Gaussian pyramid keeps smaller, blurrier copies of an image. A Laplacian pyramid keeps the detail lost between those copies, plus the smallest copy needed to rebuild the image.

Try it on your image ↓

VISUAL WALKTHROUGHFiltering
REFERENCE INPUTOriginal: broad shapes + fine stripes

Watch the thin stripes inside the rectangle. Shrinking removes their contrast while the larger shapes remain recognizable.

RESULTRebuild: enlarge, add detail, repeat

Start with the saved G2. Expand it and add L1 to recover G1; expand again and add L0 to recover G0. Enlarging alone leaves a blur. Adding the stored signed detail bands restores every original sample in this floating-point example.

STEP 03 / 03

To reconstruct, start at the smallest level: expand, add its saved detail band, and repeat until the original size is restored.

Computed 32 × 24 example using the OpenCV pyramid kernel, checked against native pyrDown/pyrUp. Detail-band colour is amplified 3× for visibility; the stored values keep their signs and are never clipped.

Try it on an image

YOUR IMAGE · REAL OPENCV

Experiment at pixel level

Open full lab ↗

Inspect a Gaussian level or signed Laplacian residual. Residual display uses mid-gray for zero; native values keep the sign.

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

For motion estimation, a 16-pixel displacement becomes 4 pixels after two reductions, making a coarse search easier. For image blending, combine broad brightness changes at coarse scales and fine edges at finer scales, then reconstruct.

How it works

  1. 01Blur and halve both dimensions repeatedly to make the Gaussian levels G0, G1 and G2.
  2. 02At each transition, expand the smaller level and subtract it from the larger one. Save the signed difference as a Laplacian detail band, and keep the smallest Gaussian level.
  3. 03To reconstruct, start at the smallest level: expand, add its saved detail band, and repeat until the original size is restored.

Lk = Gk − expand(Gk+1); reconstruct: Gk = expand(Gk+1) + Lk

What to tune

Choose enough levels to make the largest expected displacement small at the coarsest scale. Keep the same expansion operator and matching dimensions when forming and reconstructing the detail bands.

Where it breaks down

pyrUp alone cannot recover discarded detail. Reconstruction needs the smallest Gaussian image and every saved detail band. Use floating-point matrices for subtraction and addition: an unsigned 8-bit subtraction clips negative corrections. Match expansion to the exact next level size, especially for odd dimensions. A Laplacian pyramid is built from differences between scales; it is not a call to the Laplacian derivative filter.

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.