# Focus Stacking (Combine Photos Focused at Different Distances) > Merge photos focused near and far into one image that is sharp throughout. Upload a ZIP of 2–5 photos of the same subject taken at different focus distances, for macro, product or landscape shots. The photos are aligned (including the small size change from refocusing), a sharpness map picks the sharpest photo for every area, and a Laplacian pyramid blends the seams. Download the result and a colour map that shows which photo each area came from. Photo Lab in Lumina runs the same engine on your device. Part of usefulweb.app (https://usefulweb.app/). Part of [Lumina](https://lumina.usefulweb.app/) (ownerApp: lumina). Results are deterministic calculations from the inputs and the listed assumptions; the API returns exactly what the web page shows. ## Use it - Human interface: https://luminafocusstack.usefulweb.app/ (interactive tool at https://luminafocusstack.usefulweb.app/tool) - JSON API: POST https://luminafocusstack.usefulweb.app/api/v1/calculate with a JSON object of inputs (schema: https://luminafocusstack.usefulweb.app/api/v1/tool) - OpenAPI: https://luminafocusstack.usefulweb.app/openapi.json - MCP (Streamable HTTP): https://luminafocusstack.usefulweb.app/mcp - tool `lumina_focus_stack` ## Inputs - images (file, required): ZIP of 2–5 photos (PNG, JPEG or WebP; 12 megapixels together) - All photos must have the same size. ZIP order is kept; the middle photo is the alignment reference. - align (boolean): Align the photos (shift, rotation and scale) - crop (boolean): Crop to the area every photo covers - model (select): Alignment transform - radius (integer): Sharpness window radius (pixels) - Larger windows give calmer seams on noisy photos; smaller windows follow fine edges. - blend (select): Blend ## Method - Sharpness: the grey image is filtered with a 3 × 3 Laplacian; the squared response is averaged over a (2r + 1) × (2r + 1) window, giving a local focus energy per photo. - "Sharpest photo per area" gives every pixel weight 1 for the photo with the highest energy (ties: the earlier photo) and 0 for the others; "Weighted" uses energy² normalised per pixel. The weight maps are blended in a Laplacian pyramid exactly as in exposure fusion, which softens the seams between photos. - Alignment is the same as in exposure fusion: Harris corners matched with Lumina Astro Lab's triangle-matching RANSAC between neighbouring photos, Lucas–Kanade intensity refinement (unbiased by defocus blur), bicubic resampling and an optional crop to the common area. The source map colours each pixel by the photo with the highest weight.