Application of All-in-Focus image processing created by Python (OpenCV Python, NumPy and Tkinter).
- Choose directory with .png images for All-in-Focus image processing
- Load image and the next image
- Check if images are RGB or grayscale
- Calculate gradient in x and y directions for each image
- Calculate gradient for each pixel of both images
- Calculate difference between image gradients for each pixel
- Create filter matrix 3x3 filled with ones
- Convolution filter with filter matrix and array from 6)
- Decide pixel from which image is better and save result
If there is more than two files, image in the next iteration will be result of fused images from previous iteration. At the end save output .png file with fused images.
First install the dependencies (required packages) using following command:
pip3 install -r requirements.txt
Then run main .py script using command:
python all_in_focus.py
1st image | 2nd image | 3rd image | 4th image |
---|---|---|---|
No. | Reference | Source |
---|---|---|
1. | Implementation of algorithm based on "A Computationally Efficient Algorithm for Multi-Focus Image Reconstruction" scientific work from Electrical Engineering Department of Stanford University Authors: Helmy A. Eltoukhy and Sam Kavusi |
URL |
2. | Grayscale images data Author: Samet Aymaz |
URL |
3. | RGB images data Authors from the Graphics and Imaging Laboratory of the University of Washington |
URL |