Skip to the content.

Stacking Algorithms

← Back to home

ChimpStackr implements four image fusion methods. This document explains how each works and when to use it.

Laplacian Pyramid (default)

Best for: Fine detail – hairs, bristles, edges, complex overlapping structures.

Based on Burt & Adelson (1983), similar to Zerene Stacker’s PMax.

How it works

  1. Each image is decomposed into a Laplacian pyramid – a multi-scale representation where each level captures detail at a different spatial frequency (fine texture at level 0, coarse structure at higher levels).

  2. At each pyramid level and each pixel, the algorithm compares the two sources and picks the one with higher local contrast (deviation in a kernel-sized neighborhood).

  3. The selected pyramid levels are recombined to produce the fused image.

  4. A local tone-mapping step (CLAHE on the L channel) compensates for the contrast boost inherent in max-contrast selection.

Parameters

Strengths and weaknesses

Weighted Average

Best for: Smooth subjects, short stacks, good color fidelity.

Similar to Helicon Focus Method A.

How it works

  1. For each image, compute a per-pixel focus weight using Laplacian energy (higher energy = more in focus).

  2. Accumulate weighted pixel sums and weight totals across all images (float64 precision).

  3. Divide once at the end to get the properly weighted average.

Why not pairwise

Earlier versions fused pairs incrementally, which compounded blur because the focus weights on an already-blended result were wrong. The current implementation accumulates all weights before dividing, producing correct results.

Strengths and weaknesses

Depth Map

Best for: Opaque surfaces with continuous depth, best original color preservation.

Similar to Zerene Stacker’s DMap and Helicon Focus Method B.

How it works

  1. For each image, compute a multi-scale sharpness map using the Sum Modified Laplacian (SML) – the standard focus measure operator used by commercial stackers.

  2. Sharpness is evaluated at three window sizes and averaged to reduce blockiness.

  3. The sharpness map is smoothed using a bilateral filter – this preserves sharp depth discontinuities at object edges while smoothing noisy estimates in flat areas.

  4. At each pixel, the image with the highest sharpness wins – no blending.

Parameters

Strengths and weaknesses

Exposure Fusion (HDR)

Best for: Varying lighting/exposure, NOT for focus stacking.

Uses OpenCV’s Mertens exposure fusion algorithm.

How it works

  1. Images are collected in batches of 4.
  2. Each batch is fused using Mertens’ method – per-pixel weighting based on contrast, saturation, and exposure quality.
  3. Batch results are fused together in a final pass.

When to use

Algorithm Comparison

Aspect Pyramid Weighted Avg Depth Map HDR
Detail preservation Excellent Good Good Moderate
Color fidelity Good (slight shift) Very good Excellent Good
Overlapping structures Handles well Blends Cannot Blends
Artifacts Noise in flat areas Few Halos at edges Few
Speed Fast Fast Fast Moderate
Frame ordering required No No No No
Best stack size Any 2-20 Any 2-10

References