Welcome to follow the public account: Sumsmile

With the previous photo manipulation foundation in mind, this one starts with beauty algorithms.

1. Why does filtering protect edges?

One of the most important techniques in portrait beauty technology is skin grinding. Without skin grinding, who dares to take selfies and broadcast live?

Dermabrasion is essentially filtering the image, such as the previous mean filtering, or Gaussian filtering, to put it bluntly is to blur the whole image to a certain degree. However, this is not enough. The whole picture will be blurred, so it is necessary to retain the boundary features of the face of the portrait while blurring. The “reservation” here is to protect the edge.

Second, edge preserving filtering algorithm

There are many kinds of edge preserving filtering algorithms. We will not expand them one by one. Here we only discuss the representative “bilateral filtering” to bring us a perceptual understanding of the realization of edge preserving filtering. Other edge preserving filtering algorithms are listed at the end of the paper, and interested readers can study them by themselves.

2.1 Principle of bilateral filtering: see the following schematic diagram.

The input on the left is an image with a rough surface and a boundary, and the ladder represents the boundary. The intermediate filtering algorithm is a Gaussian blur * range of weights, that is, on the basis of gaussian blur, keep the ladder mutation.

On the right is the result of filtering. The boundary of the image still exists and is not blurred. Both sides of the ladder are smoothed blurred.

If you are smart, you will find that in gaussian blur, you can calculate different weights based on the information of the pixels around the current pixel, and combine the weights to blur. This is the essence of most spatial filtering, and mastering one kind of bilateral filtering makes the others easier to understand.

2.2 Further understanding with the formula of bilateral filtering:

Assume that the neighborhood radius of pixel I (I, j) is R, the neighborhood size is S, and the pixel in the neighborhood is I (k, L), then the calculation formula of the filtered pixel value Id is as follows, w(I, j, k, L) is the weight function

Where the weight w is calculated as follows:

σd and σr are the variances of space distance and color difference, respectively. Exp is a power of the natural number E.

It can be imagined that when processing boundary pixels, pixel mutation, I(I,j) -i (k, L) value is very large, Wr ≈ 0, W(I,j,k, L) is very small on the whole, that is, the surrounding pixels have little influence and almost retain the original value of the current pixel. This is to achieve “edge protection” through weight.

Similarly, when I(I, j) -i (k, L) is close to, Wr ≈ 1, the weight of Gaussian fuzzy Wd is mainly reflected, and the pixel is smooth-blurred.

Treatment results:

Other filtering

The algorithm is rather boring, and it is not suitable for a single article to be large and complete. Here are other common edge preserving filtering algorithms for readers to study by themselves.

1. Surface Blur filtering

Surface Blur filtering, also known as Surface Blur filtering, is a common filtering algorithm in Photoshop, but also a spatial domain filtering algorithm.

2. Guided Filtering Algorithm, Thesis:

Mmlab.ie.cuhk.edu.hk/pdf/pami12G…

3. Local mean filtering algorithm

The local mean filtering algorithm is a filtering algorithm based on the local mean variance proposed by Jong-sen LEE in his paper [8] in 1980. On the basis of ordinary mean filtering, the weight of variance is added, which is widely used because of its high efficiency.

4. The Anisotropic filtering

Anisotropic filtering, also known as Anisotropic diffusion filtering, was proposed by Pietro Perona and Jagannatch Malik in their paper [9] published in 1990, and has a significant effect in image denoising. This algorithm can preserve the edge of the image while removing the noise. Therefore, the author believes that this algorithm can also be used as one of the optional algorithms of beauty algorithm

5. Smart Blur filtering algorithm

Smart Blur is a kind of edge preserving filter that appears in Photoshop 2018 (PS2018 for short).

6. MeanShift filtering algorithm (Mean drift)

MeanShift, or MeanShift, was first proposed by Fukunaga in 1975 with The title of “The Estimation of The Gradient of a density function”. MeanShift filtering algorithm is an image edge preserving filtering algorithm implemented by MeanShift algorithm. It is a little complicated to understand and the algorithm complexity is high. It is not suitable for practical application and should be referred to.

There is no code given in this paper, but I will write a demo later and build the algorithm into Android iOS for readers’ reference.

Reference: Image and video filters with portrait beauty