What the stacker does
Given a series of frames of one scene focused at successive distances, it produces one image in which every region comes from the frame where that region was sharpest. Everything below runs in a Web Worker on your own processor; the page has no server-side image endpoint at all.
- 1 Brackettwo or more frames, focus stepped
- 2 Alignscale, rotation and shift, fitted on edges
- 3 Votesix scales; the sharpest frame wins each region
- 4 Mergeone image: JPEG, PNG or 16-bit TIFF
Alignment
A lens changes its effective focal length as it focuses, so consecutive frames are scaled slightly differently and shifted. On the two example series the engine was designed against, the scale drifts 1.5 % and 7.5 % across the stack, with shifts of up to 92 pixels. The stacker therefore fits an affine transform (scale, rotation, shear and shift) from each frame to the middle frame using the enhanced correlation coefficient method (Evangelidis & Psarakis, 2008), coarse to fine at ⅛ and ¼ of the frame size. It fits on the frames' edges — gradient magnitude, normalised by its local mean — rather than on their pixels, because the whole point of a bracket is that every region's contrast changes from frame to frame while the edges stay where they are. A frame whose fit correlates below 0.2 with the reference is skipped and named in the result.
The vote
Each aligned frame is decomposed into a six-level Laplacian pyramid (Burt & Adelson). At every level, the local energy of the detail — the smoothed absolute Laplacian — says how sharp that frame is in that region at that scale. The frame with the largest energy wins the coefficient; a majority filter over each winner map (5 × 5 at the two finest levels, 3 × 3 above) stops a single noisy pixel pulling detail from the wrong frame. The base band, which carries colour and exposure, is the mean of all frames.
Two passes, so memory does not grow with the frame count
Pass one reads each frame, aligns it, votes, and forgets it: what survives is one running best-energy map and one winner map per level, for the whole stack. Pass two reads each frame again, warps it with the pass-one solution, builds its pyramid and copies its coefficients into the output wherever it won. The peak memory is a few frames' worth whether you stack five frames or fifty. The cost is decoding each file twice, which is a small fraction of the arithmetic.
Crop and export
Alignment moves frames, so some edge of the reference is not covered by every frame. The output is cropped to the region all used frames cover, and the result panel says how much was removed. The image is handed over as JPEG (quality 92), PNG when it is 12 megapixels or less, and 16-bit TIFF on request — the TIFF is written from the engine's floating-point result, not from the 8-bit preview.
What the page sends over the network
- Its own HTML, CSS, scripts and the engine worker, from this domain.
- One audience-measurement beacon per page view and per named event (
work_started,work_completed, and a closed list of others) toanalytics.pagefabrica.com. It is cookieless, honours Do Not Track, and carries no file name, size, dimension, pixel or EXIF field — the code that sends it can only send a name from a fixed list. - After you accept advertising where consent is required, Google's ad library and its consent platform. Nothing about your frames enters an ad request.
- On the first RAW frame you drop — and never before — the RAW decoder module,
/vendor/raw/rawlab.wasm, from this domain. The request names the module and nothing else.
That is the complete list. A unit test in the site's own test suite fails the build if any script contains a request that could carry a frame, and the browser test stacks a second series with the network switched off.
Limits
- Movement between frames is not corrected; it ghosts.
- Overlapping edges at different depths can produce a halo the vote cannot resolve. There is no retouching brush in this version.
- Exposure and white balance are not equalised between frames.
- All frames must have the same pixel dimensions and the same format; a RAW among JPEGs is left out and named.
- RAW: the mosaic is demosaiced bilinearly at full size (an exact 2×2 bin at half size; X-Trans is read only through its 3×3 bin, so a Fuji bracket is stacked at a third of the sensor's size and the page says so); lens corrections and the camera's picture profile are not applied; exposure is automatic at export; linear DNG (already demosaiced) is not read yet. TIFF: strips only, 8- or 16-bit, uncompressed, PackBits, LZW or Deflate; tiles, floating point and CMYK are refused by name; no colour management, so export in sRGB. HEIC decodes only in Safari. RAW needs Chrome 95, Firefox 100 or Safari 15.2 or newer.
- A phone or tablet stacks at most ten frames at reduced size.
Sources
- G. D. Evangelidis and E. Z. Psarakis, Parametric Image Alignment Using Enhanced Correlation Coefficient Maximization, IEEE TPAMI 30(10), 2008.
- P. J. Burt and E. H. Adelson, The Laplacian Pyramid as a Compact Image Code, IEEE Trans. Communications 31(4), 1983.
- P. J. Burt and R. J. Kolczynski, Enhanced image capture through fusion, ICCV 1993 — the pyramid selection rule enfuse and this engine use.
- The example series used to measure the engine come from the MIT-licensed focus-stack project by Petteri Aimonen; see licences.