Image processing method, image processing device, terminal and readable storage medium
By performing size compression and color space conversion on the image, and using clustering calculations with different weights, the result pixels are filtered to draw color watermarks, the problem of inaccurate image theme color extraction in the prior art is solved, and the image display effect is improved.
Patent Information
- Application Number
- CN202210369870.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-08
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2042-04-08
AI Technical Summary
The prior art is difficult to accurately extract the subject color of an image in image processing, resulting in the color watermark not conforming to the perception of the human eye and affecting the image display effect.
By performing size compression and color space conversion on the original image, clustering calculations are performed using different weights corresponding to the R channel, G channel, and B channel respectively, the result pixels are selected, and the color watermark is drawn in the original image.
It improves the accuracy of color watermarks, makes them more in line with the perception of the human eye, and improves the image display effect.
Smart Images

Figure CN114723837B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of image processing, and in particular to an image processing method, an image processing device, a terminal and a non-volatile computer-readable storage medium. Background Art
[0002] Image theme colors are the colors extracted from an image that best represent the clustered pixel tones of the image. In pages where images occupy a large proportion, image theme colors can play a good visual effect with images, giving people a sense of harmony and consistency. Using theme colors as a color palette (formed by a combination of multiple main colors) and drawing them inside or around an image to form a color watermark can highlight the beauty of the picture. Summary of the invention
[0003] Embodiments of the present application provide an image processing method, an image processing device, a terminal, and a computer-readable storage medium.
[0004] The image processing method of the embodiment of the present application includes: compressing the size of the original image and converting the color space to obtain an intermediate image whose color space is RGB space, wherein the pixel values of the pixels in the intermediate image all include a first channel value corresponding to the R channel, a second channel value corresponding to the G channel, and a third channel value corresponding to the B channel; performing clustering calculation on the intermediate image according to the pixel values of all the pixels of the intermediate image, a first weight, a second weight, and a third weight to obtain a plurality of clustered pixels and clusters corresponding to the plurality of clustered pixels, wherein the first weight, the second weight, and the third weight correspond to the R channel, the G channel, and the B channel, respectively, and the first weight, the second weight, and the third weight are different; selecting a preset number of clusters from the plurality of clusters, and using the clustered pixels corresponding to the selected clusters as result pixels, wherein the number of pixels in the selected clusters is greater than the number of pixels in the unselected clusters; and drawing a color watermark in the original image according to the result pixels to obtain a target image.
[0005] The image processing device of the embodiment of the present application includes a first processing module, an acquisition module, a selection module and a second processing module. The first processing module is used to perform size compression and color space conversion on the original image to obtain an intermediate image whose color space is RGB space, wherein the pixel values of the pixels in the RGB space all include a first channel value corresponding to the R channel, a second channel value corresponding to the G channel and a third channel value corresponding to the B channel; the acquisition module is used to perform clustering calculation on the intermediate image according to the pixel values of all pixels of the intermediate image, a first weight, a second weight and a third weight to obtain a plurality of clustered pixels and clusters corresponding to the plurality of clustered pixels, wherein the first weight, the second weight and the third weight correspond to the R channel, the G channel and the B channel respectively, and the first weight, the second weight and the third weight are different; the selection module is used to select a preset number of clusters from the plurality of clusters, and use the clustered pixels corresponding to the selected clusters as result pixels, wherein the number of pixels in the selected clusters is greater than the number of pixels in the unselected clusters; and the second processing module is used to draw a color watermark in the original image according to the result pixels to obtain a target image.
[0006] The terminal of the embodiment of the present application includes one or more processors, a memory and one or more programs, wherein one or more of the programs are stored in the memory and executed by one or more of the processors, and the programs include a method for executing an image processing method. The image processing method includes: performing size compression and color space conversion on an original image to obtain an intermediate image whose color space is an RGB space, wherein the pixel values of the pixels in the intermediate image all include a first channel value corresponding to an R channel, a second channel value corresponding to a G channel, and a third channel value corresponding to a B channel; performing clustering calculation on the intermediate image according to the pixel values of all the pixels in the intermediate image, a first weight, a second weight, and a third weight to obtain a plurality of clustered pixels and clusters corresponding to the plurality of clustered pixels, wherein the first weight, the second weight, and the third weight correspond to the R channel, the G channel, and the B channel, respectively, and the first weight, the second weight, and the third weight are different; selecting a preset number of clusters from the plurality of clusters, and using the clustered pixels corresponding to the selected clusters as result pixels, wherein the number of pixel points in the selected clusters is greater than the number of pixel points in the unselected clusters; and drawing a color watermark in the original image according to the result pixels to obtain a target image.
[0007] The non-volatile computer-readable storage medium of the embodiment of the present application includes a computer program. When the computer program is executed by one or more processors, the processors execute the following image processing method: compressing the size of the original image and converting the color space to obtain an intermediate image whose color space is RGB space, wherein the pixel values of the pixels in the intermediate image all include a first channel value corresponding to the R channel, a second channel value corresponding to the G channel, and a third channel value corresponding to the B channel; performing clustering calculation on the intermediate image according to the pixel values of all pixels of the intermediate image, a first weight, a second weight, and a third weight to obtain a plurality of clustered pixels and clusters corresponding to the plurality of clustered pixels, wherein the first weight, the second weight, and the third weight correspond to the R channel, the G channel, and the B channel, respectively; selecting a preset number of clusters from the plurality of clusters, and using the clustered pixels corresponding to the selected clusters as result pixels, wherein the number of pixels in the selected clusters is greater than the number of pixels in the unselected clusters; and drawing a color watermark in the original image according to the result pixels to obtain a target image.
[0008] The image processing method, image processing device, terminal and non-volatile computer-readable storage medium of the present application, after obtaining an intermediate image by size compression and color space conversion of the original image, cluster calculation is performed on the intermediate image according to the first weight, second weight and third weight corresponding to the R channel, G channel and B channel respectively, so as to obtain a plurality of clustered pixels, and then the result pixels are screened out from the plurality of clustered pixels, and a color watermark is drawn in the original image according to the result pixels. Since the present application performs cluster calculation on the intermediate image according to the first weight, second weight and third weight corresponding to the R channel, G channel and B channel respectively, and the first weight, the second weight and the third weight are different, compared with using the same weight for different color channels when performing cluster calculation, the color selection of the obtained clustered pixels is more accurate, so that the color watermark can be more in line with the actual perception of the human eye and improve the image display effect.
[0009] Additional aspects and advantages of the embodiments of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0011] Figure 1 is a flowchart of an image processing method of certain embodiments of the present application;
[0012] Figure 2is a schematic diagram of the structure of an image processing device in some embodiments of the present application;
[0013] Figure 3 is a schematic diagram of the structure of a terminal in some implementation modes of the present application;
[0014] Figures 4 to 8 is a flowchart of an image processing method of certain embodiments of the present application;
[0015] Fig. 9 It is a schematic diagram of the principle of clustering calculation in the image processing method of certain embodiments of the present application;
[0016] Figure 10 to Figure 11 is a flowchart of an image processing method of certain embodiments of the present application;
[0017] Fig.12 is a schematic diagram of the principle of sorting multiple clusters in the image processing method of certain embodiments of the present application;
[0018] Fig.13 is a flowchart of an image processing method of certain embodiments of the present application;
[0019] Fig.14 is a schematic diagram of a target image of certain embodiments of the present application;
[0020] Figures 15 to 18 is a flowchart of an image processing method of certain embodiments of the present application;
[0021] Fig.19 It is a connection diagram of a non-volatile computer-readable storage medium and a processor in certain embodiments of the present application. DETAILED DESCRIPTION
[0022] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals represent the same or similar elements or elements having the same or similar functions from beginning to end. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the embodiments of the present application, and cannot be understood as limiting the embodiments of the present application.
[0023] See also Figure 1 , the embodiment of the present application provides an image processing method. The image processing method includes:
[0024] 01: compress the original image in size and convert its color space to obtain an intermediate image whose color space is RGB space, wherein the pixel values of the pixels in the intermediate image include the first channel value corresponding to the R channel, the second channel value corresponding to the G channel, and the third channel value corresponding to the B channel;
[0025] 02: performing clustering calculation on the intermediate image according to the pixel values of all pixels of the intermediate image, the first weight, the second weight and the third weight to obtain a plurality of clustered pixels and clusters corresponding to the plurality of clustered pixels, wherein the first weight, the second weight and the third weight correspond to the R channel, the G channel and the B channel respectively, and the first weight, the second weight and the third weight are different;
[0026] 03: Select a preset number of clusters from multiple clusters, and use the clustered pixels corresponding to the selected clusters as result pixels, wherein the number of pixel points in the selected clusters is greater than the number of pixel points in the unselected clusters;
[0027] 04: Draw a color watermark in the original image according to the result pixels to obtain the target image.
[0028] See also Figure 2 , the embodiment of the present application also provides an image processing device 100. The image processing device 100 includes a first processing module 10, an acquisition module 20, a selection module 30 and a second processing module 40. The first processing module 10 is used to execute the method in 01, that is, the first processing module 10 is used to compress the size and convert the color space of the original image to obtain an intermediate image whose color space is RGB space, wherein the pixel values of the pixels in the intermediate image all include a first channel value corresponding to the R channel, a second channel value corresponding to the G channel and a third channel value corresponding to the B channel. The acquisition module 20 is used to execute the method in 02, that is, the acquisition module 20 is used to perform clustering calculation on the intermediate image according to the pixel values of all pixels of the intermediate image, the first weight, the second weight and the third weight to obtain a plurality of clustered pixels and clusters corresponding to the plurality of clustered pixels, wherein the first weight, the second weight and the third weight correspond to the R channel, the G channel and the B channel respectively, and the first weight, the second weight and the third weight are different. The selection module 30 is used to execute the method in 03, that is, the selection module 30 is used to select a preset number of clusters from multiple clusters, and use the clustered pixels corresponding to the selected clusters as result pixels, wherein the number of pixel points in the selected clusters is greater than the number of pixel points in the unselected clusters. The second processing module 40 is used to execute the method in 04, that is, the second processing module 40 is used to draw a color watermark in the original image according to the result pixels to obtain a target image.
[0029] See also Figure 3The embodiment of the present application also provides a terminal 1000. The terminal 1000 includes one or more processors 200, a memory 300, and one or more programs. Among them, the one or more programs are stored in the memory 300 and executed by the one or more processors 200, and the program includes instructions for executing the image processing method of the embodiment of the present application. That is to say, the processor 200 can implement the methods in 01, 02, 03 and 04. That is, the processor 200 is used to: perform size compression and color space conversion on the original image to obtain an intermediate image whose color space is an RGB space, wherein the pixel values of the pixels in the RGB space include a first channel value corresponding to the R channel, a second channel value corresponding to the G channel, and a third channel value corresponding to the B channel; perform clustering calculation on the intermediate image according to the pixel values, the first weight, the second weight, and the third weight of all pixels of the intermediate image to obtain a plurality of clustered pixels and clusters corresponding to the plurality of clustered pixels, wherein the first weight, the second weight, and the third weight correspond to the R channel, the G channel, and the B channel, respectively, and the first weight, the second weight, and the third weight are different; select a preset number of clusters from the plurality of clusters, and use the clustered pixels corresponding to the selected clusters as result pixels, wherein the number of pixel points in the selected clusters is greater than the number of pixel points in the unselected clusters; and draw a color watermark in the original image according to the result pixels to obtain a target image.
[0030] The terminal 1000 may include but is not limited to electronic devices such as a mobile phone, a laptop computer, a tablet computer, a smart watch or a computer. The image processing device 100 may be an integration of functional modules arranged in the terminal 1000. This application only takes the case where the terminal 1000 is a mobile phone as an example for explanation. The case where the terminal 1000 is other types of electronic devices is similar to the case where the terminal 1000 is a mobile phone, and will not be described in detail.
[0031] Cluster analysis or cluster calculation is to use some methods or means to cluster data sets into different categories, or called: clusters. Each unit within the cluster is similar, but clusters are not similar. In an embodiment of the present application, cluster calculation is performed on the intermediate image, and multiple pixels are divided into multiple different clusters according to the color differences of multiple pixels in the intermediate image. The colors of the pixels in each cluster are similar, and the colors of the pixels in different clusters are quite different. The color of the cluster pixel corresponding to each cluster can represent the color of the pixels in the cluster. Since the human eye has different perception capabilities of different colors, if the same weights are used for the three channels of R, G, and B to calculate the color differences between different pixels during the cluster calculation process, the color selection of the cluster pixels obtained after the cluster calculation is completed does not conform to the human eye's perception of color.
[0032] The image processing method, image processing device 100 and terminal 1000 of the present application, after obtaining an intermediate image by size compression and color space conversion of the original image, cluster calculation is performed on the intermediate image according to the first weight, second weight and third weight corresponding to the R channel, G channel and B channel respectively, to obtain a plurality of clustered pixels, and then the result pixels are screened out from the plurality of clustered pixels, and a color watermark is drawn in the original image according to the result pixels, thereby obtaining a target image. Since the present application performs cluster calculation on the intermediate image according to the first weight, second weight and third weight corresponding to the R channel, G channel and B channel respectively, and the first weight, second weight and third weight are different, compared with using the same weight for different color channels when performing cluster calculation, the color selection of the obtained clustered pixels is more accurate and in line with the actual perception of the human eye, so that the color watermark can be more in line with the actual perception of the human eye, so as to improve the image effect of the final target image.
[0033] It should be noted that the image processing method in the present application is mainly used in the process of real-time shooting. In the process of real-time shooting, the image data output by the image signal processor (Image Single Processor, ISP) is usually YUV data, that is, the original image obtained is an image with a YUV color space.
[0034] After acquiring the original image, the processor 200 (or the first processing module 10) performs size compression and color space conversion on the original image. Figure 4 In some embodiments, the original image is compressed and the color space is converted to obtain an intermediate image whose color space is RGB space, including:
[0035] 011: performing interval sampling of a preset multiple on the original image to obtain the original image after size compression; and
[0036] 012: Perform color space conversion on the original image after size compression to obtain an intermediate image whose color space is RGB space.
[0037] Please combine Figure 2 and Figure 3 In some embodiments, the first processing module 10 and the processor 200 are further used to execute the methods in 011 and 012. That is, the first processing module 10 and the processor 200 are further used to perform interval sampling of the original image at a preset multiple to obtain the original image after size compression; and perform color space conversion on the original image after size compression to obtain an intermediate image whose color space is RGB space.
[0038] After the original image is acquired, the original image is sampled at intervals of a preset multiple to obtain the original image after size compression. For example, in some embodiments, the original image can be sampled at intervals of a preset multiple by using a neighbor interpolation method. The preset multiple can be set by the manufacturer before the terminal 1000 (or the image processing device 100) leaves the factory, or it can be set by the user according to his own needs. For example, the preset multiple can be 16 times; of course, the preset multiple can also be other values, which are not limited here. Since the colors of adjacent points of the image are relatively close, the original image is sampled at intervals to obtain the original image after size compression and then perform subsequent processing. Compared with directly performing subsequent processing on the original size image, it can reduce the data to be processed without affecting the theme color of the image, thereby accurately reducing the power of the terminal 1000 (or the image processing device 100) and improving the image processing speed.
[0039] After obtaining the size-compressed original image, the size-compressed original image is converted into a color space to obtain an intermediate image whose color space is an RGB space. In some embodiments, when the color space of the original image is a YUV space, the size-compressed original image can be converted into a color space using the BT601 conversion specification, and the conversion formula is as follows:
[0040]
[0041] It should be noted that the pixel value of each pixel in the intermediate image includes a first channel value corresponding to the R channel, a second channel value corresponding to the G channel, and a third channel value corresponding to the B channel. For example, the pixel value of pixel A in the intermediate image is (187, 11, 32), which means that the first channel value of pixel A corresponding to the R channel is 187, the second channel value corresponding to the G channel is 11, and the third channel value corresponding to the B channel is 32.
[0042] After obtaining the intermediate image, clustering calculation can be performed on the intermediate image according to the pixel values of all pixels of the intermediate image, the first weight, the second weight and the third weight to obtain multiple cluster pixels and multiple clusters corresponding to the distance center. The pixel value of each cluster pixel also includes a first channel value corresponding to the R channel, a second channel value corresponding to the G channel and a third channel value corresponding to the B channel, and the first weight, the second weight and the third weight are different. Each cluster corresponds to a cluster pixel, and each cluster includes multiple pixels, and the color difference between all pixels in the same cluster and the cluster pixel corresponding to the cluster is small. That is, the color of the cluster pixel can represent the color of all pixels in the corresponding cluster.
[0043] Specifically, see Figure 5In some embodiments, clustering calculation is performed on the intermediate image according to the pixel values of all pixels of the intermediate image, the first weight, the second weight, and the third weight to obtain a plurality of clustered pixels and a plurality of clusters corresponding to the distance centers, including:
[0044] 021: Select multiple pixels in the intermediate image as initial pixels;
[0045] 022: Update the pixel value of the initial pixel according to the pixel value of each pixel in the intermediate image, the pixel values of all the initial pixels, the first weight, the second weight and the third weight, use the updated initial pixel as the clustering pixel, and obtain the cluster corresponding to the clustering pixel.
[0046] Please combine Figure 2 and Figure 3 In some embodiments, the acquisition module 20 and the processor 200 are further used to execute the methods in 021 and 022. That is, the acquisition module 20 and the processor 200 are further used to execute: selecting multiple pixels in the intermediate image as initial pixels; and updating the pixel values of the initial pixels according to the pixel value of each pixel in the intermediate image, the pixel values of all initial pixels, the first weight, the second weight, and the third weight, using the updated initial pixels as cluster pixels, and acquiring clusters corresponding to the cluster pixels.
[0047] After obtaining the intermediate image, in some embodiments, multiple pixels are randomly selected in the intermediate image as initial pixels, and the pixel values of the initial pixels are the same as the pixel values of the corresponding pixels. For example, assuming that the pixel value of pixel A in the intermediate image is (187, 11, 32), pixel A is selected as the initial pixel Z1, and the pixel value of the initial pixel Z1 is (187, 11, 32).
[0048] After acquiring a plurality of initial pixels, the processor 200 (or the acquisition module 20) updates the pixel values of the initial pixels, uses the updated initial pixels as cluster pixels, and acquires clusters corresponding to the cluster pixels. Figure 6 In some embodiments, the pixel value of the initial pixel is updated according to the pixel value of each pixel in the intermediate image, the pixel values of all the initial pixels, the first weight, the second weight, and the third weight, the updated initial pixel is used as the clustering pixel, and the cluster corresponding to the clustering pixel is obtained, including:
[0049] 0221 (step 1): traverse all pixel points in the intermediate image and execute: calculate multiple color difference values between the pixel point and different initial pixels according to the pixel value of the pixel point, the pixel values of all initial pixels, the first weight, the second weight and the third weight;
[0050] 0222 (step 2): Divide each pixel into a cluster corresponding to the initial pixel corresponding to the minimum color difference value; and
[0051] 0223 (Step 3): The average of the pixel values of all pixels in each cluster is used as the pixel value of the cluster pixel corresponding to the cluster. If the color difference between the cluster pixel and the corresponding initial pixel is greater than the preset difference value, the pixel value of the corresponding initial pixel is updated with the pixel value of the cluster pixel, and then steps 1 to 3 are repeated using the updated initial pixel until the color difference between the cluster pixel and the corresponding initial pixel is less than the preset difference value to complete the update.
[0052] Please combine Figure 2 and Figure 3 In some embodiments, the acquisition module 20 and the processor 200 are also used to execute the methods in 0221, 0222 and 0223. That is, the acquisition module 20 and the processor 200 are also used to execute: Step 1: traverse all pixels in the intermediate image and execute: according to the pixel value of the pixel, the pixel values of all initial pixels, the first weight, the second weight and the third weight, calculate multiple color difference values between the pixel and different initial pixels; Step 2: divide each pixel into the cluster corresponding to the initial pixel corresponding to the minimum color difference value; and Step 3: take the average of the pixel values of all pixels in each cluster as the pixel value of the cluster pixel corresponding to the cluster, if the color difference value between the cluster pixel and the corresponding initial pixel is greater than the preset difference value, then use the pixel value of the cluster pixel to update the pixel value of the corresponding initial pixel, and then use the updated initial pixel to repeat steps 1 to 3 until the color difference value between the cluster pixel and the corresponding initial pixel is less than the preset difference value to complete the update.
[0053] After acquiring multiple initial pixels, the processor 200 (or acquisition module 20) executes step 1, that is, the processor 200 (or acquisition module 20) traverses all pixel points in the intermediate image and executes: according to the pixel value of the pixel point, the pixel values of all initial pixels, the first weight, the second weight and the third weight, calculates multiple color difference values between the pixel point and different initial pixels.
[0054] For example, in some embodiments, the processor 200 (or the acquisition module 20) first randomly extracts a pixel point in the intermediate image, and selects an initial pixel from multiple initial pixels, and calculates the color difference value between the pixel point and the initial pixel according to the pixel value of the pixel point, the pixel value of the initial pixel, the first weight, the second weight and the third weight. Then another initial pixel is selected from the multiple initial pixels, and the above steps are repeated to calculate the color difference value between the pixel point and the other initial pixel until all the initial pixels are selected, so that the color difference value between the pixel point and all the initial pixels is obtained. Subsequently, another pixel point is extracted from the intermediate image, and the above steps are repeated to calculate the color difference value between the other pixel point and all the initial pixels respectively, until all the pixels of the intermediate image are extracted, so that the color difference value between each pixel point in the intermediate image and different initial pixels is obtained.
[0055] Of course, in some embodiments, the processor 200 (or the acquisition module 20) may first extract an initial pixel from multiple initial pixels, calculate the color difference between each pixel in the intermediate image and the initial pixel, and then extract another initial pixel, calculate the color difference between each pixel in the intermediate image and another initial pixel, until all initial pixels are extracted, in this way, the color difference value between each pixel in the intermediate image and different initial pixels is obtained, which is not limited here.
[0056] Take the calculation of the color difference between an initial pixel and a pixel point as an example. For details, please refer to Figure 7 In some embodiments, the color difference value between the pixel point and the initial pixel is calculated according to the pixel value of the pixel point, the pixel value of the initial pixel, the first weight, the second weight, and the third weight, including:
[0057] 02211: Calculate the color difference value between the pixel point and the initial pixel based on the difference between the first channel value in the pixel value and the initial pixel, the difference between the second channel value in the pixel value and the initial pixel, the difference between the third channel value in the pixel value and the initial pixel, the first weight, the second weight and the third weight.
[0058] Please combine Figure 2 and Figure 3In some embodiments, the acquisition module 20 and the processor 200 are further used to execute the method in 02211. That is, the acquisition module 20 and the processor 200 are further used to calculate the color difference value between the pixel point and the initial pixel according to the difference between the first channel value in the pixel value of the pixel point and the initial pixel, the difference between the second channel value in the pixel value of the pixel point and the initial pixel, the difference between the third channel value in the pixel value of the pixel point and the initial pixel, the first weight, the second weight and the third weight.
[0059] Specifically, in some embodiments, the color difference value dist(A1, Z1) between the pixel point A1 and the initial pixel Z1 can be calculated by the formula: Calculated. Wherein, k1 represents the first weight, k2 represents the second weight, k3 represents the third weight, R1 represents the first channel value of the pixel point, R2 represents the first channel value of the initial pixel, (R1-R2) represents the difference between the first channel value of the pixel point and the pixel value of the initial pixel, G1 represents the second channel value of the pixel point, G2 represents the second channel value of the initial pixel, (G1-G2) represents the difference between the second channel value of the pixel point and the pixel value of the initial pixel, B represents the third channel value of the pixel point, B2 represents the third channel value of the initial pixel, and (B1-B2) represents the difference between the third channel value of the pixel point and the pixel value of the initial pixel. Wherein, the first weight, the second weight and the third weight are not the same. Since the human eye has different perception capabilities for different colors, if the first channel value, the second channel value and the third channel value use the same weight to calculate the color difference value between the pixel point and the initial pixel, the obtained color difference value is different from the color difference value actually perceived by the human eye. Therefore, in the implementation manner of the present application, the first channel value, the second channel value and the third channel value respectively correspond to different weights to calculate the color difference value between the pixel point and the initial pixel. The color difference value obtained in this way is more in line with the color difference value actually perceived by the human eye, which is conducive to making the color selection of the subsequently acquired clustered pixels more accurate, thereby enabling the color watermark to be more in line with the actual perception of the human eye and improving the image display effect.
[0060] It should be noted that, in some embodiments, the first weight, the second weight, and the third weight may be pre-set in the terminal 1000 (or the image processing device 100) before leaving the factory. For example, the manufacturer of the terminal 1000 (or the image processing device 100) has carried out a large number of experiments and calculations to obtain the first weight, the second weight, and the third weight that best fit the actual perception of the human eye. Subsequently, the obtained first weight, the second weight, and the third weight are stored in the terminal 1000 (or the image processing device 100). In the process of calculating the color difference value between the pixel point and the initial pixel, the first weight, the second weight, and the third weight pre-stored in the terminal 1000 (or the image processing device 100) can be directly obtained.
[0061] In particular, in some embodiments, when calculating the color difference between two different pixels, the first weight, the second weight, and the third weight are determined by the pixel values of the two pixels. That is, the first weight, the second weight, and the third weight are not fixed values. For example, the first weight, the second weight, and the third weight when calculating the color difference value between the pixel point A1 and the initial pixel Z1 are different from the first weight, the second weight, and the third weight when calculating the color difference value between the pixel point A1 and the initial pixel Z2. For details, please refer to Figure 7 In some embodiments, the image processing method may further include:
[0062] 06: Determine the first weight, the second weight and the third weight according to the mean value of the first channel in the pixel value of the pixel point and the initial pixel and the preset mean value.
[0063] Please combine Figure 2 and Figure 3 In some embodiments, the acquisition module 20 and the processor 200 are also used to execute the method in 06. That is, the acquisition module 20 and the processor 200 are also used to determine the first weight, the second weight and the third weight according to the mean value between the first channel value in the pixel value of the pixel point and the initial pixel and the preset mean value.
[0064] In some embodiments, the average of the first channel values in the pixel values of the pixel point and the initial pixel is calculated. That is, the average of the values corresponding to the R channel in the pixel values of the pixel point and the initial pixel is calculated. For example, assuming that the pixel value of the pixel point is (R1, G1, B1) and the pixel value of the initial pixel is (R2, G2, B2), then the average of the first channel values in the pixel value of the pixel point and the initial pixel is = (R1+R2) / 2. Then, a first weight corresponding to the R channel, a second weight corresponding to the G channel, and a third weight corresponding to the B channel are determined according to the mean value and the preset mean value.
[0065] For example, see Figure 8 In some embodiments, the first weight, the second weight, and the third weight are determined according to the mean value between the first channel values in the pixel points and the pixel values of the clustered pixels and the preset mean value, including:
[0066] 061: If the average value of the first channel value in the pixel value of the pixel point and the initial pixel is less than the preset average value, determine that the second weight is greater than the first weight, and the third weight is greater than the first weight and less than the second weight;
[0067] 062: If the mean value between the first channel values in the pixel value of the pixel point and the initial pixel is greater than or equal to the preset mean value, it is determined that the second weight is greater than the third weight, and the first weight is greater than the third weight and less than the second weight.
[0068] Please combine Figure 2 and Figure 3 In some embodiments, the acquisition module 20 and the processor 200 are also used to execute the methods in 061 and 062. That is, the acquisition module 20 and the processor 200 are also used to determine that the second weight is greater than the first weight, and the third weight is greater than the first weight and less than the second weight if the average value between the first channel values in the pixel value of the pixel point and the initial pixel is less than the preset average value; and if the average value between the first channel values in the pixel value of the pixel point and the initial pixel is greater than or equal to the preset average value, determine that the second weight is greater than the third weight, and the first weight is greater than the third weight and less than the second weight.
[0069] After obtaining the mean of the first channel value in the pixel value of the pixel point and the initial pixel, compare the mean with the preset mean. If the mean between the first channel values in the pixel value of the pixel point and the initial pixel is less than the preset mean, determine that the second weight is greater than the first weight, and the third weight is greater than the first weight and less than the second weight; and if the mean between the first channel values in the pixel value of the pixel point and the initial pixel is greater than or equal to the preset mean, determine that the second weight is greater than the third weight, and the first weight is greater than the third weight and less than the second weight. Since the distribution of colors in the RGB space is not uniform, if the first channel value, the second channel value, and the third channel value use the same weight to calculate the color difference value between the pixel point and the initial pixel, the color difference obtained in this way is not the same as the color difference actually perceived by the human eye. Therefore, in this embodiment, since the mean value between the first channel values in the pixel values of the pixel point and the initial pixel is less than the preset mean value, that is, when the values corresponding to the R channel of the pixel point and the initial pixel are slightly different, the first weight corresponding to the R channel is < the third weight corresponding to the B channel is < the second weight corresponding to the G channel; when the mean value between the first channel values in the pixel values of the pixel point and the initial pixel is greater than or equal to the preset mean value, that is, when the values corresponding to the R channel of the pixel point and the initial pixel are significantly different, the third weight corresponding to the B channel is < the first weight corresponding to the R channel is < the second weight corresponding to the G channel, so that the obtained color difference can be close to the color difference actually perceived by the human eye.
[0070] In some embodiments, if the mean value between the first channel values in the pixel values of the pixel point and the initial pixel is less than the preset mean value, the ratio of the first weight, the second weight and the third weight is determined to be 2:4:3; if the mean value between the first channel values in the pixel values of the pixel point and the initial pixel is greater than or equal to the preset mean value, the ratio of the first weight, the second weight and the third weight is determined to be 3:4:2. For example, in some embodiments, the preset mean value may be 128. That is, if the mean value between the first channel values in the pixel values of the pixel point and the initial pixel is less than 128, the ratio of the first weight, the second weight and the third weight is determined to be 2:4:3; if the mean value between the first channel values in the pixel values of the pixel point and the initial pixel is greater than or equal to 128, the ratio of the first weight, the second weight and the third weight is determined to be 3:4:2, so that the obtained color difference can be close to the color difference actually perceived by the human eye.
[0071] It should be noted that, in some embodiments, when the mean value between the first channel values in the pixel values of the pixel point and the initial pixel is less than the preset mean value, it can be directly determined that the first weight is equal to 2, the second weight is equal to 4, and the third weight is equal to 3; when the mean value between the first channel values in the pixel values of the pixel point and the initial pixel is greater than or equal to the preset mean value, it can be directly determined that the first weight is equal to 3, the second weight is equal to 4, and the third weight is equal to 2, so that the obtained color difference can be close to the color difference actually perceived by the human eye.
[0072] For example, assuming that the mean value between the first channel values in the pixel value of the pixel point and the initial pixel is less than the preset mean value, the first weight is equal to 2, the second weight is equal to 4, and the third weight is equal to 3; the mean value between the first channel values in the pixel value of the pixel point and the clustered pixel is greater than or equal to the preset mean value, and the first weight is determined to be equal to 3, the second weight is equal to 4, and the third weight is equal to 2, and the preset mean value is 128. Calculate the color difference between the pixel value of pixel point A1 (R1, G1, B1) and the pixel value of initial pixel Z1 (R2, G2, B2). First, calculate the mean value of the first channel value in the pixel value of the pixel point and the initial pixel. in like is less than 128, then the color difference between pixel A1 and initial pixel Z1 is dist(A1, Z1) like is greater than or equal to 128, then the color difference between pixel A1 and initial pixel Z1 is dist(A1, Z1)
[0073] After obtaining the color difference values between each pixel point in the intermediate image and different initial pixels, the processor 200 (or the acquisition module 20) executes the method in step 2, that is, divides each pixel point into the cluster corresponding to the initial pixel with the smallest color difference value. For example, assume there are three initial pixels in total, the color difference value between pixel point A1 and initial pixel Z1 is dist(A1, Z1), the color difference value between pixel point A1 and initial pixel Z2 is dist(A1, Z2), the color difference value between pixel point A1 and initial pixel Z3 is dist(A1, Z3), and dist(A1, Z3) < dist(A1, Z1) < dist(A1, Z2), then pixel point A1 is divided into the cluster corresponding to initial pixel Z3.
[0074] After all pixel points in the intermediate image are divided into the corresponding clusters, the processor 200 (or the acquisition module 20) executes the method in step 2, that is, the processor 200 (or the acquisition module 20) executes taking the average value of the pixel values of all pixel points in each cluster as the pixel value of the cluster pixel corresponding to the cluster. If the color difference value between the cluster pixel and the corresponding initial pixel is greater than the preset difference value, then update the pixel value of the corresponding initial pixel with the pixel value of the cluster pixel, and repeat steps 1 to 3 with the updated initial pixel until the color difference value between the cluster pixel and the corresponding initial pixel is less than the preset difference value to complete the update.
[0075] Specifically, calculate the average value of the pixel values of all pixel points in each cluster, and take the average value of the pixel values of all pixel points in the cluster as the pixel value of the cluster pixel corresponding to the cluster. Since the pixel value of the cluster pixel corresponding to the cluster is equal to the average value of the pixel values of all pixel points in the cluster, the color of the cluster pixel can represent the colors of all pixel points in the corresponding cluster. For example, assume the first cluster includes three pixel points, the pixel value of pixel point A1 is (R1, G1, B1), the pixel value of pixel point A2 is (R2, G2, B2), and the pixel value of pixel point A3 is (R3, G3, B3), then the pixel value of the cluster pixel D1 corresponding to the first cluster is (R4, G4, B4), where R4 = (R1 + R2 + R3) / 3, G4 = (G1 + G2 + G3) / 3, B4 = (B1 + B2 + B3) / 3.
[0076] After obtaining the cluster pixels corresponding to the cluster, compare the color difference values of the cluster pixels corresponding to the same cluster and the initial pixels. If the color difference value between the two is less than the preset difference value, that is, the color difference between the cluster pixels and the initial pixels corresponding to the same cluster is small, indicating that the color difference between all pixels in the corresponding cluster and the color difference between the initial pixels is small, then it can be considered that the initial pixel at this time is the image theme color of the original image. At this time, there is no need to update the initial pixel, directly use the initial pixel as the cluster pixel, and directly use the cluster corresponding to the initial pixel at this time as the cluster corresponding to the cluster pixel; if the color difference value between the two is greater than the preset difference value, that is, the color difference between the cluster pixels and the initial pixels corresponding to the same cluster is large, indicating that the color difference between all pixels in the corresponding cluster and the color difference between the initial pixels is large, and the initial pixel at this time is not the best image theme color of the original image. Among them, the specific implementation method of calculating the color difference value between the cluster pixel and the initial pixel is the same as the specific method of calculating the color difference value between the pixel point and the initial pixel in the above text, which will not be repeated here. It is worth noting that when calculating the color difference value between the cluster pixel and the initial pixel, and the first weight, the second weight and the third weight are not fixed values, the values of the first weight, the second weight and the third weight are determined by the average of the first channel values in the pixel values of the cluster pixel and the initial pixel. The specific implementation method is the same as that described in the above embodiment and will not be repeated here.
[0077] In some embodiments, if the color difference between the cluster pixel and the corresponding initial pixel is greater than a preset difference value, the pixel value of the corresponding initial pixel is updated with the pixel value of the cluster pixel, and then the updated initial pixel is used to repeat steps 1 to 3 until the color difference between the cluster pixel and the corresponding initial pixel is less than the preset difference value to complete the update. At this time, the updated initial pixel is used as the cluster pixel, and the cluster corresponding to the initial pixel at this time is directly used as the cluster corresponding to the cluster pixel. Each cluster pixel obtained in this way has a small color difference with all the pixels in the corresponding cluster, so that the cluster pixel can represent the main color of the original image.
[0078] For example, see Fig. 9, assuming that there are five pixels in the intermediate image and the number of initial pixels is two. Among them, the pixel value of pixel A1 is (R1, G1, B1), the pixel value of pixel A2 is (R2, G2, B2), the pixel value of pixel A3 is (R3, G3, B3), the pixel value of pixel A4 is (R4, G4, B4), and the pixel value of pixel A5 is (R5, G5, B5). Selecting pixel A1 and pixel A2 as initial pixels, the pixel value of initial pixel Z1 is (R1, G1, B1), and the pixel value of initial pixel Z2 is (R2, G2, B2). According to the pixel value of each pixel and the pixel value of each initial pixel, the color difference value between each pixel and different initial pixels is calculated respectively, wherein the color difference value between pixel A1 and initial pixel Z1 is dist(A1, Z1)<the color difference value between pixel A1 and initial pixel Z2 is dist(A1, Z2); the color difference value between pixel A2 and initial pixel Z1 is dist(A2, Z1)>the color difference value between pixel A2 and initial pixel Z2 is dist(A2, Z2); the color difference value between pixel A3 and initial pixel Z1 is dist(A3, Z2); The color difference value dist(A3, Z1) between the initial pixel Z1 is < the color difference value dist(A3, Z2) between the pixel A3 and the initial pixel Z2; the color difference value dist(A4, Z1) between the pixel A4 and the initial pixel Z1 is < the color difference value dist(A4, Z2) between the pixel A4 and the initial pixel Z2; the color difference value dist(A5, Z1) between the pixel A5 and the initial pixel Z1 is > the color difference value dist(A5, Z2) between the pixel A5 and the initial pixel Z2. Therefore, the pixel A1, the pixel A3 and the pixel A4 are divided into the first cluster corresponding to the initial pixel Z1, and the pixel A2 and the pixel A5 are divided into the second cluster corresponding to the initial pixel Z2. Subsequently, the average of the pixel values of all the pixels in the first cluster is used as the pixel value of the cluster pixel D1 corresponding to the first cluster, and the average of the pixel values of all the pixels in the second cluster is used as the pixel value of the cluster pixel D2 corresponding to the second cluster. That is, the pixel value of cluster pixel D1 is ((R1+R3+R4) / 3, (G1+G3+G4) / 3, (B1+B3+B4) / 3), and the pixel value of cluster pixel D2 is ((R2+R5) / 2, (G2+G5) / 2, (B2+B5) / 2). The color difference value dist(D1, Z1) between cluster pixel D1 and initial pixel Z1 and the color difference value dist(D2, Z2) between cluster pixel D2 and initial pixel Z2 are calculated; if at least one of the color difference value dist(D1, Z1) between cluster pixel D1 and initial pixel Z1 and the color difference value dist(D2, Z2) between cluster pixel D2 and initial pixel Z2 is greater than the preset difference value, the pixel value of the initial pixel is updated with the pixel value of the cluster pixel.That is, the pixel value of the initial pixel Z1 is updated to ((R1+R3+R4) / 3, (G1+G3+G4) / 3, (B1+B3+B4) / 3), and the pixel value of the initial pixel Z2 is updated to ((R2+R5) / 2, (G2+G5) / 2, (B2+B5) / 2). Then, based on the updated pixel value of the initial pixel, the color difference value between each pixel point and different initial pixels is calculated again. Among them, the color difference value dist(A1, Z1) between the pixel point A1 and the initial pixel Z1 is < the color difference value dist(A1, Z2) between the pixel point A1 and the initial pixel Z2; the color difference value dist(A2, Z1) between the pixel point A2 and the initial pixel Z1 is < the color difference value dist(A2, Z2) between the pixel point A2 and the initial pixel Z2 is; the color difference value dist(A3, Z1) between the pixel point A3 and the initial pixel Z1 is < the color difference value dist(A3, Z2) between the pixel point A3 and the initial pixel Z2 is; the color difference value dist(A4, Z1) between the pixel point A4 and the initial pixel Z1 is > the color difference value dist(A4, Z2) between the pixel point A4 and the initial pixel Z2 is; the color difference value dist(A5, Z1) between the pixel point A5 and the initial pixel Z1 is > the color difference value dist(A5, Z2) between the pixel point A5 and the initial pixel Z2. Therefore, the new first cluster includes pixel A1, pixel A2 and pixel A3, and the new second cluster includes pixel A4 and pixel A5. Subsequently, the average of the pixel values of all the pixels in the new first cluster is used as the pixel value of the cluster pixel D1 corresponding to the first cluster, and the average of the pixel values of all the pixels in the new second cluster is used as the pixel value of the cluster pixel D2 corresponding to the second cluster. That is, the pixel value of cluster pixel D1 is updated to ((R1+R2+R3) / 3, (G1+G2+G3) / 3, (B1+B2+B3) / 3), and the pixel value of cluster pixel D2 is updated to ((R4+R5) / 2, (G4+G5) / 2, (B4+B5) / 2). According to the updated pixel value of the cluster pixel and the updated pixel value of the initial pixel, the color difference value between the cluster pixel and the corresponding initial pixel is calculated. That is, the color difference value dist(D1, Z1) between the cluster pixel D1 with pixel values of (R1+R2+R3) / 3, (G1+G2+G3) / 3, (B1+B2+B3) / 3) and the initial pixel Z1 with pixel values of ((R1+R3+R4) / 3, (G1+G3+G4) / 3, (B1+B3+B4) / 3) is calculated; and the color difference value dist(D2, Z2) between the cluster pixel D2 with pixel values of ((R4+R5) / 2, (G4+G5) / 2, (B4+B5) / 2) and the initial pixel Z2 with pixel values of ((R2+R5) / 2, (G2+G5) / 2, (B2+B5) / 2) is calculated.If at least one of the color difference value dist(D1, Z1) and the color difference value dist(D2, Z2) is greater than the preset difference value, then the pixel value of the initial pixel Z1 is updated to ((R1+R2+R3) / 3, (G1+G2+G3) / 3, (B1+B2+B3) / 3), and the pixel value of the initial pixel Z2 is updated to ((R4+R5) / 2, (G4+G5) / 2, (B4+B5) / 2), and the above steps are repeated until the color difference values between all cluster pixels and the corresponding initial pixels are less than the preset difference; if the color difference value dist(D1, Z1) is greater than the preset difference value, then the pixel value of the initial pixel Z1 is updated to ((R1+R2+R3) / 3, (G1+G2+G3) / 3, (B1+B2+B3) / 3), and the pixel value of the initial pixel Z2 is updated to ((R4+R5) / 2, (G4+G5) / 2, (B4+B5) / 2), and the above steps are repeated until the color difference values between all cluster pixels and the corresponding initial pixels are less than the preset difference; Z1) and the color difference value dist(D2, Z2) are not greater than the preset difference value, then the initial pixel Z1 with the pixel value of ((R1+R3+R4) / 3, (G1+G3+G4) / 3, (B1+B3+B4) / 3) can be determined as the first cluster pixel, and the first cluster corresponding to the initial pixel Z1 is used as the cluster corresponding to the first cluster pixel; the initial pixel Z2 with the pixel value of (R2+R5) / 2, (G2+G5) / 2, (B2+B5) / 2) is determined as the second cluster pixel, and the second cluster corresponding to the initial pixel Z2 is used as the cluster corresponding to the second cluster pixel.
[0079] It should be noted that, in some embodiments, if the color difference between the cluster pixel and the corresponding initial pixel is greater than the preset difference value, the corresponding initial pixel is updated with the pixel value of the cluster pixel and the above steps 1 to 3 are repeated until the number of repetitions exceeds the preset number. That is, when the number of repetitions of the methods in 0221, 0222 and 0223 exceeds the preset number, even if the color difference between the cluster pixel and the corresponding initial pixel is still greater than the preset difference value, it is no longer repeated, but the initial pixel obtained by the last update is directly used as the cluster pixel, and the cluster corresponding to the initial pixel obtained by the last update is directly used as the cluster pixel corresponding to the cluster pixel, so that the power consumption of the image processing device 100 or the terminal 1000 can be reduced, and the speed of image processing can be accelerated.
[0080] In some embodiments, a roulette wheel method may be used to select multiple pixels in the intermediate image as initial pixels. Fig.10 In some embodiments, selecting a plurality of pixels in the intermediate image as initial pixels includes:
[0081] 0211: First selection step: select a pixel point in the intermediate image as the initial pixel;
[0082] 0212: second selection step: calculating the color difference between each pixel and the initial pixel according to the pixel value of each pixel in the intermediate image, the pixel value of the initial pixel and the first weight, the second weight and the third weight, and selecting the pixel corresponding to the maximum color difference as the next initial pixel; and
[0083] 0213: Repeat the second selection step for the next initial center point until the number of initial pixels obtained is greater than the second preset number.
[0084] Please combine Figure 2 and Figure 3 In some embodiments, the acquisition module 20 and the processor 200 are also used to execute the methods in 0211, 0212 and 0213. That is, the acquisition module 20 and the processor 200 are also used to execute: a first selection step: selecting a pixel point in the intermediate image as an initial pixel; a second selection step: calculating the color difference value between each pixel point and the initial pixel according to the pixel value of each pixel point in the intermediate image, the pixel value of the initial pixel and the first weight, the second weight and the third weight, and selecting the pixel point corresponding to the maximum color difference value as the next initial pixel; and repeating the above second selection step for the next initial pixel until the number of the acquired initial pixels is greater than the second preset number.
[0085] For example, first, the processor 200 (or the acquisition module 20) performs a first selection step, that is, randomly selects a pixel point in the intermediate image as the initial pixel, so that the pixel value of the initial pixel is the same as the pixel value of the corresponding pixel point. Subsequently, the processor 200 (or the acquisition module 20) performs a second selection step, that is, according to the pixel value of each pixel point in the intermediate image, the pixel value of the initial pixel and the first weight, the second weight and the third weight, the color difference value between each pixel point and the initial pixel is calculated, and the pixel point corresponding to the maximum color difference value is selected as the next initial pixel. The second selection step is then repeated for the next initial pixel until the number of initial pixels obtained is greater than the second preset number, so that a plurality of initial pixels are obtained. Among them, the specific implementation method of calculating the color difference value between the pixel point and the initial pixel is the same as the specific implementation method of calculating the color difference between the pixel point and the initial pixel in the above embodiment, and will not be repeated here.
[0086] Since the pixel with the largest color difference with the current initial center point is used as the next initial pixel, the color difference of the multiple initial pixels selected in this way is relatively large. Compared with directly selecting multiple pixels as initial pixels from the intermediate image, the number of times the processor 200 (or acquisition module 20) repeatedly executes the above methods 0221, 0222 and 0223 can be reduced, thereby improving the speed of image processing.
[0087] After performing clustering calculation on the intermediate image to obtain multiple cluster pixels and clusters corresponding to the cluster pixels, a preset number of clusters are selected from the multiple clusters, and the cluster pixels corresponding to the selected clusters are used as result pixels, wherein the number of pixel points in the selected clusters is greater than the number of pixel points in the unselected clusters.
[0088] Specifically, see Fig.11 In some embodiments, a preset number of clusters are selected from a plurality of clusters, and cluster pixels corresponding to the selected clusters are used as result pixels, wherein the number of pixel points in the selected clusters is greater than the number of pixel points in the unselected clusters, including:
[0089] 031: Sort all clusters by the number of pixels in each cluster, and select cluster pixels corresponding to clusters arranged before a first preset value as result pixels.
[0090] Please combine Figure 2 and Figure 3 In some embodiments, the selection module 30 and the processor 200 are also used to execute the method in 031. That is, the selection module 30 and the processor 200 are also used to sort all clusters according to the number of pixels in each cluster, and select the cluster pixels corresponding to the clusters arranged before the first preset value as the result pixels.
[0091] For example, Fig.12 As shown, assuming that the first preset value is 5, that is, the number of result pixels is 5. After clustering calculation of the intermediate image, 8 clusters are obtained, wherein there are 20 pixels in the first cluster, 50 pixels in the second cluster, 30 pixels in the third cluster, 80 pixels in the fourth cluster, 90 pixels in the fifth cluster, 66 pixels in the sixth cluster, 88 pixels in the seventh cluster, and 12 pixels in the eighth cluster. All clusters are sorted by the number of pixels in each cluster, and the order can be obtained as follows: the fifth cluster, the seventh cluster, the fourth cluster, the sixth cluster, the second cluster, the third cluster, the first cluster, and the eighth cluster. Since the first preset value is 5, the cluster pixels corresponding to the first 5 clusters are selected as the result pixels, that is, the cluster pixels Z5 corresponding to the fifth cluster, the cluster pixels Z7 corresponding to the seventh cluster, the cluster pixels Z4 corresponding to the fourth cluster, the cluster pixels Z6 corresponding to the sixth cluster, and the cluster pixels Z2 corresponding to the second cluster are selected as the result pixels, and the pixel values of the result pixels are the same as the pixel values of the corresponding cluster pixels.
[0092] It should be noted that if there are two clusters with exactly the same number of pixels, one of the clusters can be arbitrarily selected to be arranged in front of the other cluster. In particular, assuming that the first preset value is N, if arranged in the Nth cluster and the N+1th cluster, the cluster pixel corresponding to the Nth cluster can be selected as the result pixel, or the cluster pixel corresponding to the N+1th cluster can be selected as the result pixel, and there is no limitation here.
[0093] In addition, in some embodiments, the number of clustered pixels is greater than the number of result pixels. Since the updated initial pixels are used as clustered pixels, the number of clustered pixels is the same as the number of initial pixels. Therefore, the number of initial pixels needs to be greater than the number of result pixels, that is, the second preset number is greater than the first preset number. Since the color watermark is drawn only according to the result pixels in the subsequent processing process, that is, only the result pixels are used as the theme color of the original image, and in the process of clustering calculation, more clustered pixels than result pixels are obtained. Compared with only obtaining the same number of clustered pixels as the result pixels, it can avoid the situation that the picture is rich in color but the number of categories (i.e., the number of clusters) is small, resulting in the color of multiple categories being forcibly divided into one color, thereby helping to improve the image effect of the target image finally obtained. It should be noted that the first preset number and the second preset number can be set by default before the terminal 1000 (or the image processing device 100) leaves the factory, or can be set by the user according to actual needs, and there is no limitation here.
[0094] After obtaining the result pixels, a color watermark can be drawn in the original image according to the result pixels to obtain the target image. Fig.13 In some embodiments, the color space of the original image is a YUV color space, and a color watermark is drawn in the original image according to the result pixel to obtain a target image, including:
[0095] 0421: convert the result pixel into a YUV color space to obtain a YUV value corresponding to the result pixel; and
[0096] 0422: Replace the YUV value of the pixel at the preset position of the original image with the YUV value corresponding to the result pixel to obtain the target image containing the color watermark.
[0097] Please combine Figure 2 and Figure 3 In some embodiments, the second processing module 40 and the processor 200 are further used to execute the methods in 0421 and 0422. That is, the second processing module 40 and the processor 200 are further used to convert the result pixel into a YUV color space to obtain a YUV value corresponding to the result pixel; and replace the YUV value of the pixel point at the preset position of the original image with the YUV value corresponding to the result pixel to obtain a target image containing a color watermark.
[0098] After obtaining the result pixel, since the result pixel is a pixel located in the RGB color space, that is, the pixel value of the result pixel includes the first channel value corresponding to the R channel, the second channel value corresponding to the G channel, and the third channel value corresponding to the B channel, and the color space of the original image is the YUV color space, the result pixel is first converted to the YUV color space according to the BT601 standard. The conversion formula is as follows:
[0099]
[0100] After conversion, the YUV value corresponding to the result pixel can be obtained. Fig.14 As shown, by replacing the YUV value of the pixel point at the preset position of the original image with the YUV value corresponding to the result pixel, a color watermark can be drawn at the preset position of the original image, thereby obtaining a target image containing a color watermark. It should be noted that the preset position for drawing the color watermark can be around the original image or inside the original image, which is not limited here.
[0101] See also Fig.15 In some embodiments, the image processing method further comprises:
[0102] 05: Perform saturation processing on the result pixel to obtain the corresponding processed result pixel;
[0103] At this point, a color watermark is drawn in the original image according to the result pixels to obtain the target image, including:
[0104] 041: Draw a color watermark in the original image according to the processed result pixels corresponding to the result pixels to obtain the target image.
[0105] Please combine Figure 2 and Figure 3 In some embodiments, the image processing device 100 further includes a third processing module 50, and the third processing module 50 and the processor 200 are both used to execute the method in 05. That is, the third processing module 50 and the processor 200 are both used to perform saturation processing on the result pixel to obtain the corresponding processed result pixel. The second processing module 40 and the processor 200 are both used to execute the method in 041. That is, the second processing module 40 and the processor 200 are both used to draw a color watermark in the original image according to the processed result pixel corresponding to the result pixel to obtain the target image.
[0106] In some embodiments, after obtaining the result pixel, each result pixel may be subjected to saturation processing to obtain the corresponding processed result pixel. Since the human eye is more sensitive to bright colors, the result pixel is subjected to saturation processing to obtain the processed result pixel, and a color watermark is drawn based on the processed result pixel. Compared with drawing a color watermark directly based on the average color of each color category obtained by a traditional clustering algorithm, the color watermark finally obtained can be more consistent with the actual human eye perception, thereby further improving the image effect of the target image finally obtained.
[0107] For the sake of convenience, the following takes the saturation processing of a result pixel as an example. Fig.16 In some embodiments, the pixel value of the result pixel includes a first channel value corresponding to the R channel, a second channel value corresponding to the G channel, and a third channel value corresponding to the B channel, and performing saturation processing on the result pixel to obtain the corresponding processed result pixel includes:
[0108] 051: If the maximum value and the minimum value among the first channel value, the second channel value and the third channel value of the result pixel are the same, the result pixel is directly used as the corresponding processed result pixel;
[0109] 052: If the maximum value and the minimum value among the first channel value, the second channel value and the third channel value of the result pixel are different, saturation enhancement is performed according to the degree parameter to obtain the corresponding processed result pixel.
[0110] Please combine Figure 2 and Figure 3 In some embodiments, the third processing module 50 and the processor 200 are further used to execute the methods in 051 and 052. That is, the third processing module 50 and the processor 200 are further used to directly use the result pixel as the corresponding processed result pixel if the maximum value and the minimum value among the first channel value, the second channel value and the third channel value of the result pixel are the same; and if the maximum value and the minimum value among the first channel value, the second channel value and the third channel value of the result pixel are different, perform saturation enhancement according to the degree parameter to obtain the corresponding processed result pixel.
[0111] The pixel value of the result pixel is the same as the pixel value of the corresponding cluster pixel, that is, the pixel value of the result pixel also includes the first channel value corresponding to the R channel, the second channel value corresponding to the G channel, and the third channel value corresponding to the B channel. If the maximum value and the minimum value of the first channel value, the second channel value, and the third channel value of the result pixel are the same, it means that the result pixel is a gray point, and there is no need to continue to operate on it. At this time, the result pixel can be directly used as the corresponding processed result pixel, that is, the pixel value of the processed result pixel is equal to the pixel value of the result pixel. If the maximum value and the minimum value of the first channel value, the second channel value, and the third channel value of the result pixel are not the same, it means that the result pixel is not a gray point. At this time, saturation enhancement can be performed according to the degree parameter to obtain the corresponding processed result pixel.
[0112] It should be noted that the value range of the degree parameter is [-1, 1]. In one example, the degree parameter can be directly set by the user according to his or her own needs. Of course, in some embodiments, the image processing method also includes obtaining a saturation improvement parameter, and obtaining a degree parameter based on the saturation improvement parameter. The value range of the saturation improvement parameter is [-100, 100]. In one example, the saturation improvement parameter can be set by the user according to his or her own needs. After the processor 200 (or the third processing module 50) obtains the saturation improvement parameter, the saturation parameter is normalized, that is, the saturation improvement parameter is divided by 100 to obtain a degree parameter in the value range of [-1, 1]. For example, if the saturation improvement parameter is 20, then the degree parameter is 20 / 100=0.2.
[0113] More specifically, see Fig.17 In some embodiments, saturation enhancement is performed according to the degree parameter to obtain a corresponding processed result pixel, including:
[0114] 0521: Calculate the hue value corresponding to the result pixel according to the maximum and minimum values among the first channel value, the second channel value and the third channel value of the result pixel;
[0115] 0522: Calculate the saturation corresponding to the result pixel according to the hue value and the maximum and minimum values among the first channel value, the second channel value and the third channel value of the result pixel;
[0116] 0523: Obtaining the adjustment coefficient corresponding to the result pixel according to the degree parameter and the saturation; and
[0117] 0524: Calculate the pixel value of the processed result pixel according to the adjustment coefficient, the tone value and the pixel value of the result pixel.
[0118] Please combine Figure 2 and Figure 3 In some embodiments, the third processing module 50 and the processor 200 are further used to execute the methods in 0521, 0522, 0523 and 0524. That is, the third processing module 50 and the processor 200 are further used to calculate the hue value corresponding to the result pixel according to the maximum and minimum values among the first channel value, the second channel value and the third channel value of the result pixel; calculate the saturation corresponding to the result pixel according to the hue value and the maximum and minimum values among the first channel value, the second channel value and the third channel value of the result pixel; obtain the adjustment coefficient corresponding to the result pixel according to the degree parameter and the saturation; and calculate the pixel value of the processed result pixel according to the adjustment coefficient, the hue value and the pixel value of the result pixel.
[0119] When the maximum value and the minimum value among the first channel value, the second channel value and the third channel value of the result pixel are different, the hue value corresponding to the result pixel is calculated according to the maximum value and the minimum value among the first channel value, the second channel value and the third channel value of the result pixel. For example, in some embodiments, the hue value L corresponding to the result pixel can be obtained by calculating the formula: L = (Max-Min) / (2*255). Wherein Max and Min represent the maximum value and the minimum value among the first channel value, the second channel value and the third channel value of the result pixel, respectively. For example, assuming that the pixel value of the result pixel is (187, 11, 32), the hue value L corresponding to the result pixel is L = (187-11) / (2*255) = 0.345.
[0120] After obtaining the hue value corresponding to the result pixel, the saturation corresponding to the result pixel is calculated according to the hue value and the maximum and minimum values among the first channel value, the second channel value and the third channel value of the result pixel. Specifically, in some embodiments, the saturation S can be calculated by the formula: Calculated. Among them, L represents the hue value corresponding to the result pixel, Max and Min represent the maximum and minimum values of the first channel value, the second channel value and the third channel value of the result pixel respectively. For example, assuming that the pixel value of the result pixel is (187, 11, 32) and the corresponding hue value L is 0.345, then the saturation corresponding to the result pixel is
[0121] After the hue value and saturation corresponding to the result pixel are obtained, the adjustment coefficient corresponding to the result pixel is obtained according to the degree parameter and the saturation.
[0122] Specifically, see Fig.18 In some embodiments, obtaining an adjustment coefficient corresponding to a result pixel according to a degree parameter and a saturation includes:
[0123] 05231: If the degree parameter is greater than or equal to zero, and the sum of the degree parameter and the saturation is greater than or equal to the preset threshold, the adjustment coefficient is equal to the saturation;
[0124] 05232: If the degree parameter is greater than or equal to zero, and the sum of the degree parameter and the saturation is less than a preset threshold, the adjustment coefficient is equal to the difference between the preset constant and the degree parameter.
[0125] Please combine Figure 2 and Figure 3In some embodiments, the third processing module 50 and the processor 200 are further configured to execute the methods in 05231 and 05232. That is, the third processing module 50 and the processor 200 are further configured to adjust the coefficient equal to the saturation if the degree parameter is greater than or equal to zero and the sum of the degree parameter and the saturation is greater than or equal to a preset threshold; and adjust the coefficient equal to the difference between the preset constant and the degree parameter if the degree parameter is greater than or equal to zero and the sum of the degree parameter and the saturation is less than a preset threshold.
[0126] In some embodiments, after obtaining the hue value and saturation corresponding to the result pixel, it is determined whether the degree parameter is greater than or equal to 0. If the degree parameter is greater than or equal to zero, and the sum of the degree parameter and the saturation is greater than or equal to a preset threshold, the adjustment coefficient is equal to the saturation; if the degree parameter is greater than or equal to zero, and the sum of the degree parameter and the saturation is less than the preset threshold, the adjustment coefficient is equal to the difference between the preset constant and the degree parameter. For example, in some embodiments, the preset threshold can be 1, and the preset constant can be equal to 1. At this time, if the degree parameter is greater than or equal to zero, the adjustment coefficient alpha can be calculated by the formula: Calculated. Wherein, percent represents the degree parameter, and S represents the saturation of the result pixel. For example, assuming that the degree parameter percent is 0.2, the pixel value of the result pixel is (187, 11, 32) and the corresponding saturation S is 0.88. Since the degree parameter percent is greater than 0, and the sum of the degree parameter percent and the saturation S is 0.2+0.88=1.08, which is also greater than the preset threshold 1, the adjustment coefficient alpha corresponding to the result pixel is equal to the saturation S equal to 0.88.
[0127] See also Fig.18 In some embodiments, obtaining the adjustment coefficient corresponding to the result pixel according to the degree parameter and the saturation also includes:
[0128] 05233: If the degree parameter is less than zero, the adjustment coefficient is equal to the degree parameter.
[0129] Please combine Figure 2 and Figure 3 In some embodiments, the third processing module 50 and the processor 200 are further configured to execute the method in 05233. That is, the third processing module 50 and the processor 200 are further configured to adjust the coefficient to be equal to the saturation if the degree parameter is less than zero.
[0130] In some embodiments, after obtaining the hue value and saturation corresponding to the result pixel, it is determined whether the degree parameter is greater than or equal to 0. If the degree parameter is less than zero, the adjustment coefficient is equal to the degree parameter.
[0131] After obtaining the adjustment coefficient, the pixel value of the processed result pixel is calculated according to the adjustment coefficient, the hue value and the pixel value of the result pixel. Specifically, in some embodiments, if the degree parameter is greater than or equal to zero, it is necessary to increase the color saturation. At this time, the pixel value (R', G', B') of the processed result pixel can be obtained by calculating the formula (R', G', B') = (R, G, B) + [(R, G, B) - L*255] * alpha. That is, the pixel value of the processed result pixel (R', G', B') = (R + (RL*255) * alpha, G + (GL*255) * alpha, B + (BL*255) * alpha). Among them, L represents the hue value corresponding to the result pixel, alpha represents the adjustment coefficient R, G, B) represents the pixel value of the result pixel, R represents the first channel value of the result pixel value, G represents the second channel value of the result pixel value, B represents the third channel value of the result pixel value, R' represents the first channel value of the processed result pixel value, G' represents the second channel value of the processed result pixel value, and B' represents the third channel value of the processed result pixel value.
[0132] In some embodiments, if the degree parameter is less than zero, it is necessary to reduce the color saturation. At this time, the pixel value (R', G', B') of the processed result pixel can be calculated by the calculation formula (R', G', B') = L*255 + [(R, G, B) - L*255] * (1 + alpha). That is, the pixel value (R', G', B') of the processed result pixel = (L*255 + (RL*255) * (1 + alpha), L*255 + (GL*255) * (1 + alpha), L*255 + (BL*255) * (1 + alpha)). Among them, L represents the hue value corresponding to the result pixel, alpha represents the adjustment coefficient, (R, G, B) represents the pixel value of the result pixel, R represents the first channel value in the result pixel value, G represents the second channel value in the result pixel value, B represents the third channel value in the result pixel value, R' represents the first channel value in the processed result pixel value, G' represents the second channel value in the processed result pixel value, and B' represents the third channel value in the processed result pixel value.
[0133] It should be noted that if the value of any channel in the processed result pixel value obtained after calculation is greater than 255, the value is directly updated to 255; similarly, if the value of any channel in the processed result pixel value obtained after calculation is less than 0, the value is directly updated to 0.
[0134] After performing the above saturation processing on all result pixels to obtain the corresponding processed result pixels, the processor 200 (or the second processing module 40) can also draw a color watermark in the original image according to the processed result pixels corresponding to the result pixels to obtain the target image. The specific implementation of drawing a color watermark in the original image according to the processed result pixels is the same as the specific implementation of drawing a color watermark in the original image according to the result pixels in the above embodiment, and will not be repeated here.
[0135] See also Fig.19 The embodiment of the present application further provides a non-volatile computer-readable storage medium 400 including a computer program 401. When the computer program 401 is executed by one or more processors 200, the processor 200 executes the image processing methods in: 01, 02, 03, 04, 011, 012, 021, 022, 0221, 0222, 0223, 02211, 061, 062, 0211, 0212, 0213, 031, 0421, 0422, 05, 041, 051, 052, 0521, 0522, 0523, 0524, 05231, 05232, 05233.
[0136] For example, please combine Figure 1 , when the computer program 401 is executed by one or more processors 200, the processor 200 performs the following method:
[0137] 01: compress the original image in size and convert its color space to obtain an intermediate image whose color space is RGB space, wherein the pixel values of the pixels in the intermediate image include the first channel value corresponding to the R channel, the second channel value corresponding to the G channel, and the third channel value corresponding to the B channel;
[0138] 02: performing clustering calculation on the intermediate image according to the pixel values of all pixels of the intermediate image, the first weight, the second weight and the third weight to obtain a plurality of clustered pixels and clusters corresponding to the plurality of clustered pixels, wherein the first weight, the second weight and the third weight correspond to the R channel, the G channel and the B channel respectively, and the first weight, the second weight and the third weight are different;
[0139] 03: Select a preset number of clusters from multiple clusters, and use the clustered pixels corresponding to the selected clusters as result pixels, wherein the number of pixel points in the selected clusters is greater than the number of pixel points in the unselected clusters;
[0140] 04: Draw a color watermark in the original image according to the result pixels to obtain the target image.
[0141] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0142] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0143] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. An image processing method, It is characterized in that include: Performing size compression and color space conversion on the original image to obtain an intermediate image whose color space is an RGB space, wherein the pixel values of the pixels in the intermediate image include a first channel value corresponding to the R channel, a second channel value corresponding to the G channel, and a third channel value corresponding to the B channel; performing clustering calculation on the intermediate image according to pixel values of all pixels of the intermediate image, a first weight, a second weight, and a third weight to obtain a plurality of clustered pixels and clusters corresponding to the plurality of clustered pixels, wherein the first weight, the second weight, and the third weight correspond to the R channel, the G channel, and the B channel, respectively, and the first weight, the second weight, and the third weight are different; Selecting a preset number of clusters from the plurality of clusters, and using the clustered pixels corresponding to the selected clusters as result pixels, wherein the number of pixel points in the selected clusters is greater than the number of pixel points in the unselected clusters; A color watermark is drawn in the original image according to the result pixels to obtain a target image.
2. The image processing method according to claim 1, It is characterized in that The step of performing clustering calculation on the intermediate image according to the pixel values of all pixels of the intermediate image, the first weight, the second weight, and the third weight to obtain a plurality of clustered pixels and clusters corresponding to the plurality of clustered pixels includes: Selecting a plurality of pixels in the intermediate image as initial pixels; and The pixel value of the initial pixel is updated according to the pixel value of each pixel in the intermediate image, the pixel values of all the initial pixels, the first weight, the second weight and the third weight, the updated initial pixel is used as the clustering pixel, and the cluster corresponding to the clustering pixel is obtained.
3. The image processing method according to claim 2, It is characterized in that The selecting a plurality of pixels in the intermediate image as the initial pixels comprises: The first selection step: selecting a pixel point in the intermediate image as an initial pixel; A second selection step: calculating the color difference between each pixel and the initial pixel according to the pixel value of each pixel in the intermediate image, the pixel value of the initial pixel, the first weight, the second weight, and the third weight, and selecting the pixel corresponding to the maximum color difference as the next initial pixel; and Repeat the second selection step for the next initial center point until the number of the acquired initial pixels is greater than the second preset number.
4. The image processing method according to claim 2, It is characterized in that The updating of the pixel value of the initial pixel according to the pixel value of each pixel in the intermediate image, the pixel values of all the initial pixels, the first weight, the second weight, and the third weight, using the updated initial pixel as the clustering pixel, and obtaining a cluster corresponding to the clustering pixel includes: Step 1: traverse all the pixels in the intermediate image and perform: according to the pixel value of the pixel, the pixel values of all the initial pixels, the first weight, the second weight and the third weight, calculate a plurality of color difference values between the pixel and different initial pixels; Step 2: Divide each of the pixels into a cluster corresponding to the initial pixel corresponding to the minimum color difference value; and Step 3: Take the average of the pixel values of all the pixels in each cluster as the pixel value of the cluster pixel corresponding to the cluster. If the color difference between the cluster pixel and the corresponding initial pixel is greater than the preset difference value, use the pixel value of the cluster pixel to update the pixel value of the corresponding initial pixel, and then use the updated initial pixel to repeat steps 1 to 3 until the color difference between the cluster pixel and the corresponding initial pixel is less than the preset difference value to complete the update.
5. The image processing method according to claim 4, It is characterized in that Calculating a color difference value between the pixel point and the initial pixel according to the pixel value of the pixel point, the pixel value of the initial pixel, the first weight, the second weight, and the third weight, including: The color difference value between the pixel point and the initial pixel is calculated based on the difference between the first channel value in the pixel value and the initial pixel, the difference between the second channel value in the pixel value and the initial pixel, the difference between the third channel value in the pixel value and the initial pixel, the first weight, the second weight and the third weight.
6. The image processing method according to claim 1, It is characterized in that Also includes: The first weight, the second weight and the third weight are determined according to a mean value between the first channel values in the pixel values of the pixel point and the initial pixel and a preset mean value.
7. The image processing method according to claim 6, It is characterized in that The determining the first weight, the second weight, and the third weight according to the mean value of the first channel values in the pixel point and the initial pixel and the preset mean value comprises: If the mean value between the first channel values in the pixel values of the pixel point and the initial pixel is less than a preset mean value, determining that the second weight is greater than the first weight, and the third weight is greater than the first weight and less than the second weight; If the mean between the first channel values in the pixel values of the pixel point and the initial pixel is greater than or equal to the preset mean, it is determined that the second weight is greater than the third weight, and the first weight is greater than the third weight and less than the second weight.
8. The image processing method according to claim 1, It is characterized in that The step of selecting a preset number of clusters from the plurality of clusters and using the clustered pixels corresponding to the selected clusters as result pixels, wherein the number of pixel points in the selected clusters is greater than the number of pixel points in the unselected clusters, comprises: All the clusters are sorted at least in order of majority according to the number of pixel points in each cluster, and the cluster pixels corresponding to the clusters arranged before a first preset value are selected as result pixels.
9. The image processing method according to claim 1, It is characterized in that The image processing method further comprises: Performing saturation processing on the result pixel to obtain a corresponding processed result pixel; Drawing a color watermark in the original image according to the result pixel to obtain a target image comprises: A color watermark is drawn in the original image according to the processed result pixel corresponding to the result pixel to obtain a target image.
10. The image processing method according to claim 9, It is characterized in that The pixel value of the result pixel includes a first channel value corresponding to the R channel, a second channel value corresponding to the G channel, and a third channel value corresponding to the B channel, and the saturation processing of the result pixel to obtain the corresponding processed result pixel includes: If the maximum value and the minimum value among the first channel value, the second channel value and the third channel value of the result pixel are the same, directly taking the result pixel as the corresponding processed result pixel; If the maximum value and the minimum value among the first channel value, the second channel value and the third channel value of the result pixel are different, saturation enhancement is performed according to a degree parameter to obtain the corresponding processed result pixel.
11. The image processing method according to claim 10, It is characterized in that The step of performing saturation enhancement according to the degree parameter to obtain the corresponding processed result pixel includes: Calculating a hue value corresponding to the result pixel according to a maximum value and a minimum value among the first channel value, the second channel value and the third channel value of the result pixel; Calculate the saturation corresponding to the result pixel according to the hue value and the maximum and minimum values among the first channel value, the second channel value and the third channel value of the result pixel; According to the degree parameter and the saturation, obtaining an adjustment coefficient corresponding to the result pixel; and The pixel value of the processed result pixel is calculated according to the adjustment coefficient, the tone value and the pixel value of the result pixel.
12. The image processing method according to claim 11, It is characterized in that According to the degree parameter and the saturation, obtaining an adjustment coefficient corresponding to the result pixel includes: If the degree parameter is greater than or equal to zero, and the sum of the degree parameter and the saturation is greater than or equal to a preset threshold, the adjustment coefficient is equal to the saturation; If the degree parameter is greater than or equal to zero, and the sum of the degree parameter and the saturation is less than a preset threshold, the adjustment coefficient is equal to the difference between a preset constant and the degree parameter.
13. The image processing method according to claim 11, It is characterized in that According to the degree parameter and the saturation, obtaining an adjustment coefficient corresponding to the result pixel, further comprising: If the degree parameter is less than zero, the adjustment coefficient is equal to the degree parameter.
14. The image processing method according to claim 1, It is characterized in that The color space of the original image is a YUV color space, and the step of drawing a color watermark in the original image according to the result pixel to obtain a target image includes: Convert the result pixel into a YUV color space to obtain a YUV value corresponding to the result pixel; and The YUV value of the pixel at the preset position of the original image is replaced by the YUV value corresponding to the result pixel to obtain a target image containing a color watermark.
15. An image processing device, It is characterized in that include: A first processing module is used to perform size compression and color space conversion on the original image to obtain an intermediate image whose color space is an RGB space, wherein the pixel values of the pixels in the RGB space include a first channel value corresponding to the R channel, a second channel value corresponding to the G channel, and a third channel value corresponding to the B channel; an acquisition module, configured to perform clustering calculation on the intermediate image according to pixel values of all pixels of the intermediate image, a first weight, a second weight, and a third weight to acquire a plurality of clustered pixels and clusters corresponding to the plurality of clustered pixels, wherein the first weight, the second weight, and the third weight correspond to the R channel, the G channel, and the B channel, respectively; a selection module, configured to select a preset number of clusters from the plurality of clusters, and use the clustered pixels corresponding to the selected clusters as result pixels, wherein the number of pixel points in the selected clusters is greater than the number of pixel points in the unselected clusters; and The second processing module is used to draw a color watermark in the original image according to the result pixel to obtain a target image.
16. A terminal, It is characterized in that include: One or more processors, memory; and One or more programs, wherein one or more of the programs are stored in the memory and executed by one or more of the processors, and the programs include instructions for executing the image processing method according to any one of claims 1 to 14.
17. A non-volatile computer-readable storage medium storing a computer program, which, when executed by one or more processors, implements the image processing method according to any one of claims 1 to 14.
