Skip to content

Lesson 10.1 · Level 2 — Intermediate

How does autofocus work?

How does the camera know what to focus on?

Module 10 · Focus and Sharpness

2,245 words · about 10 minutes of reading · 9 min video script

  • autofocus
  • contrast detection
  • phase detection
  • hybrid AF
  • focus hunting
Glance at the summary firstThe summary from the end of the lesson, as a road map before you start reading.

For the camera, sharpness is local contrast at edges, and autofocus searches for the lens position that makes this contrast highest. Contrast detection finds an accurate but slow result by moving the lens back and forth, while phase detection compares the light coming from two edges of the lens, learns the direction and amount in one go, and is fast with moving subjects; many cameras combine the two in a hybrid way. Low light, surfaces without edges, repeating patterns and glass make autofocus struggle; on faces, regardless of how light the skin is, putting the focus on a contrasty place such as the edge of the eye or the eyelashes both helps the camera and keeps the most important place in the portrait sharp.

Learning goal

You will be able to explain how the camera finds sharpness in a scene. You will show that for the camera, sharpness means local contrast at edges; you will tell apart contrast detection, which searches for the sharpest point by moving the lens back and forth, from phase detection, which compares the light from two sides and finds the direction and amount in one go; you will recognize hybrid focus, where the two methods combine; you will know why autofocus struggles in low light, on flat surfaces, on repeating patterns and behind glass; and on low-contrast faces, of any skin, dark or light, you will learn to place the focus on a contrasty edge.

The question

When you half-press the shutter button, there is a small movement inside the lens; a few milliseconds later a box on the screen turns green and the image sharpens. Sometimes, though, the camera twitches back and forth, can't make up its mind, and finally focuses on the wall behind. The same camera that catches a running child instantly can't find a person standing in front of a blank wall one evening in a dim room.

How does the camera know what to focus on? In fact it doesn't know; it only looks and measures. Autofocus imitates what the eye does when it looks at an object, but it does this with two different methods, two different ways of "seeing". In this lesson we will talk about those two methods, why the camera sometimes behaves quickly and sometimes in confusion, and how to make focus reliable by helping it.

Context

In the lesson where we explained how the camera works, we saw that some of the lens elements inside the lens move back and forth to gather the light on the sensor, and that this is called focusing. In Lesson 4.3 you learned to direct focus to a point on a phone by tapping the screen. This module focuses on sharpness itself: how the camera finds sharpness, how it follows moving subjects, where the focus point is placed, and why photos come out blurry.

In the exposure module, understanding the camera's metering meant knowing where it would go wrong. The same holds for focus. Someone who knows how autofocus works senses before the shot in which scene it will struggle, and helps the camera. This lesson lays the foundation for the rest of the module: focus modes, focus areas, eye tracking and manual focus are all built on these two ways of seeing.

Simple explanation

How does the camera recognize sharpness?

For a person, a sharp photo is a photo whose details can be made out. For the camera, sharpness is a number: the size of the difference between points standing side by side. When the edge of an eyelash, the letters of some writing or the texture of a fabric are sharp, bright and dark points touch each other along a sharp border. When the same things are blurry, this border softens and neighboring points look alike. This can be called local contrast.

Autofocus measures this local contrast around the chosen focus point and searches for the lens position that makes it highest. That is why the camera can't focus everywhere with the same ease. On a surface with clear edges, lines or texture, focus is found quickly. On a blank wall, a cloudless sky or a misty scene, on the other hand, there are no edges to measure; wherever the lens goes, the image looks almost the same, and the camera struggles to find sharpness. In the camera's eyes, sharpness means edges.

How does contrast detection work?

Contrast detection is one of the simplest and oldest methods. The camera moves the lens in one direction and looks at whether the local contrast is rising. If it is rising, it continues in the same direction; when it starts to fall, it understands that it has passed the sharpest point and comes back. That is why contrast detection has to overshoot the sharpest point a little to find it; the lens goes forward, comes back, sometimes several times. This is why contrast-detection AF is often described as a search.

The advantage of this method is its accuracy: because it measures sharpness directly on the image the sensor sees, the point it finally finds is usually very precise. Its disadvantage is its speed: the search takes time, and if the subject is moving, by the time the lens finds the sharpest point the subject may already have gone somewhere else. The image blurring for a brief moment on the screen and sharpening again is the trace of this search. When the camera can't reach a decision for a long time, this is called focus hunting; it is common in low light and on flat surfaces.

How does phase detection work?

