Image colorization method based on semantic similarity propagation
By combining semantic features and brightness information, designing a similarity propagation energy function and using a trilinear interpolation algorithm, the problem of low image colorization calculation efficiency and color overflow in the existing technology is solved, and an efficient and natural image colorization effect is achieved.
Patent Information
- Application Number
- CN202410772113.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-16
- Publication Date
- 2024-09-20
AI Technical Summary
Existing image colorization algorithms have low computational efficiency, cumbersome user interaction, difficult to avoid color overflow, low color saturation and lack of vividness in the generated images.
Using a method based on semantic similarity propagation, the semantic features of the image are combined with the brightness information, and the energy function of similarity propagation is designed. Through optimization and solution, the local stroke color is propagated to semantically close areas, and the trilinear interpolation algorithm is combined to accelerate the calculation and achieve Image colorization.
It significantly improves the computational efficiency and user interaction experience of image colorization, avoids color overflow, generates images with natural colors, high saturation, and improved visual effects.
Smart Images

Figure CN118674802A
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image processing, and in particular to an image colorization method based on semantic similarity propagation. Background Art
[0002] Image colorization aims to convert grayscale images into color images. This technology has long attracted extensive attention from researchers in the fields of computer graphics and computer vision, and has been widely used in many fields such as image restoration, medical imaging, film restoration, and artistic creation. After decades of development, researchers have proposed a large number of interactive, rule-based, and deep learning-based algorithms to improve the effect of image colorization. Despite this, existing image colorization algorithms still have some significant defects, such as low computational efficiency, color overflow, cumbersome user interaction, and low color saturation and lack of vividness of the generated images.
[0003] Image colorization is a popular research direction in the fields of computer graphics and computer vision. Its purpose is to assign a reasonable color to each pixel in a grayscale image. The application of this technology can not only significantly enhance the visual appeal of the image, but also give the grayscale image a new vitality and expressiveness. In the film and television industry, colorization technology has given old black-and-white movies and TV shows a new lease of life, attracting the attention of a new generation of viewers. In the medical field, colorization technology can help doctors observe and analyze medical images more clearly, thereby improving the accuracy of diagnosis. In the field of art and culture, colorization technology makes historical photos and documents more vivid and easier to understand, providing a new perspective for research and education. In short, this technology has shown great application potential in many fields.
[0004] For decades, scholars at home and abroad have conducted in-depth research on the problem of image colorization. At present, the mainstream image colorization algorithms are mainly divided into two categories: traditional algorithms based on edit propagation and color transfer, and emerging algorithms based on deep learning. Algorithms based on edit propagation usually model the image colorization task as an energy optimization problem based on similarity propagation. This method propagates the brush color specified by the user to other areas with similar brightness, thereby achieving a natural and realistic image colorization effect. However, this type of method generally has the disadvantages of low computational efficiency and cumbersome user interaction, which seriously increases the user's operation burden. Image colorization algorithms based on color transfer usually require users to specify a reference image. The algorithm will comprehensively analyze the color features of the reference image and apply these features to the grayscale image to be processed to achieve colorization. Although this method eliminates the step of user interaction, it also limits the user's ability to personalize the colorization process. Algorithms based on deep learning learn the color selection and propagation mechanism from large-scale data sets. By training complex neural network models, they can automatically color grayscale images without too much user intervention. These deep learning models can usually capture the contextual information of the image, thereby generating color images that are more in line with human visual expectations. However, these methods often have high requirements for computing resources, and the prediction process may take a long time. In addition, the generated images are not ideal in terms of color saturation and are prone to color overflow, which will have an adverse effect on the final visual effect of the image. Summary of the invention
[0005] In order to solve the problems existing in the prior art, the purpose of the present invention is to provide an image colorization method based on semantic similarity propagation, which achieves more accurate and better quality colorization effects with less user interaction and achieves significant improvement in computational efficiency.
[0006] To achieve the above object, the technical solution adopted by the present invention is: an image colorization method based on semantic similarity propagation, comprising the following steps:
[0007] Step 1, semantic feature extraction: combine the semantic features of the image with the brightness information, i.e., the Y channel, to form the feature space of the grayscale image;
[0008] Step 2: Image colorization: Design an energy function based on similarity propagation in the feature space, and propagate the color of the local brush strokes, i.e., the U and V chromaticity channels, to other areas with similar semantics through optimization.
[0009] Step 3: Merge the optimized U and V chromaticity channels with the original Y channel to achieve the conversion of the input image from grayscale to color.
[0010] As a further improvement of the present invention, the step 1 specifically comprises the following steps:
[0011] Step 1.1, using the semantic soft segmentation method to extract the multi-dimensional semantic feature vector of the grayscale image pixel by pixel, and using the principal component analysis method to reduce the dimension of the multi-dimensional semantic feature vector;
[0012] Step 1.2: Optimize the semantic features using the segmentation model. First, input the grayscale image into the segmentation model to obtain a set of masks, and perform deduplication on the masks. Then, in the three-dimensional semantic feature space, use the K-means algorithm to cluster the regions indicated by each mask, cluster the pixels in each region into two categories, and use the cluster center of the category with a larger number to replace the semantic features of all pixels in the region.
[0013] Step 1.3: Combine the semantic features in step 1.1 and step 1.2 with the brightness information to form the features of the grayscale image. Finally, any pixel I in the input image i Each corresponds to a two-dimensional semantic feature vector and a brightness value Y i :
[0014]
[0015] As a further improvement of the present invention, the step 2 is specifically as follows:
[0016] Assuming that in an image with smoothly changing colors, the chromaticity value of any pixel can be represented by the chromaticity values of its neighboring pixels through weighted average; and assuming that pixels with similar features should receive similar colors, that is, chromaticity values U and V; then: image colorization is transformed into the following two energy function optimization problems:
[0017]
[0018]
[0019] Both energy functions contain two terms. The first term is used to minimize the chromaticity value U of any pixel. i or V i and the chromaticity value U of the neighboring pixel p or V p ; The second item is used to constrain the chromaticity value of the user's stroke or Among them, N(i) represents the index of the neighboring pixels of the i-th pixel, It means that the pixel I in the input grayscale image i With Pixel I p similarity;
[0020] The energy function is converted into a linear equations solution problem, and the constraints are incorporated into the solution process as hard constraints, which is converted into a linear equations solution as follows:
[0021] (IW)U=0
[0022] (IW)V=0
[0023] Where I is an n×n identity matrix, (n represents the number of pixels in the image, W is an n×n matrix, W i , j Represents pixel I i With Pixel I j Similarity, U and V are n-dimensional column vectors to be solved.
[0024] As a further improvement of the present invention, pixel I i With Pixel I p The similarity is defined as follows:
[0025]
[0026] Here, δ represents the standard deviation of the Gaussian kernel.
[0027] As a further improvement of the present invention, an interpolation method is used to accelerate the solution of the linear equations. As a three-dimensional point, the entire image can be regarded as a three-dimensional point set. First, the three-dimensional space [0, 1] where the grayscale image is located is 3 The image is evenly divided into b×b×b grids. The stroke color is first propagated to the grid corners, and then the color of the corners is transferred to the image pixels through trilinear interpolation.
[0028] As a further improvement of the present invention, it also includes: for each corner point, its neighborhood is defined as the 6 corner points directly connected to it, and some known corner points are used as constraints. If there are user strokes in the grid associated with a corner point, the average chromaticity of these strokes is used as the chromaticity value of the corner point; otherwise, the chromaticity value of the corner point is unknown and the chromaticity value needs to be obtained through energy optimization.
[0029] The beneficial effects of the present invention are:
[0030] 1. The present invention models the image colorization task as an energy optimization problem based on semantic similarity propagation. The proposed method can effectively propagate the user's brush strokes to other semantically similar regions in the image, thereby achieving a natural and realistic image colorization effect and effectively avoiding problems such as color overflow.
[0031] 2. The present invention greatly improves the efficiency of image colorization processing by adopting a trilinear interpolation algorithm, which not only realizes the rapid conversion of image colors and significantly shortens the processing time, but also greatly improves the user's editing experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 is an overall flow chart of an embodiment of the present invention;
[0033] Figure 2 This is a comparison diagram of the colorization effect before and after optimization and before and after adding brightness in the embodiment of the present invention;
[0034] Figure 3 This is a diagram showing the colorization effect in an embodiment of the present invention;
[0035] Figure 4 A comparison diagram of image color results and calculation time when b takes different values in an embodiment of the present invention;
[0036] Figure 5 A comparison diagram of the effects of the algorithm of the embodiment of the present invention and the existing editing and propagation colorization algorithm;
[0037] Figure 6 A diagram showing the comparison results of the algorithm of the embodiment of the present invention and other deep learning algorithms based on brushstrokes;
[0038] Figure 7 A comparison diagram of the algorithm of the embodiment of the present invention and other fully automatic image colorization algorithms based on deep learning;
[0039] Figure 8 This is a quantitative comparison diagram of the algorithm of the embodiment of the present invention and other colorization algorithms. DETAILED DESCRIPTION
[0040] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0041] Example
[0042] This embodiment proposes an image colorization method based on semantic similarity propagation. First, a deep learning network is used to extract pixel-by-pixel semantic features of the input grayscale image, and it is optimized to construct a feature space of the grayscale image. Then, the image colorization problem is modeled as an efficient energy optimization problem based on semantic similarity propagation. The proposed method is simple to interact with and can quickly propagate the stroke color added by the user to other semantically similar areas in the image, achieving an efficient and interactive image colorization effect, while effectively avoiding problems such as color overflow, ensuring the naturalness and realism of the colored image.
[0043] The overall process of this embodiment is as follows Figure 1As shown in the figure, the input includes a grayscale image I and some user strokes G, and the output is a converted color image I′. The purpose is to design an efficient algorithm that can quickly propagate user strokes to other semantically similar areas in the image to achieve interactive and natural image colorization effects, while effectively avoiding problems such as color overflow.
[0044] This embodiment is mainly divided into two steps: semantic feature extraction and color propagation; the purpose of semantic feature extraction is to combine the semantic features of the image with the brightness information (Y channel) to form the feature space of the grayscale image. In the image colorization step, this embodiment designs an energy function based on similarity propagation in the feature space, and propagates the color of the local brush strokes (U, V chromaticity channels) to other areas close to the semantics through optimization. Finally, the optimized U and V channels are merged with the original Y channel to achieve the conversion of the input image from grayscale to color.
[0045] The present embodiment is further described below:
[0046] Semantic feature extraction:
[0047] Image colorization algorithms based on edit propagation usually rely only on the brightness information of the grayscale image itself for color conversion. During the color propagation process, pixels with similar brightness will receive similar colors. Obviously, this algorithm cannot achieve content-aware color conversion because the user's brushstrokes will unconditionally propagate to multiple objects or regions with similar brightness. To this end, it is hoped that the semantic information of the grayscale image can be introduced into the image colorization algorithm based on edit propagation to achieve content-aware image colorization.
[0048] First, the semantic soft segmentation method (SSS) is used to extract the pixel-by-pixel semantic feature vector of the grayscale image. This method uses DeepLab-ResNet-101 as the backbone network, which can extract a 128-dimensional semantic feature vector and ensure that the semantic features of different types of objects have obvious differences as much as possible. In order to reduce redundant information and speed up the subsequent calculation process, the principal component analysis (PCA) method is further used to reduce the 128-dimensional semantic feature vector to 3 dimensions.
[0049] The semantic features after dimensionality reduction still have a certain degree of noise, which is mainly manifested in two aspects: first, the semantic information within the same object may be quite different; second, different objects may have similar semantic features. If the similarity between pixels is measured directly based on these semantic features, then during the color propagation process, it may cause drastic changes in the color within the same object, or different objects may receive similar colors. Figure 2 As shown, Figure 2 (a) in the figure is the input grayscale image and the user's strokes. The extracted semantic features are shown in (b) in 2. It can be found that there are different semantics inside the field (such as purple and blue), and the yellow color similar to the sky appears inside the house. The colorization effect is shown in the figure below. Figure 2 As shown in (c) in the figure, it can be seen that there is obvious erroneous propagation in the image, and obvious color spillage occurs in the background and around the house. In order to ensure the accurate propagation of color information, the semantic features need to be further optimized.
[0050] The semantic features are optimized with the help of the latest Segment Anything Model (SAM). First, the grayscale image is input into the SAM model to obtain a set of masks (each mask represents an object or region in the input image), and the masks are deduplicated to ensure that they do not overlap. Next, in the three-dimensional semantic feature space, the K-means algorithm is used to cluster the regions shown by each mask. Specifically, the pixels in each region are clustered into two categories, and the semantic features of all pixels in the region are replaced with the cluster center of the larger category. In this way, all pixels in the same region have the same semantic features. This optimization process not only ensures the semantic similarity of objects of the same type, but also makes the semantics of different objects significantly different. Figure 2 (d) in the figure is the optimized semantic feature map. Figure 2 In (c), the grass, house, and background boundaries become clear, and the resulting colorized image is as follows: Figure 2 As shown in (e), it can be seen that the coloring effect is significantly improved and there is no color overflow problem.
[0051] During the experiment, we further found that it is difficult to control the saturation change of colors in images using only semantic features, such as Figure 2As shown in (f) in the figure, the colorization result obtained by simply relying on semantic information for propagation cannot reflect the changes in color saturation in the image. The color of the grass is uniformly yellow and the gradient effect that may exist in the field is lost. In fact, even within the same object, the color saturation is inconsistent: usually, the color saturation of pixels with higher brightness is relatively high, while the color saturation of pixels with lower brightness is relatively low. To this end, the semantic features of the first two dimensions are combined with the brightness information to form the features of the grayscale image. Finally, any pixel I in the input image i Each corresponds to a two-dimensional semantic feature vector and a brightness value Y i ; which can be simply expressed as:
[0052]
[0053] For ease of processing, the semantic information and brightness are normalized to [0,1]. So far, the semantic features of the grayscale image have been extracted and optimized. Next, we will introduce how to achieve efficient color propagation based on the extracted semantic and brightness features.
[0054] Color Spread:
[0055] The image colorization algorithm based on similarity propagation is based on two important assumptions: 1) In an image with smoothly changing colors, the chromaticity value of any pixel can be represented by the chromaticity value of its neighboring pixels through weighted average; 2) Pixels with similar features should receive similar colors (chromaticity values U, V). To this end, image colorization can be transformed into the following energy function optimization problem:
[0056]
[0057] The above two energy functions both contain two terms: the first term is used to minimize the chromaticity value of any pixel (U i or V i ) and the chromaticity value of the neighboring pixel (U p or V p ) weighted average difference; the second term is used to constrain the chromaticity value of the user's stroke ( or ) remains unchanged during the solution process; where N(i) represents the index of the neighboring pixels of the i-th pixel, It means that the pixel I in the input grayscale image i With Pixel I p Specifically, the similarity between any two pixels is defined as follows:
[0058]
[0059] Here, δ represents the standard deviation of the Gaussian kernel. According to experience, δ=1 is taken in this embodiment.
[0060] In the actual solution process, the above energy function is usually converted into a linear equation system, and the constraints are incorporated into the solution process as hard constraints. Here, the first energy function is taken as an example, which is actually equivalent to solving the following linear equation system:
[0061] (IW)U=0
[0062] Where I is an n×n identity matrix (n represents the number of pixels in the image), and W is an n×n matrix (W i,j Represents pixel I i With Pixel I j similarity); U is an n-dimensional column vector to be solved. Once the U and V chromaticity channels of the image are solved, they can be merged with the Y channel to obtain the final colorization result.
[0063] Acceleration strategy:
[0064] In general, the complexity of solving a system of linear equations is as high as O(n 3 ), for an image containing millions of pixels, it is impossible to achieve fast feedback; in order to solve this problem, the interpolation method is used to speed up the solution of the problem; any pixel in the grayscale image As a three-dimensional point, the entire image can be naturally regarded as a three-dimensional point set. First, the three-dimensional space [0,1] where the grayscale image is located 3 The image is evenly divided into b×b×b grids (b=4 in the experiment). Try to propagate the brush color to the grid corners first, and then transfer the color of the corners to the image pixels through trilinear interpolation. This method can effectively reduce the scale of the problem solving because the number of corner points is much less than the number of pixels in the image.
[0065] The energy function to be solved is roughly the same as the above two energy functions. The main difference is that here only the color values of the grid corners need to be solved, so the scale is significantly reduced. For each corner point, its neighborhood is defined as the 6 corner points directly connected to it. In order to solve this problem, some known corner points are also required as constraints; specifically, if there are user strokes in the grid associated with a corner point, the average chromaticity of these strokes is used as the chromaticity value of the corner point; otherwise, the chromaticity value of the corner point is unknown and needs to be obtained through energy optimization.
[0066] Experimental results and analysis:
[0067] The experimental environment of this embodiment is Windows 11, AMD R7-5850U, and 16GB memory; the algorithm is written in C++ language, and the user interface is developed in Qt. Next, the effectiveness of the algorithm of this embodiment will be verified and evaluated from four aspects: colorization results, parameter evaluation, comparative experiment, and running time.
[0068] 1. Colorization results
[0069] Figure 3 The colorization results generated by the algorithm of this embodiment are shown. The second row in the table is the input image and the user's brushstrokes, and the third row is the corresponding colorization results. In the "bedroom" example, the user makes the room vivid and warm with simple brushstrokes. In the "back figure" example, an old photo is revitalized, showing the scene of farmers working hard among the green mountains and clear waters; in the "field" example, the user reproduces the picture of rice seedlings growing vigorously under the blue sky through rough graffiti. In general, the method of this embodiment can accurately realize the user's editing intention, and the visual effect is natural, avoiding problems such as color overflow.
[0070] 2. Parameter evaluation:
[0071] The feature space where the grayscale image is located is evenly divided into b×b×b grids, and the scale of calculation is reduced by propagating color values on the grid corners, thereby achieving efficient color conversion. The choice of b is closely related to the computational efficiency and colorization effect; usually, when the value of b is small, the number of grid corners is small, so the calculation time can be accelerated. However, this also means that the stroke color propagates over a wider range, increasing the risk of color overflow. Conversely, the calculation time is correspondingly extended, and the stroke propagation range is reduced, thereby reducing the possibility of color overflow.
[0072] Figure 4 The comparison of image colorization results and calculation time when b takes different values is listed. It can be seen that when b=2, although the calculation time is relatively low, obvious color overflow occurs (such as the green on the cow's back and the blue on the wall above the kitten). When b=8, although the local color control is better, the calculation time is relatively increased. In contrast, b=4 can ensure higher calculation efficiency and achieve better image colorization effect. Therefore, this embodiment adopts this setting in all experiments.
[0073] 3. Comparative experiment
[0074] 3.1. Comparison with existing edit propagation algorithms:
[0075] Figure 5The comparison between this embodiment and the existing ones in terms of the quality and running time of generated color images is shown. For a fair comparison, the two algorithms use the same user strokes as input. From the colorization results, since the existing algorithms only use the brightness information of the image, it is impossible to achieve content-aware color propagation. For example, in the "rose" example, the left part of the flower presents the green of the background, while the right background presents the red of the flower. In the "walnut" example, the walnut in the lower left corner is propagated to the gray of the carpet, rather than the yellow expected by the user. In contrast, the algorithm of this embodiment introduces the semantic information of the image into the color propagation, achieving content-aware color propagation. At the same time, the generated color image has clear boundaries and no color overflow, so it is more in line with the user's editing intention. In addition, the interpolation method is used to accelerate the calculation process, so the calculation time is much lower than that of the existing algorithm.
[0076] 3.2. Comparison with existing stroke-based deep learning algorithms:
[0077] Figure 6 The comparison results of the algorithm in this paper and other stroke-based deep learning algorithms are shown. The first column is the input grayscale image and user strokes, and the second, third, and fourth columns are the colorization results obtained by different algorithms.
[0078] In the "banana" example, the user expects the wall to be beige, the banana to be yellow, and the desktop to be red. The existing algorithm 1 can correctly color the banana, but the colors of the wall and background look extremely unnatural. In the existing algorithm 2, the colors of the banana and the wall are more natural, but an unpredictable blue appears on the desktop.
[0079] In the "flower" example, the user expects the flower to be colored light yellow and the leaves to be colored green; the existing algorithm 1 achieves a relatively natural colorization result, but an unnatural green appears on the flower. The result of the existing algorithm 2 shows an unexpected pink color on the flower.
[0080] In the "orange" example, the user expects the background to be beige, and the three oranges are colored light yellow, dark green, and light green respectively. The colorization effect of the existing algorithm 1 is generally good, but the colorization of the background is limited to the upper half, and the lower half is not colored. The results of the existing algorithm 2 again show unexpected blue.
[0081] 3.3. Comparison of existing deep learning algorithms without interaction:
[0082] Figure 7The comparison results of the algorithm in this paper and other fully automatic image colorization algorithms based on deep learning are shown. For example, in the "cookie" example, the image color generated by the existing algorithm 1 is not saturated and the desktop has an unreasonable yellow color. The color of the result automatically generated by the existing algorithm 1 is still not saturated and the overall color is unnatural. The colorization result generated by the algorithm in this embodiment has a natural visual effect and bright colors.
[0083] From the results, the colors generated by the automatic algorithm are unsaturated and the colorization results have incorrect color propagation, while the colorization results achieved by the algorithm of this embodiment have vivid colors and clear boundaries.
[0084] In addition to comparing the visual effects of various colorization algorithms with the algorithm in this paper, this embodiment also makes a quantitative analysis of the colorization results of various algorithms. Figure 8 As shown in the figure, the given color image is converted into a grayscale image as input, and the color image is used as the editing target to evaluate the quality of color images generated by different algorithms. Peak signal-to-noise ratio (PSNR) and structural measurement index (SSIM) are common indicators for evaluating the quality of image generation. PSNR is defined based on the mean square error, and SSIM is used to measure the similarity between images. Generally speaking, the larger the values of PSNR and SSIM, the better the quality of the generated image. Figure 8 The colorization results of the algorithm of this embodiment are compared with those of existing algorithms one, two, and three. The algorithm of this embodiment obtains the highest PSNR and SSIM values in all examples, indicating that the algorithm of this embodiment is more in line with the user's editing intention.
[0085] Run time:
[0086] Table 1 lists the running time of colorization of all examples in this embodiment (the semantic feature extraction and optimization time as preprocessing are not included). For all examples, the average running time of the algorithm is 0.34s. Therefore, the overall running efficiency of the algorithm is relatively high.
[0087] Table 1. Image colorization time performance statistics
[0088]
[0089] This embodiment introduces a novel image colorization method based on semantic similarity propagation. The method first extracts the semantic features of the input grayscale image and combines it with the brightness information of the image to construct a feature space and measure the similarity between pixels in this space. Then, an energy function based on semantic similarity propagation is designed, and the chromaticity information of the image is solved by optimizing this function. Finally, the brightness channel of the input image is combined with the solved chromaticity channel to generate the final colorized image. The algorithm effectively solves the common problems of complex user interaction, low computational efficiency and color overflow in the editing and propagation method, and achieves efficient, convenient and natural image colorization effect.
[0090] The above-mentioned embodiments only express the specific implementation of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.
Claims
1. An image colorization method based on semantic similarity propagation, characterized in that: The following steps are involved: Step 1, semantic feature extraction: combine the semantic features of the image with the brightness information, i.e., the Y channel, to form the feature space of the grayscale image; Step 2: Image colorization: Design an energy function based on similarity propagation in the feature space, and propagate the color of the local brush strokes, i.e., the U and V chromaticity channels, to other areas with similar semantics through optimization. Step 3: Merge the optimized U and V chromaticity channels with the original Y channel to achieve the conversion of the input image from grayscale to color.
2. The image colorization method based on semantic similarity propagation according to claim 1, characterized in that: The step 1 specifically comprises the following steps: Step 1.1, using the semantic soft segmentation method to extract the multi-dimensional semantic feature vector of the grayscale image pixel by pixel, and using the principal component analysis method to reduce the dimension of the multi-dimensional semantic feature vector; Step 1.2: Optimize the semantic features using the segmentation model. First, input the grayscale image into the segmentation model to obtain a set of masks, and perform deduplication on the masks. Then, in the three-dimensional semantic feature space, use the K-means algorithm to cluster the regions indicated by each mask, cluster the pixels in each region into two categories, and use the cluster center of the category with a larger number to replace the semantic features of all pixels in the region. Step 1.3: Combine the semantic features in step 1.1 and step 1.2 with the brightness information to form the features of the grayscale image. Finally, any pixel I in the input image i Each corresponds to a two-dimensional semantic feature vector and a brightness value Y i :
3. The image colorization method based on semantic similarity propagation according to claim 2, characterized in that: The step 2 is specifically as follows: Assuming that in an image with smoothly changing colors, the chromaticity value of any pixel can be represented by the chromaticity values of its neighboring pixels through weighted average; and assuming that pixels with similar features should receive similar colors, that is, chromaticity values U and V; then: image colorization is transformed into the following two energy function optimization problems: Both energy functions contain two terms. The first term is used to minimize the chromaticity value U of any pixel. i or V i and the chromaticity value U of the neighboring pixel p or V p ; The second item is used to constrain the chromaticity value of the user's stroke or Among them, N(i) represents the index of the neighboring pixels of the i-th pixel, It means that the pixel I in the input grayscale image i With Pixel I p similarity; The energy function is converted into a linear equations solution problem, and the constraints are incorporated into the solution process as hard constraints, which is converted into a linear equations solution as follows: (IW)U=0 (IW)V=0 Where I is an n×n identity matrix, (n represents the number of pixels in the image, W is an n×n matrix, W i , j Represents pixel I i With Pixel I j Similarity, U and V are n-dimensional column vectors to be solved.
4. The image colorization method based on semantic similarity propagation according to claim 3, characterized in that: Pixel I i With Pixel I p The similarity is defined as follows: Here, δ represents the standard deviation of the Gaussian kernel.
5. The image colorization method based on semantic similarity propagation according to claim 3 or 4, characterized in that: The interpolation method is used to accelerate the solution of linear equations. As a three-dimensional point, the entire image can be regarded as a three-dimensional point set. First, the three-dimensional space [0, 1] where the grayscale image is located is 3 The image is evenly divided into b×b×b grids. The stroke color is first propagated to the grid corners, and then the color of the corners is transferred to the image pixels through trilinear interpolation.
6. The image colorization method based on semantic similarity propagation according to claim 5, characterized in that: Also includes: For each corner point, its neighborhood is defined as the six corner points directly connected to it. Some known corner points are used as constraints. If there are user strokes in the grid associated with a corner point, the average chromaticity of these strokes is used as the chromaticity value of the corner point; otherwise, the chromaticity value of the corner point is unknown and needs to be obtained through energy optimization.
