Skin whitening is one of the essential functions of any popular face filter software. However, if you search for skin whitening algorithms on the internet, you may not have much to get and use. I have always thought that this algorithm is actually very simple, and the implementation methods can be said to be varied. This article shares the three implementation methods I have studied.
First, use the color balancing algorithm.
Color balance is a commonly used function in Photoshop. It is found that this algorithm can achieve skin whitening by chance from a software called digitalcameraenhance. The interface of this software is as follows:
The Adjustment Center tone column shows that the intensity of skin whitening on the right side of the target image is increasing. So I think the most famous feature in PS is the color balance function, enabling the color balance function, if the three boxes of the Color Order are set to the same positive value and the preserve brightness option is not checked, the image is obviously white.
Note 1: the three adjustment values of the color order must be the same or the difference is very small. Otherwise, the output image may be partial. Second, select the intermediate adjustment. Third, you must not check the maintain brightness option.
The code for this algorithm can be deducted from the open-source gimp software. In fact, if the above three conditions are met, competent people will find that it is actually a ing table, the specific algorithm formula is not provided here. Gimp is open-source. If you have this requirement, you should find it by yourself.
Second, use logarithmic curve.
In fact, skin whitening is mainly used to make skin white and brightened. Therefore, if a suitable ing table is available, the source image will be enhanced in the color order, and the brightness will be slightly weaker at both ends, with a slight intensity in the middle, it is also a good choice. When studying an image enhancement paper, a two-stage contrast enhancement algorithm for digital images, we found that one of the formulas is very suitable for this situation:
W (x, y) indicates the input image data, V (x, y) indicates the input result, beta is the adjustment parameter, and beta is [2, 3, 3, 4, 5] hour curve, such:
It can be seen that the larger the beta version, the stronger the whitening degree. I think this program should be easy to implement.
Third: Use layer mixing.
I did this using Photoshop. Open the image, click the channel panel, and press Ctrl + and click the RGB channel image, in this way, you can obtain a selection area based on the image strength (the selection area is actually a gray image), return to the layer panel, click New layer, and then click Add layer mask, in this way, the content of the selected selection area is used as a mask, and the layer is filled in white. Adjust the transparency of the new layer to control the final whitening degree.
In this method, it is important to take the image strength content as a mask.
This layer + Mask Encoding implementation is actually a process of Alpha mixing. If you are interested in implementation, you can study it on your own.
I personally think that if you have mastered most of the algorithms for adjusting the menu in PS, you will not be able to adjust the color in many meitu software. Of course, there is a powerful basis for art as a support, it depends on the artist to find a certain effect through some steps, and then on the programmer code. I can't do it.
The above operations are all for full graph processing. After all, the non-skin parts will also be processed, which may be inappropriate in many cases, therefore, a better way is to recognize the skin color. Of course, the principle of this skin color recognition is the same as that of my previous skin polishing algorithm. It should be neither necessary nor accurate, at the edge, a certain degree of appearance is required, including non-skin parts, so that the entire image looks more natural.
I have done some processing with the above three algorithms, and the results are as follows:
Colorbalance of the source image. The parameter is 75.
Log curve. The Beta parameter is a mixture of 5 layers with an opacity of 30%.
Colorbalance of the source image. The parameter is 75.
Log curve. The Beta parameter is a 6-layer mixture with an opacity of 35%.
Colorbalance of the source image. The parameter is 75.
Log curve. The Beta parameter is a mixture of 5 layers with an opacity of 30%.
Purely for this function, it is not much different from software such as meitu xiuxiu.
Test download: http://files.cnblogs.com/Imageshop/SkinWhitening.rar
The above test images are from the Internet.
* *************************** Basically, I do not provide source code, however, I will try to use text to clearly describe the corresponding algorithm or provide the reference documentation ************************
* ************************************ Because it depends on your own the effort and the effect written in practice are exactly what they are, people must rely on their own *******************
* ************************** Laviewpbt time: 2014.7.14 contact QQ: 33184777 reprinted. Please keep the information of this bank **********************