How Image Division Fixes Uneven Lighting in GIMP
Dividing an image by a heavily blurred duplicate of itself is a standard digital image processing technique used to remove gradients, vignettes, and non-uniform illumination. This article explains the mathematical and optical principles behind this method, showing how separating high-frequency textures from low-frequency lighting allows GIMP's "Divide" blend mode to isolate and cancel out uneven background exposure, leaving behind a uniformly lit image.
The Physics of an Image: Reflectance and Illumination
To understand why division works, an image must be broken down into its physical components using the Retinex theory of vision. Any photograph can be mathematically approximated as the product of two factors:
\[\text{Image}(x, y) = \text{Reflectance}(x, y) \times \text{Illumination}(x, y)\]
- Reflectance: The intrinsic details, textures, colors, and edges of the subject itself. These are high-frequency details that change rapidly from pixel to pixel.
- Illumination: The light cast upon the subject. Uneven lighting, spotlights, and lens vignetting are low-frequency variations that change smoothly and gradually across the scene.
Because the final pixel values are the result of light multiplying against the surface's reflectance, reversing uneven lighting requires division rather than subtraction.
Why Blurring Isolates the Illumination
Applying a heavy Gaussian blur to an image acts as a low-pass spatial filter. It eliminates the fine details, fine lines, and sharp edges (high-frequency reflectance data) while preserving the broad, gradual shifts in brightness (low-frequency illumination data).
The resulting blurred image is essentially a map of the uneven illumination field:
\[\text{Blurred Layer} \approx \text{Illumination}(x, y)\]
The Mathematics of the "Divide" Blend Mode
In GIMP, the "Divide" blend mode takes each pixel value from the lower layer (the original image) and divides it by the corresponding pixel value from the upper layer (the blurred duplicate), scaling the result back to standard display values (typically 0–255 or 0.0–1.0):
\[\text{Result} = \frac{\text{Original}}{\text{Blurred Duplicate}} = \frac{\text{Reflectance} \times \text{Illumination}}{\text{Illumination}} = \text{Reflectance}\]
Because the illumination term exists in both the numerator and the denominator, it cancels itself out:
- In overly bright areas (hotspots): The blurred layer has a high pixel value. Dividing the original bright pixels by this large value scales them down, darkening the hotspot.
- In dark or shadowed areas (vignetting): The blurred layer has a low pixel value. Dividing the original dark pixels by a fraction increases their relative value, lifting the shadows.
By scaling every pixel relative to the local brightness captured in the blur, the overall variation in illumination across the frame is normalized to a flat, neutral baseline while preserving the underlying details of the image.