{'fraction_non_alphanumeric': 0.024247164646069613, 'fraction_numerical': 0.005214444009907443, 'mean_word_length': 4.887950882578664, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Color transfer based on color classification

In order to solve the problem that the global color transfer algorithm may fail in color-rich images and the resulting images do not have a sense of hierarchy, this paper proposes a color transfer algorithm based on color classification mapping. When faced with a colorful image, the global color transfer algorithm will be weak, and the resulting image will not have a sense of hierarchy. Therefore, it is necessary to use a local algorithm for color transfer. The k-means algorithm based on color classification is used in this paper. Through this algorithm, rich color information can be classified, so that it can be transmitted separately in each color classification. A large number of experimental results show that compared with the global color transfer algorithm, the color transfer algorithm used in this paper is more layered, the result is more accurate, and it has a better performance in terms of visual effects.


Introduction
Color transfer is a common work in image processing. Its purpose is to adjust the color information of another image according to the color of one color image. The scope of application includes the enhancement of images and videos, and the aesthetics of cultural relics and artworks, image correction for further processing. The input of color transfer is two images: one is the target image, and the other is the color image. The output image is required to have the color style of the color image while maintaining the target image content as a whole.
Reinhard et al. [1] creatively propose a set of transformation formulas, which enabled the target image to have the same mean and standard deviation in the lαβ space as the color image, thereby achieving global color transfer. Pitie et al. [2] propose an N-dimensional probability distribution function transfer algorithm, which is implemented by rotating the coordinate axis and then matching each one-dimensional edge distribution. When N = 3, the algorithm realizes the global color transfer of the image, andbetter achieves the color retention of the color image by the transfer result. But for matching, in the process of stretching the pixels, the algorithm will produce unnatural results such as white points and artifacts in the stretched area because there is no extra detail in the result image. Pitie et al. [3] introduce a new method based on Monge-Kantorovitch transportation, but it's still a global transfer method.
Li et al. [4] propose a color transfer algorithm based on color combination that can evoke different emotions. This algorithm can transfer different emotions through different color schemes. This method has no reference image, and the color transfer results in a single emotional image. Gao et al. [5] introduce color transfer to the improvement of personal landscape photos. By removing the attractive areas in the photos to improve the quality of the photos, it can be effectively applied to the  [6] propose a gradient-preserving algorithm based on the L0 norm. The similarity-based color transfer model was constructed by super-pixel similarity, and gradient preservation was performed through the L0 norm. Grogan et al. [7,8] adopt a method based on shape registration, which is a local algorithm, but the time cost is too large Due to the widespread application of deep learning, algorithms for color transfer and harmonization [9,10,11] through deep learning have emerged. Although this type of algorithm has a good transfer effect, it requires a relatively large data set, and the learning network is more complicated, and the entire process is time-consuming. In this paper, we propose a new color transfer algorithm. The algorithm includes color classification of the target image and the source image, and color transfer of the corresponding areas. Figure 1 shows an overview of our method. Given the target image and the source image, we classify the two images separately and transfer the two images into the lαβ space at the same time, then divide the three regions of the lαβ values of the two images according to the classification results. Finally, we perform color transfer in the areas corresponding to the two images.

Color classification
A color image needs a three-dimensional color space to represent it, so each pixel of the image can be represented by a three-dimensional color vector, that is, each color image can be regarded as a collection of three-dimensional color vectors. In this step, after considering the results and running time of kmeans algorithm, EM algorithm and improved EM algorithm, this paper adopts kmeans algorithm. When the initial color center is given, the kmeans algorithm can effectively segment the color, and the running time is shorter. The EM algorithm and the improved EM algorithm need to start with kmeans, and adjust each classification according to information such as probability information, and the adjustment process greatly increases the running time of the program.
The algorithm proposed in this paper requires color transfer according to the corresponding area, and does not need to adjust the level of the area. If the initial clustering center is given, kmeans can In the color wheel of art, rich colors are created by superimposing and mixing primary colors instead of arranging them according to wavelength. The first color is centered on red and contains magenta to orange; The second color is centered on green and contains orange-yellow to blue-green; The third color is centered on blue and contains light-blue to purple (different groups and the corresponding centers can be exchanged with each other). Since the colors on the color wheel are dense, it is a difficult problem to determine the specific center value and boundary value of each category, but we only need the initial value of the color classification for subsequent color classification. We don't want to strictly bind each color category to each category, because in extreme cases, determining the colors of two borders as one category and dividing similar colors into two categories will have a great effect on the resulting image. This is why we do not use Euclidean distance for classification but use kmeans for classification. Another reason for using kmeans is that the proposed algorithm expects colors to be transmitted in similar clusters., though each area may cross the set boundaries. It is necessary to approach the center of each color classification without accurately representing the center of each group, each center needs to be have a representative hue and high saturation. In this paper, (230,0,18), (0,153,68), (29,32,136) are used as the initial classification centers, some images need proper adjustment center. The overall color classification steps are as follows: (1) Initialization. Input the three-dimensional color vector set of color image and structure image, input the set number of clusters three, and enter the initial cluster center.
(2) Iterate. The image 3D color vector object is matched to the closest clustering center according to recent criteria.
(3) Update the cluster center. According to the average value of each class as the new cluster center, the vector objects are redistributed.

Color transfer
Once the color classification is performed, color transfer needs to be performed for each area. Reinhard's algorithm transfers the image to the uncorrelated color space of each channel, can achieve color transfer in each area. Therefore, after color classification, the source image and target image are transferred to the lαβ space. Then the following formula is used to transfer the color of each region.