Skip to content

Combines multiple images taken at different focus distances to produce a final image with a greater depth of field

Notifications You must be signed in to change notification settings

bznick98/Focus_Stacking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Check out the latest homepage of Focus Stacking

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

Result Demo

Demo 1 Demo 2

Workflow

Image of project workflow > Detailed Report

Installation

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, run pyenv 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

Run

# 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

Some optional arguments and flags

Arguments:

  • -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'.

Flags:

  • -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.

Source

TODO

  • 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.

About

Combines multiple images taken at different focus distances to produce a final image with a greater depth of field

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages