Contrast Detection Autofocus

Contrast detection autofocus (CDAF) is an autofocus method that measures sharpness on the image sensor itself. The camera moves the lens a small step, checks the contrast between neighboring pixels in the focus area, and repeats until contrast stops rising. A sharp edge is a steep jump from dark to light; blur softens it, so the contrast peak marks the point of focus. The reading comes from the final image, so it is accurate. But the camera only knows it passed the peak afterward and must back up, a motion called hunting. Compact cameras, phones, DSLR live view, and early mirrorless cameras rely on it; hybrid systems use it for the final adjustment.

Egor Kloos shot the Rotterdam cube houses on a Panasonic Lumix GX9, a camera that focuses by contrast detection alone. A still subject, hard edges in every direction, and f/11 give the system an easy peak and no reason to hurry.

Egor Kloos

How contrast detection autofocus affects photography

The missing piece is direction. Phase detection autofocus measures how far and which way the lens is off before it moves. Contrast detection learns nothing from one reading, so it steps, compares, overshoots, and comes back. On a still subject that takes a split second. In continuous autofocus (AF-C) the peak keeps moving while the lens is still searching, which is why contrast-only cameras struggle with sports and birds. Hybrid systems let phase detection jump close before contrast detection confirms the exact point.

Where speed does not matter, contrast detection is the more precise method. It reads the real image, so no separate module can drift out of alignment and no front or back focus needs calibrating. It works at any aperture, including f/16 on a macro lens, because it does not need the wide baseline phase detection gets from a large maximum aperture. The focus area can shrink to a pinpoint on an insect's eye. Adapted lenses, slow lenses, and live view on a tripod all suit it.

Its weak spots are whatever weakens the contrast signal. A plain wall, a clear sky, fog, or a dim room gives the camera no edge to measure, so it hunts across the whole range and may give up. In video the pulse as the lens checks both sides of focus is visible, one reason on-sensor phase detection took over.

Tips for working with contrast detection autofocus

  • Use single autofocus (AF-S) for still subjects and let the camera settle before taking the shot.

  • Put the focus point on a hard edge: an eyelid, a window frame, or lettering, not a smooth cheek or open sky.

  • Choose the smallest focus area for macro and product work. A large box locks onto whatever has the strongest edges.

  • When it keeps hunting, magnify the view and switch to manual focus. The same contrast is easy to see by eye at 10x.

  • For moving subjects, use a camera with phase detection or hybrid autofocus, or pre-focus where the subject will arrive.

Frequently Asked Questions

Contrast detection autofocus is a focusing method that measures sharpness on the image sensor itself. The camera moves the lens in small steps and checks the contrast between neighboring pixels in the focus area after each step. Contrast is highest when the subject is sharp, so the camera stops at the peak. It needs no extra hardware, works with any lens, and is accurate, but it must pass the peak to recognize it, so it is slower than phase detection and can hunt back and forth.

Phase detection compares two views of the subject from opposite sides of the lens and reads how far and in which direction the lens must move, so it goes straight to focus. Contrast detection only measures how sharp the image is right now, so it has to search by stepping the lens and comparing readings. Phase detection is faster and better for moving subjects. Contrast detection is more precise on still subjects, needs no calibration, and works at small apertures. Most mirrorless cameras now use both in a hybrid system.

The camera cannot tell from one reading whether the lens should move closer or farther, or how far. It picks a direction, steps the lens, and checks whether contrast went up or down. To be sure it found the peak it has to pass it and see contrast fall, then step back. That overshoot and return is the hunting a photographer sees in the viewfinder. In low light or on a low-contrast subject the readings are noisy, so the camera may hunt across the whole focus range before locking or giving up.

On a still subject, yes. Contrast detection judges focus from the image recorded by the sensor, so what it reports as sharp is sharp. Phase detection in a DSLR uses a separate module that can be slightly misaligned, producing front or back focus that needs fine-tuning per lens. Contrast detection has no such offset. It also works with a smaller focus area, which matters for macro work. Its accuracy drops when the scene has little contrast or when the subject moves during the search.

Compact cameras and most phone cameras rely on it, as do DSLRs when they focus in live view with the mirror up. Early mirrorless cameras and some later models, including many Panasonic Lumix bodies before 2023, several Olympus PEN and OM-D models, the Fujifilm GFX 50 series, and the Leica Q2, use contrast detection alone. Nearly all current mirrorless cameras pair on-sensor phase detection with contrast detection, using phase detection to get close and contrast detection to confirm the final position.

It suits macro work well. Depth of field at close range is paper thin, and contrast detection can place a tiny focus point on the exact detail that must be sharp, such as an insect's eye. It also keeps working at f/11 or f/16, where the small aperture can starve a DSLR's phase detection module of light. The subject has to stay still during the search, so a tripod or a calm moment helps. For insects that will not sit still, many photographers switch to manual focus and rock the camera back and forth.

The system needs a measurable difference between neighboring pixels. In dim light the sensor signal is weak and noisy, so the contrast readings between steps become unreliable and the camera cannot tell a real peak from noise. It responds by taking more steps, searching farther, or failing to lock. Opening the aperture for focusing, using the AF assist lamp, aiming at a lit edge, or raising the scene brightness all help. Manual focus with magnification is the fallback.

It works, but the search is visible. Each time the camera refocuses it steps through and past the sharp point before settling, which shows as a pulse or wobble in the footage. Cameras built for video use on-sensor phase detection or hybrid systems so the lens can move smoothly to the new distance without overshooting. On a contrast-only camera, locking focus before recording or focusing by hand gives cleaner results.

Depth from Defocus is Panasonic's way of speeding up contrast detection. The camera stores a profile of how each lens blurs an out-of-focus point, compares two frames taken at slightly different focus positions, and estimates both the distance and the direction to focus from the shape of the blur. That cuts most of the hunting. It still finishes with a normal contrast check, so it remains a contrast-based system and works best with native lenses that have a stored profile.

Hybrid autofocus combines phase detection and contrast detection on the same sensor. Phase detection pixels measure the distance and direction and drive the lens most of the way in one move. Contrast detection then checks the image and makes a small final adjustment to the exact peak. The result is close to phase detection speed with contrast detection precision. Nearly all mirrorless cameras released since the mid-2010s use some form of hybrid system.

Discover more

There's so much photography to see.

Sign Up
Profile pictureProfile pictureProfile picture

Community, not comparison

Build relationships with and learn from other photographers while enjoying a chronological feed and no public counts.

Learn more

Focused features

Gorgeous apps, public profiles, appreciations, categories, ad free, high quality images, camera and lens feeds…

Learn more