Depth from defocus

Also known as: DFD

On this page 7

Depth from defocus (DFD) is a focusing technique that estimates subject distance from the amount of blur in images captured at slightly different focus positions, using a known optical model of the lens. Within Focus & autofocus in photography, DFD is best known as an extension of contrast detection AF that lets a camera on-sensor system predict the direction and distance to sharp focus instead of searching for it step by step.

The idea originated in computer vision research in the 1980s, where blur was treated as a measurable depth cue. Camera makers later adapted it to mirrorless bodies, most prominently in Panasonic Lumix cameras, to make contrast-based focusing faster without dedicated phase detection pixels.

How depth from defocus measures distance

Depth from defocus works by comparing two or more images of the same scene captured with the focus group in slightly different positions. A point that lies outside the plane of focus is spread into a blur disc, and the size of that disc depends on how far the point sits from the focus plane, the aperture and the focal length.

The camera stores a point spread function (PSF) profile for each compatible lens, describing how that lens blurs light at different apertures, focal lengths and focus distances. By measuring how the blur changes between the two frames and matching the change against the profile, the processor calculates an estimated defocus amount and its sign, which tells the motor whether to move toward infinity or toward the minimum focus distance.

The process runs as a fast closed loop. The following table summarizes the main stages and what each one contributes to the final focus decision.

StageWhat happensResult
Frame captureSensor reads two frames at nearby focus positionsPair of differently blurred images
Blur comparisonProcessor measures local sharpness changeRelative defocus per AF area
PSF matchingChange is matched to stored lens dataDistance and direction estimate
Fast driveFocus motor jumps toward the estimateLens near correct focus
Contrast confirmationFine contrast peak searchFinal, accurate focus
Stages of a depth from defocus focus cycle

The final step matters: in most implementations DFD provides a coarse but fast prediction, and conventional contrast detection performs the last precise adjustment. This hybrid behavior explains why DFD systems are usually very accurate once focus is locked.

Key parameters that affect DFD performance

The reliability of depth from defocus depends on how measurable the blur is and how well the camera knows the lens. Several optical and electronic parameters influence both speed and accuracy.

ParameterTypical influencePractical consequence
Lens profile dataRequired for accurate PSF matchingUnprofiled or adapted lenses fall back to plain contrast AF
ApertureWider apertures produce stronger blur differencesEstimates are often more decisive near maximum aperture
Sensor readout rateHigher frame rates shorten each cycleFaster acquisition and smoother tracking
Scene contrastBlur is measured on edges and texturePlain walls and fog weaken estimates
Light levelNoise masks fine blur changesSlower or hesitant focus in dim interiors
Subject motionMovement between frames distorts comparisonPossible misjudged direction with fast subjects
Parameters and their influence on DFD

Because the method needs lens-specific optical data, DFD is typically restricted to native lenses from the camera maker or partners in the same mount alliance. Third-party and adapted lenses often still focus, but without the predictive advantage.

How DFD compares with other autofocus methods

Depth from defocus sits between pure contrast detection and phase detection AF. It shares the sensor-based accuracy of contrast systems while borrowing part of the distance awareness that phase detection obtains optically.

MethodDistance informationMain strengthMain weakness
Contrast detection AFNone, searches for peakHigh accuracy, simple hardwareSlow, visible hunting
Depth from defocusEstimated from blur and lens modelFaster contrast-based focusDepends on lens data and texture
Phase detection AFMeasured directly from light anglesFast tracking of moving subjectsRequires dedicated pixels or module
Hybrid autofocusPhase data plus contrast confirmationSpeed with accuracyMore complex sensor design
Depth from defocus versus related focusing methods

In practice, the most visible symptom of DFD is reduced but not eliminated focus wobble during video. Continuous autofocus may still show a small breathing-like pulse as the system checks contrast, which is why some videographers moved to cameras with on-sensor phase detection. Panasonic itself added phase detection to later full-frame and Micro Four Thirds bodies while retaining DFD-related processing.

Using a DFD camera effectively

Photographers get the best results from depth from defocus by giving the system clear blur cues and by choosing focus modes that match the subject. The following decision table summarizes practical settings.

SituationRecommended approachReason
Static subject, good lightSingle autofocus with a small AF pointDFD plus contrast confirmation gives precise focus
PortraitsFace or eye detectionDetection narrows the area where blur is measured
Moving subjectContinuous AF with subject tracking and a focus limiterLimits the search range and reduces direction errors
Video interviewFace detection with lowered AF sensitivityReduces visible pulsing between frames
Low-contrast sceneTarget a textured edge or use manual focusDFD needs detail to measure blur
Adapted lensManual focus with focus peakingPredictive DFD data is unavailable
Situations and recommended approaches with DFD

Keeping firmware current is also worth the effort, because manufacturers have refined DFD algorithms and lens profiles through updates. A focus limiter on a telephoto lens reduces the range the system must evaluate and shortens acquisition time.

Limitations and common misconceptions

Depth from defocus is an estimation technique, so its weaknesses come from situations where blur stops being a reliable signal of distance.

  • DFD is not phase detection. It infers distance from image blur rather than measuring it directly from separated light paths.
  • Repeating patterns and low texture can make blur comparison ambiguous and cause hesitation.
  • Fast erratic motion between the compared frames can lead to a wrong direction decision and visible hunting.
  • Strong backlight and flare reduce contrast and degrade the blur measurement.
  • Small apertures such as f/11 or narrower create deep focus zones with weak blur differences, reducing the value of the prediction.

A frequent misunderstanding is that DFD guarantees video focus without pulsing. It shortens the search considerably, but because confirmation still relies on contrast, subtle focus wobble can appear when the subject or lighting changes.

The idea in brief

Depth from defocus lets a camera judge distance by looking at how blurry things are. The camera takes two quick looks with the focus nudged slightly between them. If the blur grows or shrinks, the camera knows which way to turn the focus and roughly how far.

It is a bit like adjusting binoculars: once you notice the view getting sharper, you know which way to keep turning. The camera simply does this with stored knowledge of its lens, so it can jump close to sharp focus instead of searching slowly.

A practical scenario

A travel photographer uses a Micro Four Thirds camera with DFD and a native 12-60 mm zoom in a busy street market. Shooting at 25 mm and f/4, she selects single autofocus with face detection to capture vendors at work. The camera compares blur between frames, drives the lens almost directly to the right distance, and confirms with a brief contrast check, so focus locks in a fraction of a second with no noticeable hunting.

Later she mounts an adapted manual lens for a vintage look. Because the camera has no stored blur profile for that lens, the predictive advantage disappears, so she switches to manual focus with focus peaking. The difference shows clearly that DFD speed depends on native lens data, not on the sensor alone.