📜 ⬆️ ⬇️

Recovery of unevenly lit images

To improve the visual quality of images taken in low light conditions, and images with low contrast levels, there are many algorithms. The choice of the most suitable algorithm and its parameters is a non-trivial task and depends on the image being processed.

imageimage

In most cases, to restore the color characteristics of an unevenly lit image, it manages: linear correction of brightness and contrast, power (gamma) correction, and logarithmic correction (retinex).

Source image
image
')
Autolevel algorithm
image

Gamma Correction
image

Linear correction
image

Multi-Scale Retinex
image

In this case, in my opinion, all algorithms except linear correction improved visual image quality.

Autolevel algorithm


The Autolevel algorithm is based on the principle: the darkest color in the image is black, and the lightest is white. That is, if the images contain small, very bright or very dark areas, then there is a high probability that the algorithm will not give the desired result. Autolevel is also very sensitive to impulse noise.

Example

Source image
image

Autolevel algorithm
image

Gamma Correction


The Gamma Correction algorithm is based on a power conversion of the image pixel intensities. In this algorithm, the intensity of the dark pixels of the image increases more than the intensity of bright pixels.

Gamma Correction
image

Retinex


It should be noted that the above algorithms do not take into account local neighborhoods of pixels, therefore, in cases where the image contains, as well as very dark and very bright local areas, these algorithms cannot provide high-quality image recovery. In these situations, it is advisable to use the algorithm Retinex and its modifications.

The SSR (Single-Scale Retinex) algorithm aligns the luminance of the image, while maintaining local contrast in poorly and brightly lit areas. Correction occurs according to the formula:

R (x, y, sigma) = log [I (x, y)] - log [I (x, y) * G (x, y, sigma)]

where G is Ggaussian, sigma is the blur coefficient, and " * " is the convolution operator.
After applying the SSR, the main part of the received pixels belongs to the range [-1; 1], to visualize the image, the values ​​must be normalized by the formula:
I = 255 * I + 127

Algorithm Single-Scale Retinex, sigma = 18
image

Algorithm Single-Scale Retinex, sigma = 400
image

Algorithm Single-Scale Retinex, sigma = 4000
image

The MSR (Multi-Scale Retinex) algorithm is a weighted sum of SSRs with different blur ratios.
MSR = w1 · SSR1 + w2 · SSR2 + ... + wn · SSRn
moreover, w1 + w2 + ... + wn = 1 . Usually, in practice n = 3

Algorithm Multi-Scale Retinex, sigma = 7, 480, 4800
image

Retinex algorithms are applied to the luminance channel, therefore, it is necessary to adjust the chromatic components after it, for example, linearly increasing the contrast or saturation.

Algorithm Multi-Scale Retinex + Contrast Correction
image

Sources


Source: https://habr.com/ru/post/150767/


All Articles