Check out the latest homepage of Focus Stacking
Focus stacking is a technique used in photography to increase the depth of field in an image by combining multiple images taken at different focus distances into a single image with greater sharpness and clarity from foreground to background. The process involves taking multiple shots of the same scene, each with a different focus distance, and then combining them into one single clear image.
In this project, I chose a pyramid-based method for decomposition, blending and fusion to achieve better final image quality.
Input Image Sequences | Result |
---|---|
Note: Generally this project requires python >= 3, but recommended using python >= 3.6. Recommend to use pyenv for install/manage python versions if you don't have python installed. Simply, to install pyenv, run
curl https://pyenv.run | bash
, and to install python 3.10, runpyenv install 3.10
.
# get the code
git clone https://github.com/bznick98/Focus_Stacking.git
# and go into project directory
cd Focus_Stacking
# use pipenv for virtual environment and package management
pipenv install .
# enable a pipenv virtual env shell, or add 'pipenv run ' before every run command
pipenv shell
# option 1. run focus stacking for all images under a directory
python run.py assets/test_images/test6/
# option 2. or specify images separately
python run.py img1.jpg img2.jpg ...
# for more details and configs, checkout
python run.py -h
- -d, --depth [INT] : the depth (level) of Laplacian Pyramid, default = 5.
- -k, --k_size [INT] : the kernel size of Gaussian Kernel (an integer), default = 5.
- -o, --output_path [STR] : the name of output file, default = 'output.jpg'.
- -h : show help info, all descriptions of args and flags.
- --debug : for debugging, plot laplacian pyramids, original images, final result step by step.
- --plot : TODO: plot final results.
- --naive : to use naive method (max LoG) for focus stacking.
- --eval : to evaluate the focusness(quality) before/after focus stacking using standard deviation, higher is better.
- Wang & Chang 2011, A Multi-focus Image Fusion Method Based on Laplacian Pyramid
- Test6 folder images source
- Some code snippets cited inside helper.py
- Support colored image for laplacian method. (Done!)
- Fix align image error for laplacian method, there is no align step right now.
- Add GUI to the tool, make it easy to use for non-tech photography community.
- A more comprehensive homepage of Focus Stacking is setup, link is given at the top of the page.