Focus stacking is an image processing technique where a series of images focused at multiple planes are combined allowing full control over depth of field. In this project, focus stacking is implemented to generate an all-in-focus image. The implementation is done in four stages: image capture, alignment, in-focus detection, and blending.
A series of images of a static scene are captured at differing focal depths.
The images in the focus stack are aligned using a calculated lens-to-sensor distance for each image that is proportional to the image size (magnification from lens adjustment) captured by the detector.
The images are filtered using a Laplacian operator for edge detection, and then blurred using a Gaussian filter to map a genaral area of in-focusness.
The images of the filtered stack that contain the highest intensity value pixels are recorded into a single image and scaled to the range 0 to 1 to form a depth map.
The depth map is used to combine the in-focus pixels from the original stack images.




