We live in a 3-D world, but a camera can only create a 2-D record of the scene outside its lens.
One of the resulting limitations is the need to focus the camera to get a sharp image. The further an object is from the camera, the nearer the camera's sensor (or, in days gone by, the film) needs to be to the lens to get a sharp image.
So focusing the camera is a matter of positioning the lens the right distance from the sensor. But how can a camera work out what that distance is on its own? There are two approaches to this problem, active and passive.
Active autofocus, which was common before the digital revolution, relies on trying to work out how far away the photographer's subject is and then positioning the lens appropriately. The camera emits sound or infrared, waits for it to bounce back off whatever the camera is pointed at and uses the delay to work out the range. In days gone by, this was a good solution, although it was easy for the rangefinder to make a mistake.
Sonar, for example, won't focus properly through windows, because the sound bounces back off the glass.
With the appearance of digital cameras, active autofocus became less common, because now even simple point-and-click cameras come with enough electronics to support passive autofocus without much extra work.
Instead of trying to measure the distance from the camera to the subject like active autofocus, passive autofocus keeps adjusting the lens position until the image on the sensor is as sharp as possible.
You still need a way for the camera to measure the sharpness, though.
A camera doesn't appreciate the images it captures like a human: You may be photographing a loved one or a forest or an ocean, but the camera is oblivious to all that, it's mainly concerned with capturing pixels and storing them to memory.
One very common technique, known as contrast autofocus, uses the sharpness of edges to estimate focus. The blurriness of an unfocused image ensures that it contains no sharp edges and that one pixel looks much like other nearby pixels. But in a focused image the sharp edges will show up as abrupt changes between pixels. All the camera has to do is keep adjusting the focus and measuring the sharpness of edges until it has worked out which setting provides the sharpest result.
Ad Feedback
Like active autofocus, passive autofocus has its faults. It only works if there are some clear edges in the subject, which is why if you point a digital camera at a plain-coloured wall it will buzz and buzz as it tries to focus before eventually giving up. Passive autofocus works well where there are clear edges which means that, when it comes to cameras at least, it is best to focus on the details