Phase detection works with a different logic. It gathers the light coming from two separate edges of the lens separately and compares these two images. If the subject is exactly in focus, the two images sit on top of each other. If it isn't, they slide apart, and the direction of this slide tells which way the lens needs to go, and the amount tells how far. This is like focusing old rangefinder cameras by bringing two images on top of each other: as soon as you look, you know the direction and the distance.

That is why phase-detection AF is fast; without searching, it goes straight to somewhere near the right point. It is especially suited to following moving subjects. In cameras with a mirror this job is done by a separate focus sensor under the mirror; in mirrorless cameras and many phones, special points placed on the sensor do the same job. Today many cameras use the two methods together: they approach quickly with phase detection and make the last fine adjustment with contrast detection. This is called hybrid AF, and it is a common solution today.

When does autofocus struggle?

Both methods need light and edges. As the light drops, the information reaching the sensor shrinks and edges get lost in the grain; autofocus slows down or hunts. Many cameras and phones switch on a small assist light over the subject in this case. Flat surfaces without edges, repeating patterns, for example the close lines of a curtain or a fence, and glass or bright reflections also confuse focus; the camera may focus on the glass itself or on the reflection behind it.

Faces are sometimes low-contrast surfaces too. Dark skin in a dim room, light skin in flat, soft light, or a forehead recorded close to white in bright sun offers the camera few edges to measure. In this case it helps to place the focus not in the middle of the face but on a contrasty edge: the edge of the eye, the eyelash line, where the eyebrow starts, the hairline or the frame of a pair of glasses. The eyes are often the most important place in a portrait and usually the most contrasty area of the face; setting the focus there both makes things easier for the camera and keeps sharp the place the viewer will look at first.

Visual evidence

Imagine photographing your grandmother knitting in front of a white wall one evening, in the dim light of the lamp in the corner. The focus point is in the middle of the frame, on your grandmother's cheek. You half-press the shutter button; the image on the screen blurs and sharpens, blurs again, the camera hunts back and forth and finally focuses on the corner of the wall behind. In the photo the wall is sharp, and your grandmother's deep wheat-colored face is soft.

You move the focus point to the frame of your grandmother's glasses, right next to her eye. This time the camera decides in one go; the box turns green. In the photo the thin metal frame of the glasses, her eyelashes and the lines around her eyes are sharp; her cheek is inside the slice of sharpness too. The texture of the needles and the wool in her hands can be made out as well. The same light, the same camera; only the focus point was moved to an edge the camera could measure.

Common mistakes

Common mistakeThinking autofocus will work equally well on every surface.
Correction

On a blank wall, in the sky or in a misty scene there are no edges to measure. The fix: put the focus point on a place with an edge, a line or texture.

Common mistakePressing the shutter button all the way and shooting while the camera is hunting.
Correction

A frame taken before the lens finds sharpness comes out blurry. The fix: wait for the focus confirmation, that is the green box or the beep; if it can't find it, move the focus point to a contrasty edge.

Common mistakePutting the focus on a flat area of the face in a portrait.
Correction

Flat areas such as the cheek or forehead offer few edges, especially in dim or flat light. The fix: place the focus on the edge of the eye, the eyelashes or the frame of the glasses.

Summary

For the camera, sharpness is local contrast at edges, and autofocus searches for the lens position that makes this contrast highest. Contrast detection finds an accurate but slow result by moving the lens back and forth, while phase detection compares the light coming from two edges of the lens, learns the direction and amount in one go, and is fast with moving subjects; many cameras combine the two in a hybrid way. Low light, surfaces without edges, repeating patterns and glass make autofocus struggle; on faces, regardless of how light the skin is, putting the focus on a contrasty place such as the edge of the eye or the eyelashes both helps the camera and keeps the most important place in the portrait sharp.

Mini assignment

In this assignment you will find for yourself where autofocus is strong and where it is weak.

  1. In the same light, try focusing once on a blank wall and once on a surface with writing or a pattern on it, and note in which one the camera decides faster.
  2. In a dim room, take two frames of a face, focusing first on the cheek, then on the edge of the eye, and compare where sharpness falls in the two frames.
  3. Try focusing on an object behind a window pane, and look at whether the camera focuses on the glass or on the object.
  4. Check in the settings whether the focus assist light on your camera or phone is turned on.

Check yourself

  • Were you able to tell on which surfaces the camera hunts and on which it decides in one go?
  • In the frame focused on the eye, is the face sharper than in the frame focused on the cheek?
  • In the dim light, whatever the face's skin tone, were you able to find a contrasty edge and set the focus there?

Glossary

TermShort definition
AutofocusThe camera finding sharpness by itself by adjusting the position of the lens.
Contrast-detection AFA focus method that moves the lens back and forth and searches for the point where local contrast is highest.
Phase-detection AFA focus method that compares the light coming from two edges of the lens and finds the direction and amount in one go.
Hybrid AFA combined method that approaches quickly with phase detection and fine-tunes with contrast detection.
Focus huntingThe camera failing to find sharpness and moving the lens back and forth.

