Ask Your Question
0

Is it possible to combine 3 photos of different focal lengths to make the clearest image possible?

asked 2018-09-22 03:30:42 -0500

kaf120 gravatar image

I'm creating a function on my Android app that takes 3 photos at three different focal lengths and will combine the images to make one sharp image. Because each photo has a different focuses there will be parts of the photo that will be blurry and parts that will be clear. Is it possible to find the clear parts of the images and combine them into one single clear photo? I'm completely new to OpenCV and was wondering if something like this was even possible and if it would be difficult. I imagine something like this would be pretty difficult since the code has to recognize what is clear and what isn't. In addition, what would be the best way to approach this? I've looked at some capabilities of OpenCV like filtering and blending but i'm unsure of what to use exactly.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2018-09-22 10:06:50 -0500

berak gravatar image

updated 2018-09-22 10:50:29 -0500

YES ! it 's called "focus stacking".

the algorithm, quoting straight from here goes like this:

  1. Align the images. Changing the focus on a lens, even if the camera remains fixed, causes a mild zooming on the images. We need to correct the images so they line up perfectly on top of each other.
  2. Perform a gaussian blur on all images
  3. Compute the laplacian on the blurred image to generate a gradient map
  4. Create a blank output image with the same size as the original input images
  5. For each pixel [x,y] in the output image, copy the pixel [x,y] from the input image which has the largest gradient [x,y]
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-09-22 03:30:42 -0500

Seen: 32 times

Last updated: Sep 22