Home/Technologies/How Phase Detection Autofocus Works: The Complete Guide
Technologies

How Phase Detection Autofocus Works: The Complete Guide

Phase detection autofocus uses two images to determine the correct lens movement for sharp focus. Discover how it works in DSLRs, mirrorless cameras, and smartphones, plus the differences from contrast detection and common focusing issues.

Nov 20, 2026
7 min
How Phase Detection Autofocus Works: The Complete Guide

Phase detection autofocus helps a camera determine which way to move the lens when an object in the frame appears out of focus. Imagine you're photographing a person, but the wall behind them is sharp instead. To bring the face into focus, the camera needs to move the focus closer. Conversely, if an object in front of the person is sharp, the lens must be moved in the opposite direction.

To distinguish these scenarios, the camera compares two images of the same part of the frame, captured through different sections of the lens. By analyzing how these images are shifted relative to each other, it determines the direction for focusing and estimates how far the lens should move.

What is phase detection autofocus and why are two images needed?

Picture a black stripe on a white sheet. Phase detection autofocus generates two images of this stripe. One is formed from light passing through the left part of the lens, the other from the right. It's enough to use a small section of the frame where the border between black and white is clear.

When the camera is perfectly focused on the sheet, light from each point of the stripe converges at a single spot on the focus plane. The edge of the stripe appears in the same position in both images. If focus is off, the rays converge either before or after this plane, causing the same edge to appear at different locations in the two images.

The camera analyzes brightness changes in each image, searching for the shift where the transition from white to black matches in both. This relative shift is known as the phase difference in phase detection autofocus.

How does the camera determine lens shift direction and amount?

What the sign of the shift tells about focus direction

Returning to the black stripe example: When the camera is focused in front of the sheet, the stripe's edge appears further right in one image than the other. If focus is behind the sheet, the order is reversed. When focus is correct, the edges align perfectly.

The comparison order of these images is predetermined, so the shift can be given a positive or negative sign. The camera uses this sign to decide whether to move the focus closer or farther and commands the mechanism to move in the appropriate direction.

How the camera calculates the amount to shift the lens

The magnitude of the shift indicates how far off focus is. If, at a certain lens position, the stripe edges are six pixels apart, the error is greater than if they're only two pixels apart. The camera converts this distance on the sensor into a movement for the focusing lens group, taking lens characteristics into account.

After the lens moves, the camera can remeasure the shift. If it's reduced but still present, a small adjustment is made. If the sign reverses, focus has overshot and can be nudged back a little.

Where is phase difference measured in DSLRs, mirrorless cameras, and smartphones?

Dedicated sensor in DSLRs

When photographing through a DSLR's optical viewfinder, the main mirror directs most of the lens light into the viewfinder. Some light passes through a semi-transparent area of the main mirror and hits a secondary mirror, which reflects it down to a separate autofocus module.

Inside this module, small lenses form a pair of images using light from different parts of the lens. During shooting, the mirror flips up to let light reach the sensor. While the mirror is raised, the autofocus module loses its optical path.

Phase-detect pixels on the sensor and Dual Pixel technology

In mirrorless cameras and smartphones with phase detection autofocus (PDAF), the shift is measured directly on the sensor. One method is to place pairs of pixels with partially masked photosensitive areas on the sensor. In each pair, one pixel receives light mostly from one side of the lens, and the other from the opposite side.

With Dual Pixel technology, two photodiodes sit beneath a single microlens. For focusing, their signals can be read separately and compared. When forming the final image, the signals are combined to provide one brightness value per pixel. To learn more about how microlenses gather light and how sensors turn it into photographs, read our detailed guide: CMOS sensors: how they shape digital photography.

How does phase detection differ from contrast detection and what is hybrid autofocus?

Imagine a cyclist riding straight toward the camera. Contrast detection autofocus evaluates sharpness by how abruptly brightness changes at detail edges, like a helmet's outline. The camera shifts the lens slightly and measures contrast again. If the edge is sharper, it continues in the same direction; if blur increases, it reverses. To find peak contrast, the system may overshoot and backtrack, which sometimes appears as a brief oscillation in focus during video.

Phase detection can determine the correct direction and amount of lens movement from the first measurement. As the cyclist approaches, the camera repeats measurements. In continuous focus mode, it can factor in previous readings to predict the subject's position at the moment of capture.

Hybrid autofocus combines both methods. For example, the camera may use phase data to quickly approach the right lens position, then fine-tune using contrast detection. When tracking moving subjects, phase measurements help update focus as distance changes. The way methods are combined depends on the camera model and shooting mode.

Why does phase detection autofocus miss focus?

Low light, uniform surfaces, and repeating patterns

Phase detection needs a feature distinguishable in both images. If the focus point falls on a smooth wall, brightness barely changes in that area, making it hard for the camera to detect a shift-even in good light. If there's an edge of a painting or doorframe at the same distance, focus is easier to achieve.

In darkness, details are harder to spot against noise. On objects with repeating patterns, like a grille, several shifts may yield similar matches. In such cases, it helps to move the focus point to the edge of the pattern, where repetition ends.

Front focus and back focus in DSLRs

If, when shooting through the optical viewfinder, sharpness consistently lands in front of the intended subject, it's called front focus. If it falls behind, it's back focus. For instance, if you repeatedly focus on the middle book in a row but the one closer to the camera is always sharper, it's a sign of front focus.

A likely cause is misalignment between the separate autofocus module and the sensor. The module confirms focus based on its own image, while the sensor achieves peak sharpness at a different lens position. To check, photograph a stationary target through the viewfinder and in Live View (if the camera focuses via the sensor in this mode). If the error only occurs in the first case, the AF module or lens may need calibration.

Conclusion

Phase detection autofocus compares two images of the same area, captured through different parts of the lens. The sign of the shift between them tells the camera which way to move the lens, and the magnitude helps calculate how much to move it.

If your camera struggles to focus on a uniform object, place the autofocus point on its edge or on a contrasting detail at the same distance. This gives the system a boundary to measure the shift and achieve sharp focus.

Tags:

autofocus
phase-detection
mirrorless-cameras
DSLRs
photography-technology
contrast-detection
hybrid-autofocus
dual-pixel

Similar Articles

Loading...
How Phase Detection Autofocus Works in Cameras and Smartphones