How the Photoshop Dehaze Filter Removes Fog
The Dehaze filter in Adobe Photoshop removes atmospheric fog and haze by applying a physical model of optical scattering to mathematically reconstruct the original scene radiance. Instead of simply increasing global contrast or saturation, the algorithm estimates the density of particulate matter in the atmosphere at different depths of an image, calculates the amount of scattered ambient light, and subtracts that interference to restore lost color, edge detail, and contrast.
The Atmospheric Scattering Model
The fundamental mechanism behind Photoshop's Dehaze filter is based on the atmospheric scattering model, originally derived from Koschmieder's Law. When photographing through fog, haze, or smoke, the light reaching the camera sensor consists of two components:
- Direct Attenuation: The actual light reflected from the subject, which weakens exponentially over distance as it is scattered and absorbed by atmospheric particles.
- Airlight (Ambient Scattering): Diffuse ambient light scattered into the camera's line of sight by particles, which acts as a veil that reduces contrast and shifts colors (often toward a pale blue, white, or gray).
The algorithm models the captured image using the equation:
\[I(x) = J(x)t(x) + A(1 - t(x))\]
In this model, \(I(x)\) is the hazy image captured by the camera, \(J(x)\) is the true scene radiance (the haze-free image), \(A\) is the global atmospheric light vector, and \(t(x)\) is the transmission map representing the portion of light that reaches the sensor without scattering.
Estimating Airlight
To begin the dehazing process, the algorithm identifies the global atmospheric light (\(A\)). It analyzes the image to locate the regions most heavily veiled by fog—often the brightest, lowest-contrast pixels that do not correspond to pure white specular highlights or artificial light sources. By sampling these regions, the filter determines the precise color cast and brightness of the scattered ambient light.
Constructing the Transmission Map
The most complex step is calculating the transmission map, \(t(x)\), which effectively acts as an estimated depth map of the scene. Photoshop largely relies on principles similar to the Dark Channel Prior (DCP) heuristic.
In clear, haze-free outdoor images, most local, non-sky patches contain some pixels that have very low intensity in at least one color channel (red, green, or blue). However, because atmospheric airlight adds brightness across all channels, hazy regions lose these dark pixels. By measuring how much the lowest-intensity channel has been elevated in localized neighborhoods, the filter calculates the density of the haze layer across different areas of the frame.
Photoshop refines this raw transmission map using edge-preserving smoothing techniques (such as guided filtering). This prevents abrupt transitions and avoids unnatural halo artifacts around sharp edges, such as mountain ridges or tree lines against the sky.
Scene Radiance Recovery
Once the atmospheric light (\(A\)) and the transmission map (\(t(x)\)) are established, the filter inverts the optical model to isolate and solve for the clear image, \(J(x)\):
\[J(x) = \frac{I(x) - A}{t(x)} + A\]
By dividing the subtracted signal by the transmission value, the filter amplifies the attenuated light from distant objects proportionally to their estimated distance. Areas identified as having heavy haze receive greater contrast and saturation recovery, while foreground areas with high transmission values remain relatively untouched.
Local Contrast and Color Reconstruction
Because atmospheric scattering disproportionately degrades high spatial frequencies and desaturates color, the final phase of the Dehaze algorithm restores local micro-contrast and vibrance. It restores the dynamic range specifically within midtones and shadows without clipping specular highlights, producing a clear, natural-looking image.