## 5 Multi-Attribute Image Aesthetic Processing
### Portrait Beauty Case  
Like image denoising, skin smoothing is a basic facial beautification method that aims to remove blemishes and acne, and cover flaws and wrinkles. To enhance realism, this study adopts a local mean-square error filter algorithm for skin smoothing that preserves the  
Figure 6: Aesthetic processing of image color saturation attribute. Figure 7: Comprehensive processing of image contrast and color saturation. details of the image. The denoising principle of the skin smoothing algorithm is described as follows. Suppose that there is a grayscale image of size \(N*M\), and \(x_{ij}\) represents the pixel value at position \((i,j)\). Then, the local average value and local mean-square error within the \((2n+1)(2m+1)\) window can be expressed as follows:  
\[m_{ij}=\frac{1}{(2n+1)(2m+1)}\sum_{k=i-n}^{n+i}\sum_{l=j-m}^{m+j}x_{kl} \tag{5}\]  
The formula for calculating the local variance \(v_{ij}\) is as follows:  
\[v_{ij}=\frac{1}{(2n+1)(2m+1)}\sum_{k=i-n}^{n+i}\sum_{l=j-m}^{m+j}\left(x_{kl}- m_{ij}\right)^{2} \tag{6}\]  
The filtering formula for the local mean-square error is as follows:  
\[x_{ij}=(1-k)m_{ij}+kx_{ij} \tag{7}\]  
where \(x_{ij}\) represents the pixel value of the input image, and coefficient \(k\) is expressed as follows:  
\[k=\frac{v_{ij}}{v_{ij}+\sigma} \tag{8}\]  
where \(\sigma\) is the parameter input by the user. The variance \(Var(x)\) is expressed as follows:  
\[ \begin{array}{c}\text{Var}(x)=\sum_{i=1}^{n}p_{i}(x_{i}-\mu)^{2}\\ =\frac{1}{n}\left(\sum_{i=1}^{n}x_{i}^{2}-\frac{1}{n}(\sum_{i=1}^{n}x_{i})^{2 }\right)\end{array}  \tag{9}\]  
If the variance value in Equation (9) is small for an image, then the area is smooth grayscale. Hence, the difference in grayscale values between pixels is small. Conversely, the variance increases when it is a local edge or high-frequency area; hence, the user's input parameters can be ignored. After filtering, the processed image is equivalent to the grayscale value of the input. Overall, this algorithm ensures image smoothness while preserving edge information and does not significantly impact the edges. The importance of fair skin is high in modern aesthetics. Adaptive whitening has to be performed for portrait beautification, as the brightness of the skin is generally low. Additionally, the whitening process can moderately increase image brightness. In this study, the beauty algorithm uses a log curve to enhance the whitening effect. The log curve follows Weber-Fechner's law of visual characteristics, which aligns the whitening effect with human perception. The formula for this principle is as follows:  
\[F(x,y)=\frac{\log(L(x,y)\times(\beta-1)+1)}{\log(\beta)} \tag{10}\]  
where \(F(x,y)\) represents the image after the brightness adjustment, \(L(x,y)\) represents the input image, and \(\beta\) represents the brightness-adjustment parameter. The larger the \(\beta\) value, the greater the whitening effect. The implementation steps of the portrait beauty function are as follows:  
1. Import the MagicJni.cpp source file written in C++ as an independent beauty function module. This module includes skin smoothing and portrait whitening algorithms, which can effectively improve image quality. 2. Edit the CMakeLists.txt file and use the Android Native Development Kit (NDK) to convert the.cpp file into a.so file. 3. Use the Java Native Interface (JNI) to call the C++ function. Therefore, in Java, the MagicJni class is used to call the local mean-square error filter algorithm and the log curve whitening algorithm to achieve beauty processing. 4. Package the.so file into a.apk file using the NDK and run it on a smartphone. Figure 8 illustrates the impact of portrait image beauty. In this situation, a scene recognition model is employed to detect people. By implementing skin smoothing and  
whitening, the portrait's aesthetic appeal can be improved while slightly enhancing the overall brightness of the image, thereby replacing the customary dependence on lighting in portrait photography.