Skip to content

Commit a2f6b07

Browse files
committed
.
1 parent fde966f commit a2f6b07

File tree

10 files changed

+15
-15
lines changed

10 files changed

+15
-15
lines changed

_posts/2025-04-22-naive-even-ilumination.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ color: success
66
description: A simple and efficient method to correct uneven ilumination in images
77
---
88

9-
TAGS: image processing
10-
119
# Introduction
1210

1311
A way to improve uneven illumination in images → just as we can fit a line to a 1D signal, we can fit a plane to an image, as if it were a parallelepiped with a certain tilt. We convert this plane into a grayscale image, center it at 0±tol (with both negative and positive values), and add it to the grayscale channel of the unevenly illuminated image. This will make bright areas darker and dark areas brighter—or something like that. It’s like applying a proportional shadow correction to make the luminance channel more homogeneous.
@@ -18,7 +16,7 @@ When we observe an image with uneven illumination, we often sense that something
1816

1917
# Theoretical Background
2018

21-
Imagine a grayscale image as a 3D surface, where each pixel has coordinates \((x, y)\) and an intensity \(z\). If we fit a plane to this surface using linear regression (least squares), we obtain a representation of the general intensity trend across the image.
19+
Imagine a grayscale image as a 3D surface, where each pixel has coordinates $$(x, y)$$ and an intensity $$z$$. If we fit a plane to this surface using linear regression (least squares), we obtain a representation of the general intensity trend across the image.
2220

2321
This plane can be interpreted as capturing the global illumination or tonal bias of the image. By centering this plane around zero and scaling it appropriately, we can add it to the original image to enhance intensity differences: bright areas become darker and dark areas become brighter, thus improving the homogeneity of illumination.
2422

@@ -60,10 +58,10 @@ c
6058
= I,
6159
$$
6260

63-
where $I$ is the vector of intensities and:
61+
where $$I$$ is the vector of intensities and:
6462

6563
$$
66-
A = \begin{bmatrix} x_1 & y_1 & 1; \\ x_2 & y_2 & 1; \\ \cdots & \cdots & \cdots \end{bmatrix}
64+
A = \begin{bmatrix} x_1 & y_1 & 1 \\ x_2 & y_2 & 1 \\ \vdots & \vdots & \vdots \end{bmatrix}
6765
$$
6866

6967
Solve using least squares:
@@ -97,29 +95,31 @@ Finally, clip values to valid range and convert back to `uint8`:
9795
I_out = np.clip(I_out, 0, 255).astype(np.uint8)
9896
```
9997

100-
# 3D Visualization
98+
# Experimentation
10199

102-
This visualization helps to understand how the plane fits the image’s intensity surface and how its addition enhances illumination.
100+
The 3D visualization helps to understand how the plane fits the image’s intensity surface and how its addition enhances illumination.
103101

104102
Testing with some synthetic images:
105103

106104
| Uneven | Heightmap and plane | Corrected |
107105
|--------|----------------------|-----------|
108-
| ![](../assets/blog_images/2025-04-22-naive-even-ilumination/1.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_1.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_1.png) |
109-
| ![](../assets/blog_images/2025-04-22-naive-even-ilumination/2.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_2.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_2.png) |
110-
| ![](../assets/blog_images/2025-04-22-naive-even-ilumination/3.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_3.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_3.png) |
111-
| ![](../assets/blog_images/2025-04-22-naive-even-ilumination/4.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_4.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_4.png) |
106+
| <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/1.png" width="300" height="300" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_1.png" width="450" height="450" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_1.png" width="300" height="300" /> |
107+
| <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/2.png" width="300" height="300" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_2.png" width="450" height="450" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_2.png" width="300" height="300" /> |
108+
| <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/3.png" width="300" height="300" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_3.png" width="450" height="450" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_3.png" width="300" height="300" /> |
109+
| <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/4.png" width="300" height="300" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_4.png" width="450" height="450" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_4.png" width="300" height="300" /> |
112110

113111
And with some real images:
114112

115113
| Uneven | Heightmap and plane | Corrected |
116114
|--------|----------------------|-----------|
117-
| ![](../assets/blog_images/2025-04-22-naive-even-ilumination/5.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_5.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_5.png) |
118-
| ![](../assets/blog_images/2025-04-22-naive-even-ilumination/6.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_6.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_6.png) |
119-
| ![](../assets/blog_images/2025-04-22-naive-even-ilumination/7.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_7.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_7.png) |
120-
| ![](../assets/blog_images/2025-04-22-naive-even-ilumination/8.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_8.png) | ![](../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_8.png) |
115+
| <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/5.png" width="300" height="300" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_5.png" width="450" height="450" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_5.png" width="300" height="300" /> |
116+
| <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/6.png" width="300" height="300" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_6.png" width="450" height="450" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_6.png" width="300" height="300" /> |
117+
| <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/7.png" width="300" height="300" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_7.png" width="450" height="450" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_7.png" width="300" height="300" /> |
118+
| <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/8.png" width="300" height="300" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/3d_surface_8.png" width="450" height="450" /> | <img src="../assets/blog_images/2025-04-22-naive-even-ilumination/perceptually_improved_8.png" width="300" height="300" /> |
121119

122120
# Conclusion
123121

124122
When vignetting is strong or the uneven distribution is very unimodal (e.g., in case 3), the method tends to perform worse than when the plane fit is clearly dominated by a directional tilt.
125123

124+
Additionally, the idea behind the model is to counteract the nearly saturated regions in the opposite way, so it’s not a very intelligent algorithm and relies on a manual parameter. However, as seen in the paper's case, it is particularly useful for specific applications where an aesthetically pleasing perception of the image is desired in real time, Avoiding uneven lighting effects characteristic of a real outdoor scene.
125+
19.7 KB
Loading
64.8 KB
Loading
-142 KB
Loading
-6.52 KB
Loading
16.2 KB
Loading
26.7 KB
Loading
179 KB
Loading
151 KB
Loading
192 KB
Loading

0 commit comments

Comments
 (0)