📜 ⬆️ ⬇️

Cleaning the image from noise, some methods

If you saw a picture that is obtained in modern digital cameras without processing, then you know that it looks just awful. It is filled with noise. Even when you download a picture to a computer and it has already been internally processed in a camera, if you increase it and look at individual pixels, you can see how courageously digital algorithms are struggling with noise and losing in this unequal war.
Some algorithms erase fine details completely, these are famous Nokia cell phones. In some cases, the details remained, but they are surrounded by colored islands of complex shape, this can be seen in Sony cameras. Well, and so on - each method has its own problems.

What means are there to remove this noise, and which do not violate other patents? I hope this short review will be useful.

1. Transition to the brightness-color coordinates.
This conversion can be done in many ways: HSV, L * a * b, etc. For some reason, which we will not go into:
- the human eye is much less sensitive to the details of color information than the luminance
- noise in the color component, on the contrary, is much higher than in the brightness
Therefore, simple filtering of the color components + reverse recovery usually makes the image much better.
')
2. The median filter.
A good easy way to clear the image of noise is the median filter Im_new (x, y) = median {dx = -1..1, dy = -1..1} Im (x + dx, y + dy).
This method has many variations, I will give only a few:
2.1 Step 1: calculate M1 = median (C, Cnorth, Csouth); M2 = median (C, Ceast, Cwest); M3 = median (C, Cne, Csw); M4 = median (C, Cnw, Csw); here Cnort, Cne, ... Cnw are eight neighboring pixels from a 3x3 neighborhood, C is the central pixel
Step 2 - calculate Ma = median (C, M1, M2); Mb = median (C, M3, M4);
Step 3 - calculate Csmooth = median (C, Ma, Mb);
Step 4 - Replace C with Csmooth.
2.2 Step 1: sort pixels from a 3x3 neighborhood in ascending order, P [1] ... P [9].
Step 2: If the central pixel is P [1] - replace it with P [2], if the central pixel is P [9] - replace it with P [8], otherwise leave it unchanged.
This direction is used by Kodak, as well as most scanners and fax machines.

3. Filters that control the amount of correction
This method first suggests smoothing the picture somehow roughly, for example using a low-pass filter, bilateral filter or something else. And then such a procedure is done.
Im_new (x, y) = Im (x, y) + S (Im (x, y) -Im_smooth (x, y), threshold).
The transmitter function S can be arranged differently, for example:
S (x, threshold) = x if -threshold <x <threshold; S (x, threshold) = threshold if x> threshold; S (x, threshold) = - threshold if x <-threshold. If the threshold is chosen to be approximately equal to the noise value, then all noise will disappear, and the details and small objects will remain clear.

4. Bilateral filter
Very interesting filter, invented in 2003. For descriptions refer to the Internet.
Here is a pretty good article: scien.stanford.edu/class/psych221/projects/06/imagescaling/bilati.html
An interesting kind of bilateral filter is also T-filter:
Step 1: Find all the pixels in a neighborhood whose values ​​differ from the source pixel by no more than the specified threshold.
Step 2: Average these found pixels and save the value.

5. Filters using spectral representation of the signal
So works, for example, Photoshop. The idea is to do a Fourier transform in the neighborhood of each pixel, then erase the high frequencies and do the inverse transform.
Instead of the Fourier transform, other orthogonal bases are also used, sometimes quite intricate. In essence, this is a whole family of methods.

6. Filters, highlighting the dominant direction
At each point, these filters first find the dominant direction (the direction of the brightness gradient), and then average the signal only in the perpendicular direction. Thus, the lines and small details remain clear. Good variations of this algorithm also take into account the values ​​of the matrix of second derivatives.
This is a whole family of algorithms, descriptions of which can also be found on the Internet.

7. Local classification of fragments
These filters work particularly well with special images, such as text, starry sky, etc.
First, a database of typical elements of such an image is compiled, for example, several hundred fragments of NxN pixels that have already been cleared of noise.
The algorithm works like this: the neighborhood of each pixel is compared with these fragments and the one that is most similar is selected. Then the value of the original pixel in the dirty picture is replaced with the value of the analogous pixel located in the same place on the blank fragment.

8. I will give at the end a “simple” method, which can also be used in a number of cases.
Step 1: Reduce the image (using some clever Downscaling algorithm)
Step 2: Increase it back (using some smart Upscaling algorithm)
The fact is that the Upscaling / Downscaling algorithms are very powerful (Lanczos filter, fractal methods, etc.), so the result is quite satisfactory. The same method can be used as a simple but fairly effective compression.

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


All Articles