Simple Focus Stacking in Python: Merge a collection of photos taken at different focus depths into one image with sharp focus
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Input Updated sample images Dec 14, 2015
.gitignore Added .gitignore Dec 14, 2015 Algorithm speed up improvement Oct 20, 2016
LICENSE Initial commit Dec 14, 2015 Updated read me, comments in Dec 14, 2015 Create Dec 14, 2015


Simple Focus Stacking in Python

This project implements a simple focus stacking algorithm in Python.

Focus stacking is useful when your depth of field is shallower than all the objects you wish to capture (in macro photography, this is very common). Instead, you take a series of pictures where you focus progressively throughout the range of images, so that you have a series of images that, in aggregate, have everything in focus. Focus stacking, then, merges these images by taking the best focused region from all of them to build up the final composite image.

The focus stacking logic is contained in There is a sample driver program in It assumes that there is a subdirectory called "input" which contains the source images. It generates an output called "merged.png".

I have also included some sample images in the input directory to allow you to experiment with the code without having to shoot your own set of images.

This project is Copyright 2015 Charles McGuinness, and is released under the Apache 2.0 license (see license file for precise details).