Skip to content

Simple implementation of focus stacking technique.

Notifications You must be signed in to change notification settings

pwlnk/focus-stacking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Focus Stacking

This repository contains simple implementation of focus stacking technique, which is used in digital image processing. It combines multiple images taken at different focus distances to give a resulting image with a greated depth of field than any of the individual source images. [Wikipedia]

Images in example-images directory comes from http://grail.cs.washington.edu/projects/photomontage/data/bug.zip.

Requirements and Technical Info

To run this project OpenCV 3 is required (used for images disk operations).

Project was compiled and tested under Manjaro Linux 17.1.10 (kernel 4.14.47).

Build and Run Instruction

Building:

In order to build this program, please download and extract this repository and then follow below steps:

cd focus-stacking
mkdir build
cd build

cmake ../
make

Running:

After compilation two executables should be created: runAllTests and focusStacking.

In order to run tests, execute:

./runAllTests

In order to run focus stacking, execute (all arguments are optional):

./focusStacking [images_directory [bg_threshold [kernels_size [gaussian_sigma]]]]

Example:

./focusStacking ../example-images/ 70 7 5.0

After processing results are stored in the same director as executable. Results are two JPG images, i.e. focus_image.jpg and depth_map.jpg.

Parameters:

You can specify following arguments:

  • images_directory [string] - relative path to directory where images are stored (default=../example-images/)
  • bg_threshold [unsigned int] - threshold value used to decide whether edges are meaningful or whether they belong to image background (default=70)
  • kernels_size [unsigned int] - size of gaussian and laplacian filters (default=7)
  • gaussian_sigma [float] - sigma parameter of gaussian kernel (default=5.0)

Example Results

All in Focus Image Depth Map
bg_threshold=25, kernels_size=3, gaussian_sigma=2.0
all-in-focus depth-map
bg_threshold=70, kernels_size=7, gaussian_sigma=5.0
all-in-focus depth-map
bg_threshold=160, kernels_size=13, gaussian_sigma=7.0
all-in-focus depth-map

Bonus

Animated image generated with depthy.me tool.

all-in-focus

About

Simple implementation of focus stacking technique.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published