Mini quiz

1. What does sharpness mean for the camera?

  • A) The photo's brightness
  • B) The vividness of the colors
  • C) The size of the local contrast at edges
  • D) The photo's size

2. What is the most noticeable disadvantage of contrast detection?

  • A) That it can be slow because it searches
  • B) That it is never accurate
  • C) That it only works in daytime
  • D) That it spoils colors

3. Why is phase detection fast with moving subjects?

  • A) Because it never moves the lens
  • B) Because it only works at wide angles
  • C) Because it doesn't measure light
  • D) Because it finds the direction and amount in one go from the slide between two images

4. If autofocus is hunting on a face in a dim room, what should you do?

  • A) Move the focus to a contrasty place such as the edge of the eye or the eyelashes
  • B) Put the focus point in the middle of the cheek
  • C) Turn the camera to a blank wall
  • D) Press the shutter button all the way and shoot

Answers

  1. C — In a sharp image, bright and dark points meet along a sharp border; the camera measures this local contrast.
  2. A — Contrast detection overshoots the sharpest point to find it and comes back; this search takes time.
  3. D — The slide between the images coming from the two edges tells the direction and amount; the lens goes to the right point without searching.
  4. A — Flat areas such as the cheek offer few edges; the edge of the eye and the eyelashes give the camera a measurable contrast.

Summary card

  • For the camera, sharpness means edges: local contrast.
  • Contrast detection: searches back and forth, accurate but slow.
  • Phase detection: compares two images, knows the direction and amount in one go.
  • Low light, flat surfaces, repeating patterns and glass make focus struggle.
  • In portraits, put the focus on the edge of the eye, the eyelashes or the frame of the glasses.

Bridge to the next lesson

You now know how the camera finds sharpness. But what it does with the sharpness it finds is a separate decision: find sharpness once on a still subject and lock it, or, with a running child, keep searching for sharpness again and again as the subject moves? The next lesson describes how a moving subject stays sharp, and the camera's two basic focus modes.

Animation and narration notes

Animation and narration notes

Video flow

  • 0:00–0:40 🖥️ A box turning green on the screen when the shutter button is half-pressed; then an image hunting back and forth in front of a blank wall. The question appears.
  • 0:40–1:40 🎬 A group of lens elements moving back and forth inside the lens; light gathering in front of, on and behind the sensor.
  • 1:40–2:50 🎬 The edge of an eyelash, sharp and blurred; two bar graphs showing the brightness difference between neighboring points. A graph that doesn't change at all on a blank wall.
  • 2:50–4:10 🎬 Contrast detection: the lens goes one way, the contrast bar rises, passes the peak and falls, the lens comes back. An image blurring and sharpening on the screen.
  • 4:10–5:30 🎬 Phase detection: the light coming from two edges of the lens forms two separate images; while the images are slid apart, an arrow shows the direction and amount, then they sit on top of each other. A separate focus sensor in a camera with a mirror, points on the sensor in a mirrorless one; the two methods working one after the other in hybrid focus.
  • 5:30–6:40 📷 Focus hunting in dim light and an assist light; curtain lines, glass and reflections. On a low-contrast face, the focus being moved to the edge of the eye, the eyelashes and the frame of the glasses.
  • 6:40–8:10 📷 Two frames of the knitting grandmother, with the focus on the cheek and on the frame of her glasses.
  • 8:10–9:00 🎬 A camera focusing on the wall, a shutter button pressed without waiting, focus put on the cheek; at the close, the assignment's wall, pattern and glass frames.

Audio version note

The lesson's images rely on the difference between sharpness and blur and on the camera's internal movements; what is sharp, what is soft and how the camera behaves are described to the listener in words.

  • Contrast detection: "The image blurs for a moment, then sharpens, then blurs slightly again and comes back; the camera overshoots the sharpest point a little and comes back to find it."
  • Phase detection: "Imagine two half images; one slid a little to the left, one a little to the right. As the lens moves, the two halves come closer together and finally sit on top of each other as a single sharp image."
  • The frame focused on the cheek: "The corner of the white wall behind is sharp; the grandmother's face, on the other hand, is soft, and her eyes and glasses can't be made out."
  • The frame focused on the frame of the glasses: "The thin metal frame of the glasses, her eyelashes and the lines around her eyes are sharp; the needles in her hands and the texture of the wool can be made out too."

Pronunciation notes

  • "AF" is read letter by letter, "A F"; "hybrid" is read normally.