did you ever wonder how your smartphone manage to focus on any place you tap on the camera app? 🙂 okey, even if u did or didn’t now you gonna find how.
to achieve the correct focus, modern digital cameras have come up with 3 approaches such as, ACTIVE, PASSIVE and HYBRID. in ACTIVE approach they use separate sensor mechanism to detect focus. in PASSIVE approach, it uses algorithmic ways to find correct focus from the input of the optical system. there are few ways doing this, i’m gonna show you, how it is done with “contrast detection” method.
so let’s jump into some facts. 😉
when a region is at its sharpest focus, the adjacent pixels in the region will be at maximum contrast. in another word difference between intensity levels in the region is higher than the differences between intensity levels in the region, when the region is not focused.
what will happen to the image mean when it is focused or blurred? so let us take a sample image, make it blur and calculate the mean of those two. i blurred the image using gimp (gaussian blur radius 10px) and calculated image statics using
min: 0 (0)
max: 255 (1)
mean: 63.7428 (0.249972)
standard deviation: 80.7208 (0.316552)
min: 0 (0)
max: 255 (1)
mean: 63.7887 (0.250152)
standard deviation: 76.3692 (0.299487)
identify -verbose independent-arcade-lightings.jpg command will pull out all image statistics of you image.
as you can see, mean of the both original and blurred images is same. 🙂 so image mean does not affect with the focus of the image. also, you can see that standard deviation is the variable which has changed with the blurring. an image’s standard deviation is directly related to its contrast. (standard deviation expresses by how much the members of a group differ from the mean value for the group)
so we can conclude 2 facts about focus.
- focus does not affect image mean.
- the spread of the pixel intensities (standard deviation) is affected by focusing.
now we have a great way to measure if a region is focused or not. what we want to do is to implement a mechanical control system for the camera lens to achieve the highest possible contrast of the region. and that is what actually comes with PASSIVE AF digital cameras. the system can be modeled like below.