Theme color determination method, image display method, model training method and device

By determining the theme color of the image and adjusting the display interface colors, the problem of immersive experience caused by the large color difference between the target image and other areas was solved, thus improving the user experience.

CN115439661BActive Publication Date: 2026-03-13BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-24
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

In existing technologies, the target image in the display interface has a large color difference from other areas, which prevents users from having an immersive experience and reduces the user's experience when browsing images.

Method used

The target color group is determined based on the color grouping and pixel count in the image to be processed, and the theme color of the image is calculated. The colors of the areas outside the image in the display interface are then adjusted to match the overall color of the image.

Benefits of technology

It increases the likelihood of users having an immersive experience and improves the quality of users' image browsing experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115439661B_ABST
    Figure CN115439661B_ABST
Patent Text Reader

Abstract

This invention provides a method for determining a theme color, an image display method, a model training method, and an apparatus. The method involves grouping the colors in the image to be processed into multiple groups based on their color families. A target color group is determined from these groups based on a first number corresponding to each color in the target color group. The theme color of the image is then calculated based on the pixel values ​​of each color in the target color group. This method determines the theme color of the image, and subsequently, the colors of other areas of the display interface (excluding the displayed image) are set to the theme color, ensuring that the colors of other areas match the overall color of the displayed image. This provides an immersive experience and improves the user experience when browsing images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a method for determining theme color, an image display method, a model training method, and an apparatus. Background Technology

[0002] Currently, research on immersive experiences, both domestically and internationally, is still ongoing. The aim of immersive experiences is to eliminate as many distractions as possible from the content the user is focused on, allowing the user to concentrate smoothly on performing their intended behavior. Furthermore, it leverages the user's highly focused attention to guide them towards positive emotions and an immersive experience. As a medium for providing information to users, the rationality and comfort of the display interface design affect the user's perception and understanding of that information. A well-designed display interface can provide users with an immersive experience and improve the user experience.

[0003] In related technologies, for display interfaces that display images, the display interface shows a target image, and the other areas of the display interface (e.g., the menu bar) are in preset colors. If the preset colors differ significantly from the overall color of the target image, it will prevent users from having an immersive experience and reduce the user experience of browsing images. Summary of the Invention

[0004] The purpose of this invention is to provide a method for determining a theme color, an image display method, a model training method, and an apparatus. These methods can determine the theme color of an image and set the colors of other areas in the display interface besides the displayed image to the theme color, thereby improving the user experience. The specific technical solution is as follows:

[0005] In a first aspect of this invention, a method for determining a theme color is provided, the method comprising:

[0006] Based on the color system to which each color to be processed belongs in the image to be processed, the colors to be processed in the image to be processed are grouped to obtain multiple color groups, which are used as the color groups to be processed.

[0007] Based on the first number corresponding to each color to be processed in each color group to be processed, a target color group is determined from each color group to be processed; wherein, the first number corresponding to a color to be processed is: the number of pixels in the image to be processed that contain the color to be processed;

[0008] The theme color of the image to be processed is calculated based on the pixel values ​​corresponding to each color to be processed in the target color group.

[0009] Optionally, the step of grouping the colors to be processed in the image according to the color system to which each color belongs, resulting in multiple color groups, as the color groups to be processed, includes:

[0010] Based on the color system to which each color to be processed belongs in the image to be processed, each color to be processed is clustered to obtain multiple color groups, which are used as color groups to be processed; wherein, the first color difference value between the cluster centers of any two color groups to be processed is greater than a first threshold; the first color difference value between each color to be processed and the cluster center of its respective color group to be processed is less than the first color difference value between the color to be processed and the cluster centers of other color groups to be processed.

[0011] Optionally, before grouping the colors in the image to be processed according to their respective color systems to obtain multiple color groups as the groups of colors to be processed, the method further includes:

[0012] According to the first number of each color to be processed in the image to be processed, arranged in descending order, the first second number of colors are determined from the colors contained in the image to be processed, and these are taken as the colors to be processed.

[0013] Optionally, determining the target color group from each color group to be processed based on the first number corresponding to each color to be processed in each color group to be processed includes:

[0014] For each color group to be processed, based on each color to be processed in the color group, the color difference value corresponding to the color group to be processed is calculated, and based on the first number corresponding to each color to be processed in the color group, the average number of colors to be processed corresponding to the color group to be processed is calculated; wherein, the color difference value represents the dispersion of each color to be processed in the color group to be processed; the average number of colors to be processed represents the proportion of each color to be processed in the color group to be processed in the image to be processed.

[0015] The color difference value to be processed and the mean number of samples to be processed are input into a pre-trained target color prediction model to obtain the confidence score of the color group to be processed output by the target color prediction model, which is used as the confidence score of the sample group to be processed. The target color prediction model is trained based on the sample color difference value, the mean number of samples, and the sample confidence score of the sample color group. The sample color group is obtained by grouping the sample colors in the sample image. The sample color difference value represents the dispersion of each sample color in the sample color group; the mean number of samples represents the proportion of the sample colors in the sample color group in the sample image.

[0016] From each color group to be processed, determine the color group with the highest confidence level and use it as the target color group.

[0017] Optionally, for each color group to be processed, calculating the color difference value corresponding to the color group to be processed based on each color to be processed in the color group to be processed, and calculating the average number of colors to be processed corresponding to the color group to be processed based on the first number corresponding to each color to be processed in the color group to be processed, includes:

[0018] For each color group to be processed, according to the first number corresponding to each color to be processed in the color group to be processed in descending order, calculate the color difference value between each two adjacent colors to be processed in the color group to be processed, and use it as the second color difference value; calculate the average value of each second color difference value corresponding to the color group to be processed to obtain the color difference value to be processed corresponding to the color group to be processed.

[0019] Calculate the average of the first number corresponding to each color in the color group to be processed, and obtain the average number of colors to be processed corresponding to the color group to be processed.

[0020] Optionally, before grouping the colors in the image to be processed according to their respective color systems to obtain multiple color groups as the groups of colors to be processed, the method further includes:

[0021] For each pixel in the image to be processed, if the brightness value of the pixel's color belongs to a first preset brightness range, the color of the pixel is determined as a candidate color; from each candidate color, the color to be processed is determined.

[0022] or,

[0023] For each pixel in the image to be processed, if the brightness value of the pixel's color belongs to a second preset brightness range and the saturation value of the color does not belong to a preset saturation range, the color of the pixel is determined as a candidate color; from each candidate color, the color to be processed is determined; wherein, the second preset brightness range belongs to the first preset brightness range.

[0024] Optionally, determining the color to be processed from the candidate colors includes:

[0025] From the candidate colors, determine the candidate colors whose corresponding first number is greater than the second threshold, and use them as the colors to be processed; wherein, the first number corresponding to a candidate color is: the number of pixels in the image to be processed that contain the candidate color.

[0026] Optionally, before grouping the colors in the image to be processed according to their respective color systems to obtain multiple color groups as the groups of colors to be processed, the method further includes:

[0027] Obtain the original image and extract the image region from the original image excluding the specified object to obtain the image to be processed;

[0028] For each pixel in the image to be processed, the brightness and saturation values ​​of the pixel's color are calculated based on the pixel value.

[0029] Optionally, after calculating the theme color of the image to be processed based on the pixel values ​​corresponding to each color to be processed in the target color group, the method further includes:

[0030] The theme color of the image to be processed is used as the theme color of the original image, and the theme color of the original image is stored.

[0031] In a second aspect of the present invention, an image display method is also provided, the method being applied to a server, the method comprising:

[0032] Receive a request from the client to retrieve the target image;

[0033] Obtain the target image and the theme color of the target image; wherein the theme color of the target image is obtained by the server based on any of the theme color determination methods described in the first aspect above;

[0034] The target image and its theme color are sent to the client so that upon receiving the target image and its theme color, the client displays the target image on its display interface and sets the color of all other areas of the display interface except the target image to the theme color of the target image.

[0035] In a third aspect of this invention, a model training method is also provided, the method comprising:

[0036] Based on the color system to which each sample color in the sample image belongs, the sample colors in the sample image are grouped to obtain multiple color groups, which are then used as sample color groups.

[0037] Based on each sample color in the sample color group, calculate the sample color difference value corresponding to the sample color group, and calculate the mean number of samples corresponding to the sample color group based on the number of samples corresponding to the sample colors in the sample color group; wherein, the sample color difference value represents the dispersion of each sample color in the sample color group; the mean number of samples represents the proportion of the sample colors in the sample color group in the sample image; the number of samples corresponding to a sample color is the number of pixels in the sample image containing that sample color.

[0038] Obtain the confidence level of the sample color group as the sample confidence level; wherein, the sample confidence level represents the probability that the sample color in the sample color group can characterize the overall color features of the sample image;

[0039] Based on the sample color difference value, the mean number of samples, and the sample confidence level, the model parameters of the initial color prediction model are adjusted until the preset convergence condition is met, thus obtaining the trained target color prediction model.

[0040] In a fourth aspect of the invention, a theme color determining device is also provided, the device comprising:

[0041] The color grouping module is used to group the colors in the image to be processed according to the color system to which each color belongs, resulting in multiple color groups, which are then used as the color groups to be processed.

[0042] The target color grouping determination module is used to determine the target color group from each color group to be processed based on a first number corresponding to each color to be processed in each color group to be processed; wherein, the first number corresponding to a color to be processed is: the number of pixels in the image to be processed that contain the color to be processed;

[0043] The theme color determination module is used to calculate the theme color of the image to be processed based on the pixel values ​​corresponding to each color to be processed in the target color group.

[0044] Optionally, the color grouping module is specifically used to cluster each color to be processed based on the color system to which each color to be processed belongs in the image to be processed, to obtain multiple color groups as color groups to be processed; wherein, the first color difference value between the cluster centers of any two color groups to be processed is greater than a first threshold; the first color difference value between each color to be processed and the cluster center of its respective color group to be processed is less than the first color difference value between the color to be processed and the cluster centers of other color groups to be processed.

[0045] Optionally, the device further includes:

[0046] The color determination module is used to group the colors to be processed in the image according to the color system to which each color belongs, and obtain multiple color groups before the color grouping module performs the operation of determining the second number of colors from the colors in the image to be processed, according to the first number of the colors to be processed in the image in descending order, as the colors to be processed.

[0047] Optionally, the target color grouping determination module is specifically used to, for each color group to be processed, calculate the color difference value corresponding to the color group to be processed based on each color to be processed in the color group to be processed, and calculate the average number of colors to be processed corresponding to the color group to be processed based on a first number corresponding to each color to be processed in the color group to be processed; wherein, the color difference value represents the dispersion of each color to be processed in the color group to be processed; the average number of colors to be processed represents the proportion of each color to be processed in the color group to be processed in the image to be processed;

[0048] The color difference value to be processed and the mean number of samples to be processed are input into a pre-trained target color prediction model to obtain the confidence score of the color group to be processed output by the target color prediction model, which is used as the confidence score of the sample group to be processed. The target color prediction model is trained based on the sample color difference value, the mean number of samples, and the sample confidence score of the sample color group. The sample color group is obtained by grouping the sample colors in the sample image. The sample color difference value represents the dispersion of each sample color in the sample color group; the mean number of samples represents the proportion of the sample colors in the sample color group in the sample image.

[0049] From each color group to be processed, determine the color group with the highest confidence level and use it as the target color group.

[0050] Optionally, the target color grouping determination module is specifically used to, for each color group to be processed, calculate the color difference value between each two adjacent colors in the color group to be processed, according to the first number of each color to be processed in the color group to be processed arranged in descending order, as a second color difference value; calculate the average value of each second color difference value corresponding to the color group to be processed to obtain the color difference value to be processed corresponding to the color group to be processed.

[0051] Calculate the average of the first number corresponding to each color in the color group to be processed, and obtain the average number of colors to be processed corresponding to the color group to be processed.

[0052] Optionally, the device further includes:

[0053] The color determination module is used to group the colors to be processed in the image according to the color system to which each color belongs, before the color grouping module performs the operation of grouping the colors to be processed in the image, resulting in multiple color groups. Before grouping the colors to be processed, the module performs the following operation: for each pixel in the image, if the brightness value of the color of the pixel belongs to a first preset brightness range, the color of the pixel is determined as a candidate color; and the color to be processed is determined from each candidate color.

[0054] or,

[0055] For each pixel in the image to be processed, if the brightness value of the pixel's color belongs to a second preset brightness range and the saturation value of the color does not belong to a preset saturation range, the color of the pixel is determined as a candidate color; from each candidate color, the color to be processed is determined; wherein, the second preset brightness range belongs to the first preset brightness range.

[0056] Optionally, the color determination module is specifically used to determine, from each candidate color, a candidate color whose first number is greater than a second threshold, as the color to be processed; wherein, the first number corresponding to a candidate color is: the number of pixels in the image to be processed containing that candidate color.

[0057] Optionally, the device further includes:

[0058] The image to be processed acquisition module is used to group the colors to be processed in the image to be processed according to the color system to which each color to be processed belongs, and obtain multiple color groups before the color grouping module is used as the color grouping module. The module then acquires the original image and extracts the image area in the original image except for the specified object to obtain the image to be processed.

[0059] The brightness value determination module is used to calculate the brightness value and saturation value of the color of each pixel in the image to be processed, based on the pixel value of that pixel.

[0060] Optionally, the device further includes:

[0061] The theme color storage module is used to, after the theme color determination module calculates the theme color of the image to be processed based on the pixel values ​​corresponding to each color to be processed in the target color group, use the theme color of the image to be processed as the theme color of the original image and store the theme color of the original image.

[0062] In a fifth aspect of the invention, an image display device is also provided, the device being applied to a server, the device comprising:

[0063] The request receiving module is used to receive requests from clients for the target image.

[0064] The theme color acquisition module is used to acquire the target image and the theme color of the target image; wherein, the theme color of the target image is obtained by the server based on any of the theme color determination methods described in the first aspect above;

[0065] The theme color sending module is used to send the target image and the theme color of the target image to the client, so that after the client receives the target image and the theme color of the target image, it displays the target image on the client's display interface and sets the color of other areas in the display interface except for the target image to the theme color of the target image.

[0066] In a sixth aspect of the invention, a model training apparatus is also provided, the apparatus comprising:

[0067] The sample color grouping module is used to group the sample colors contained in the sample image according to the color system to which each sample color belongs, resulting in multiple color groups, which are then used as sample color groups.

[0068] The sample color difference value determination module is used to calculate the sample color difference value corresponding to the sample color group based on each sample color in the sample color group, and to calculate the mean number of samples corresponding to the sample color group based on the number of samples corresponding to the sample colors in the sample color group; wherein, the sample color difference value represents the dispersion of each sample color in the sample color group; the mean number of samples represents the proportion of the sample color in the sample color group in the sample image; and the number of samples corresponding to a sample color is the number of pixels in the sample image containing that sample color.

[0069] The sample confidence acquisition module is used to acquire the confidence of the sample color group as the sample confidence; wherein, the sample confidence represents the probability that the sample color in the sample color group can characterize the overall color features of the sample image;

[0070] The model parameter adjustment module is used to adjust the model parameters of the initial structure color prediction model based on the sample color difference value, the mean number of samples, and the sample confidence level, until the preset convergence condition is reached, and the trained target color prediction model is obtained.

[0071] In another aspect of the present invention, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus.

[0072] Memory, used to store computer programs;

[0073] When a processor executes a program stored in memory, it implements the theme color determination method step described in any of the first aspects above, the image display method step described in any of the second aspects above, or the model training method step described in any of the third aspects above.

[0074] In another aspect of the present invention, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, it implements the theme color determination method steps described in any of the first aspects, or the image display method steps described in any of the second aspects, or the model training method steps described in any of the third aspects.

[0075] In another aspect of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute the theme color determination method described in any of the first aspects, or the image display method described in any of the second aspects, or the model training method described in any of the third aspects.

[0076] The technical solution provided in this embodiment of the invention involves grouping the colors to be processed in the image to be processed according to the color system to which each color belongs, resulting in multiple color groups, which serve as the color groups to be processed; determining a target color group from each color group based on a first number corresponding to each color to be processed; the first number corresponding to a color to be processed is the number of pixels in the image to be processed containing that color; and calculating the theme color of the image to be processed based on the pixel values ​​corresponding to each color to be processed in the target color group.

[0077] Based on the above processing, the theme color of the image to be processed can be determined. Furthermore, the theme color can be determined based on the number of pixels in the image containing the color to be processed, that is, the proportion of the color to be processed within the image. This improves the accuracy of the determined theme color. Subsequently, the colors of other areas in the display interface besides the displayed image can be set to the image's theme color, ensuring that the colors of other areas match the overall color of the displayed image. This provides users with an immersive experience and enhances the user experience when browsing images. Attached Figure Description

[0078] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.

[0079] Figure 1 This is a flowchart of the first theme color determination method provided in the embodiments of the present invention;

[0080] Figure 2 This is a flowchart of the second theme color determination method provided in this embodiment of the invention;

[0081] Figure 3 This is a flowchart of the third theme color determination method provided in this embodiment of the invention;

[0082] Figure 4 This is a flowchart of the fourth theme color determination method provided in the embodiments of the present invention;

[0083] Figure 5 This is a flowchart of a model training method provided in an embodiment of the present invention;

[0084] Figure 6 This is a flowchart of the first image display method provided in the embodiments of the present invention;

[0085] Figure 7 This is a flowchart of the second image display method provided in this embodiment of the invention;

[0086] Figure 8 This is a structural diagram of a theme color determination device provided in an embodiment of the present invention;

[0087] Figure 9 This is a structural diagram of a model training device provided in an embodiment of the present invention;

[0088] Figure 10 This is a structural diagram of an image display device provided in an embodiment of the present invention;

[0089] Figure 11 This is a structural diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0090] The technical solutions of the present invention will now be described with reference to the accompanying drawings in the embodiments of the present invention.

[0091] In related technologies, for display interfaces that display images, the display interface shows a target image, and the other areas of the display interface (e.g., the menu bar) are in preset colors. If the preset colors differ significantly from the overall color of the target image, it will prevent users from having an immersive experience and reduce the user experience of browsing images.

[0092] To address the aforementioned problems, this invention provides a method for determining a theme color. This method is applied to an electronic device, which can determine the theme color of an image to be processed using the method provided in this invention, thereby improving the accuracy of the determined theme color. If the electronic device is a client, it can subsequently set the colors of other areas of the display interface according to the theme color of the image to be processed when displaying it. If the electronic device is a server, upon receiving a request from a client to retrieve an image to be processed, it can send the image to be processed and its theme color to the client. Correspondingly, the client can set the colors of other areas of the display interface according to the theme color of the image to be processed when displaying it, providing users with an immersive experience and improving the user experience when browsing images.

[0093] See Figure 1 , Figure 1 A flowchart of a theme color determination method provided in an embodiment of the present invention, the method may include the following steps:

[0094] S101: Based on the color system to which each color to be processed belongs in the image to be processed, group each color to be processed in the image to be processed to obtain multiple color groups, which are used as color groups to be processed.

[0095] S102: Determine the target color group from each color group based on the first number corresponding to each color to be processed in each color group to be processed.

[0096] The first number corresponding to a color to be processed is the number of pixels in the image to be processed that contain that color.

[0097] S103: Calculate the theme color of the image to be processed based on the pixel values ​​corresponding to each color to be processed in the target color group.

[0098] Based on the theme color determination method provided in this invention, the theme color of the image to be processed can be determined. Furthermore, the theme color can be determined based on the number of pixels in the image containing the color to be processed, that is, based on the proportion of the color to be processed in the image, thus improving the accuracy of the determined theme color. Subsequently, the colors of other areas in the display interface besides the displayed image can be set as the theme color of the image, making the colors of other areas in the display interface match the overall color of the displayed image. This allows users to have an immersive experience and improves the user experience when browsing images.

[0099] For step S101, the image to be processed is any image whose theme color needs to be determined.

[0100] When the electronic device acts as a client, it can retrieve the image that needs to be displayed and use it as the image to be processed. Alternatively, when the electronic device acts as a server, it can receive the retrieval request sent by the client and determine that the image requested by the client is the image to be processed.

[0101] The color to be processed can include the color of each pixel in the image to be processed. Alternatively, the color to be processed can also include a subset of colors determined from the colors of the individual pixels in the image to be processed.

[0102] In some embodiments, prior to step S101, the electronic device may determine the color to be processed based on the following method.

[0103] Method 1,

[0104] For each pixel in the image to be processed, if the brightness value of the pixel's color belongs to the first preset brightness range, the color of the pixel is determined as a candidate color; from each candidate color, the color to be processed is determined.

[0105] The first preset brightness range can be set according to actual needs. The lower limit of the first preset brightness range is a lower brightness value, and the upper limit of the first preset brightness range is a higher brightness value. For example, the first preset brightness range can be [3, 92], or the first preset brightness range can also be [4, 91], but it is not limited to these.

[0106] The brightness of a color can be represented by its brightness value. If the brightness value of a pixel falls within a first preset brightness range, it indicates that the pixel's color is neither too bright nor too dark, and the electronic device can determine that the pixel's color is a candidate color. Furthermore, the electronic device can determine the color to be processed from the candidate colors.

[0107] Method 2,

[0108] For each pixel in the image to be processed, if the brightness value of the pixel's color belongs to the second preset brightness range and the saturation value of the color does not belong to the preset saturation range, the color of the pixel is determined as a candidate color; from each candidate color, the color to be processed is determined.

[0109] The second preset brightness range is a subset of the first preset brightness range. The second preset brightness range can be set according to actual needs, and it is a subset of the first preset brightness range. For example, if the first preset brightness range is [3, 92], then the second preset brightness range can be [6, 90], or if the first preset brightness range is [4, 91], then the second preset brightness range can be [7, 89], but it is not limited to these.

[0110] The preset saturation range can be set according to actual needs. For example, the preset saturation range can be [25, 35], or it can be [20, 30], but it is not limited to these.

[0111] The brightness of a color can be represented by both its brightness value and saturation value. If the brightness value of a pixel's color belongs to a second preset brightness range and the saturation value of the color does not belong to a preset saturation range, it indicates that the color of the pixel is neither a brighter color nor a darker color, and the electronic device can determine that the color of the pixel is a candidate color.

[0112] Alternatively, for each pixel in the image to be processed, if the brightness value of the pixel's color belongs to the second preset brightness range and the saturation value of the color is not a specified saturation value (e.g., 30), then the color of the pixel is determined to be a candidate color.

[0113] Furthermore, electronic devices can determine the color to be processed from the alternative colors.

[0114] Based on the above processing, brighter and darker colors in the image to be processed can be filtered out, thus avoiding the influence of brighter and darker colors on the determination of the theme color of the image to be processed and improving the accuracy of the determined theme color.

[0115] In some embodiments, the step of determining the color to be processed from the candidate colors may include the following steps: determining candidate colors whose corresponding first number is greater than a second threshold from the candidate colors as the color to be processed.

[0116] The first number corresponding to a candidate color is the number of pixels in the image to be processed that contain that candidate color.

[0117] The second threshold can be determined based on the total number of colors contained in the image to be processed. For example, the second threshold can be 1.25% of the total number of colors contained in the image to be processed. That is, when the total number of colors contained in the image to be processed is 400, the second threshold is 5. Alternatively, the second threshold can also be 1.5% of the total number of colors contained in the image to be processed. That is, when the total number of colors contained in the image to be processed is 400, the second threshold is 6. However, it is not limited to these two types of thresholds.

[0118] For each candidate color, the electronic device can count the number of pixels of that candidate color in the image to be processed, obtaining a first number corresponding to that candidate color. The first number represents the frequency of occurrence of the candidate color in the image to be processed, and can indicate the proportion of the candidate color in the image to be processed. If the first number corresponding to a candidate color is greater than a second threshold, it indicates that the proportion of the candidate color in the image to be processed is relatively large, and the electronic device can determine that the candidate color is the color to be processed.

[0119] Based on the above processing, if the first number corresponding to the color to be processed is greater than the second threshold, then the proportion of the color to be processed in the image to be processed is relatively large. In other words, colors with a small proportion in the image to be processed can be filtered out, which can reduce the amount of calculation. Furthermore, filtering out colors with a small proportion in the image to be processed has little impact on the accuracy of the determined theme color. Thus, the efficiency of determining the theme color of the image can be improved while ensuring the accuracy of the determined theme color.

[0120] In some embodiments, before step S101, the method may further include the following steps: determining the first second number of colors from the colors contained in the image to be processed, according to the first number of colors contained in the image to be processed arranged in descending order, as the colors to be processed.

[0121] For each color in the image to be processed, the electronic device can count the number of pixels of that color in the image to be processed, and obtain the first number corresponding to that color. The first number can represent the proportion of that color in the image to be processed. Then, according to the first number corresponding to each color in descending order, the electronic device determines the first second number of colors from the colors contained in the image to be processed as the colors to be processed.

[0122] The second number can be determined based on the total number of colors contained in the image to be processed. For example, the second number can be 80% of the total number of colors contained in the image to be processed, or 90% of the total number of colors contained in the image to be processed, etc., but it is not limited to these.

[0123] Based on the above processing, the first two numbers of each color in the descending order of their first number have a larger proportion in the image to be processed. This means that colors with a smaller proportion in the image can be filtered out, reducing the amount of computation. Furthermore, filtering out colors with a smaller proportion in the image has a smaller impact on the accuracy of the determined theme color. Therefore, while ensuring the accuracy of the determined theme color, the efficiency of determining the theme color of the image can be further improved.

[0124] In some embodiments, Figure 1 Based on this, see Figure 2Before step S101, the method may further include the following steps:

[0125] S104: For each pixel in the image to be processed, if the brightness value of the pixel's color belongs to a first preset brightness range, determine the color of the pixel as a candidate color; determine the color to be processed from each candidate color. Alternatively, for each pixel in the image to be processed, if the brightness value of the pixel's color belongs to a second preset brightness range and the saturation value of the color does not belong to a preset saturation range, determine the color of the pixel as a candidate color; determine the color to be processed from each candidate color.

[0126] Accordingly, prior to step S104, the method may further include the following steps:

[0127] S105: Obtain the original image and extract the image region from the original image excluding the specified object to obtain the image to be processed.

[0128] S106: For each pixel in the image to be processed, calculate the brightness and saturation values ​​of the pixel's color based on the pixel value.

[0129] The specified object can be set by technical personnel according to actual needs. For example, the specified object can be a person, an animal, etc.

[0130] When the electronic device acts as a client, it can retrieve the image that needs to be displayed and use it as the original image. Alternatively, when the electronic device acts as a server, it can receive retrieval requests from clients and determine that the image requested by the client is the original image.

[0131] The electronic device then determines whether the original image contains the specified object. If the original image does not contain the specified object, the electronic device identifies the original image as the image to be processed. If the original image contains the specified object, the electronic device can extract the image region from the original image excluding the specified object, and use this region as the image to be processed. For example, if the original image contains an image of a person, the electronic device extracts the image region from the original image excluding the image of the person to obtain the image to be processed.

[0132] For each pixel in the image to be processed, the electronic device can obtain the pixel value of that pixel, that is, the RGB value of that pixel. Based on the RGB value of that pixel, the HSL (Hue, Saturation, Lightness) value of that pixel is calculated. The HSL value of that pixel represents the color of that pixel.

[0133] Based on the above processing, the color characteristics of the specified object in the original image may differ significantly from those of other areas in the original image. Electronic devices can extract the image areas other than the specified object from the original image as the image to be processed, which can improve the accuracy of the determined theme color of the image.

[0134] In some embodiments, the electronic device may group the colors to be processed in the following manner to obtain multiple groups of colors to be processed.

[0135] Method 1,

[0136] Step S101 may include the following steps: according to the first number of each color to be processed contained in the image to be processed, in descending order, divide each color to be processed into a third number of color groups, which are used as color groups to be processed.

[0137] The first number corresponding to a color to be processed is the number of pixels in the image containing that color. Each group of colors to be processed contains the first fourth number of colors in the sorted order, and the fourth number is different for different groups of colors to be processed. The third and fourth numbers can be set according to requirements.

[0138] For example, the image to be processed contains 50 colors to be processed. According to the order of the first number corresponding to each color to be processed from largest to smallest, the electronic device can divide the first 5 colors to be processed in the order into one group of colors to be processed; divide the first 10 colors to be processed in the order into one group of colors to be processed; divide the first 20 colors to be processed in the order into one group of colors to be processed; divide the first 50 colors to be processed in the order into one group of colors to be processed, resulting in 4 groups of colors to be processed.

[0139] Alternatively, if the image to be processed contains 100 colors to be processed, the electronic device can group the first 10 colors to be processed into one group according to the descending order of the first number corresponding to each color; group the first 20 colors to be processed into one group; group the first 40 colors to be processed into one group; group the first 60 colors to be processed into one group; and group the first 80 colors to be processed into one group, resulting in 5 groups of colors to be processed.

[0140] Method 2

[0141] Step S101 may include the following steps: clustering each color to be processed based on the color system to which each color to be processed in the image to be processed is located, resulting in multiple color groups, which are used as color groups to be processed.

[0142] Specifically, the first color difference value between the cluster centers of any two color groups to be processed is greater than a first threshold; the first color difference value between each color to be processed and the cluster center of its respective color group to be processed is less than the first color difference value between the color to be processed and the cluster centers of other color groups to be processed.

[0143] Electronic devices can use the k-Means algorithm to select k seeds from each color to be processed, with each seed serving as a cluster center. Based on the selected cluster centers, each color to be processed can be grouped to obtain multiple groups of colors to be processed.

[0144] In one implementation, the electronic device can select a specified color to be processed from among the colors to be processed, according to the descending order of the first number corresponding to each color, to obtain the first cluster center. For example, the electronic device can select the first color to be processed from among the colors to be processed as the first cluster center, or the electronic device can select the second color to be processed from among the colors to be processed as the first cluster center.

[0145] The electronic device identifies all colors other than the first cluster center from among the colors to be processed as the current comparison colors. For each current comparison color, the electronic device calculates the color difference value (i.e., the first color difference value) between that comparison color and the first cluster center.

[0146] For example, the color system to which a color belongs can be represented by the hue value of the color to be processed. The electronic device calculates the difference between the hue value of the color to be compared and the hue value of the cluster center, and calculates the absolute value of the difference as the first color difference value between the color to be compared and the cluster center.

[0147] Alternatively, the color family to which a color belongs can be represented by the hue, saturation, and brightness values ​​of the color to be processed. The electronic device then calculates the sum of the hue, saturation, and brightness values ​​of the color to be compared (this can be called the first sum), and calculates the sum of the hue, saturation, and brightness values ​​of the cluster center (this can be called the second sum). The electronic device calculates the difference between the first sum and the second sum, and calculates the absolute value of this difference as the first color difference value between the color to be compared and the cluster center.

[0148] For each color to be compared, the electronic device determines whether the first color difference value between the color to be compared and the first cluster center is greater than a first threshold. If the first color difference value between the color to be compared and the cluster center is greater than the first threshold, it indicates that the difference between the color to be compared and the first cluster center is large, and the electronic device determines the color to be compared as a new cluster center.

[0149] The first threshold can be set according to actual needs. For example, the first threshold can be 45, or it can be 50, but it is not limited to this.

[0150] Then, the electronic device determines the other colors to be processed from among the colors to be processed, excluding the current cluster center, to obtain the current colors to be compared. The current cluster centers include all the previously determined cluster centers. The electronic device then calculates a first color difference value between each current color to be compared and each current cluster center. From the current colors to be compared, the electronic device determines colors whose first color difference value with that cluster center is greater than a second threshold, and uses them as new cluster centers, and so on, until a fifth number of cluster centers are determined. The fifth number can be set according to the total number of colors contained in the image to be processed; for example, if the total number of colors in the image to be processed is 50, the fifth number can be 4, or if the total number of colors in the image to be processed is 100, the fifth number can be 5, but it is not limited to these.

[0151] Furthermore, for each color to be compared, the electronic device divides the color to be compared into the color group to which the cluster center with the smallest first color difference value between the color to be compared belongs, thus obtaining multiple color groups as color groups to be processed.

[0152] For step S102, the electronic device can determine the target color group from each color group to be processed in the following manner.

[0153] Method 1,

[0154] The electronic device can count the number of colors to be processed contained in each color group to be processed, and determine the color group containing the largest number of colors to be processed from all the color groups to be processed as the target color group.

[0155] Method 2,

[0156] For each color group to be processed, the electronic device can calculate the sum of the first number corresponding to each color to be processed in the color group to be processed, and determine the color group to be processed with the largest sum from all the color groups to be processed as the target color group.

[0157] Method 3

[0158] exist Figure 1 Based on this, see Figure 3 Step S102 may include the following steps:

[0159] S1021: For each color group to be processed, calculate the color difference value corresponding to the color group to be processed based on each color to be processed in the color group to be processed, and calculate the average number of colors to be processed corresponding to the color group to be processed based on the first number corresponding to each color to be processed in the color group to be processed.

[0160] Among them, the color difference value to be processed represents the degree of dispersion of each color to be processed in the color group to be processed; the average number of colors to be processed represents the proportion of the color to be processed in the color group to be processed in the image to be processed.

[0161] S1022: Input the color difference value to be processed and the average number of to be processed into the pre-trained target color prediction model to obtain the confidence of the color group to be processed output by the target color prediction model, which is used as the confidence of the to be processed.

[0162] The target color prediction model is trained based on the sample color difference value, the mean number of samples, and the sample confidence score of the sample color group. The sample color group is obtained by grouping the sample colors in the sample image. The sample color difference value represents the dispersion of each sample color in the sample color group. The mean number of samples represents the proportion of the sample color in the sample image in the sample color group.

[0163] S1023: From each color group to be processed, determine the color group with the highest confidence level and use it as the target color group.

[0164] For each color group to be processed, the color difference value of the color group to be processed represents the degree of dispersion of each color to be processed in the color group to be processed; the larger the color difference value of the color group to be processed, the higher the degree of dispersion of each color to be processed in the color group to be processed.

[0165] The average number of colors to be processed in a given color group represents the proportion of that color in the image to be processed. The higher the average number of colors to be processed in a given color group, the higher the proportion of that color in the image to be processed.

[0166] In one implementation, for each color group to be processed, the electronic device calculates the color difference value between every two colors to be processed in the color group to be processed, and calculates the average of each color difference value as the color difference value to be processed for the color group to be processed.

[0167] In another implementation, Figure 3 Based on this, see Figure 4 Step S1021 may include the following steps:

[0168] S10211: For each color group to be processed, according to the order of the first number corresponding to each color to be processed in the color group to be processed from largest to smallest, calculate the color difference value between each two adjacent colors to be processed in the color group to be processed, and use it as the second color difference value; calculate the average value of each second color difference value corresponding to the color group to be processed to obtain the color difference value to be processed corresponding to the color group to be processed.

[0169] S10212: Calculate the average of the first number corresponding to each color to be processed in the color group to be processed, and obtain the average number of colors to be processed corresponding to the color group to be processed.

[0170] For each color group to be processed, the electronic device can calculate the color difference value between each two adjacent colors in the color group to be processed, according to the first number corresponding to each color in the color group to be processed in descending order, and use it as the second color difference value.

[0171] The second color difference value between each pair of adjacent colors to be processed includes: the absolute value of the difference in hue value, the absolute value of the difference in saturation value, and the absolute value of the difference in brightness value between the two adjacent colors to be processed.

[0172] For example, the group of colors to be processed contains four colors to be processed, which are represented by hue value, saturation value and brightness value: the first color to be processed (10, 20, 30), the second color to be processed (5, 20, 15), the third color to be processed (40, 10, 25) and the fourth color to be processed (60, 15, 20).

[0173] The electronic device calculates the second color difference value between the first and second colors to be processed as (5, 0, 15), the second color difference value between the second and third colors to be processed as (35, 10, 10), and the second color difference value between the third and fourth colors to be processed as (20, 5, 5), thus obtaining the three second color difference values ​​corresponding to the group of colors to be processed.

[0174] The electronic device can calculate the average of the second color difference values ​​corresponding to the color group to be processed, and obtain the color difference value to be processed corresponding to the color group to be processed. For example, in the above embodiment, the electronic device calculates the average of the three second color difference values ​​corresponding to the color group to be processed as (20, 5, 10).

[0175] The electronic device can also calculate the average of the first number corresponding to each color to be processed in the color group to be processed, and obtain the average number of colors to be processed corresponding to the color group to be processed.

[0176] Then, the electronic device inputs the color difference value to be processed and the average number of to be processed into the target color prediction model to obtain the confidence of the color group to be processed output by the target color prediction model, which is used as the confidence of to be processed. The confidence of to be processed represents the probability that each color to be processed in the color group to be processed can characterize the overall color features of the image to be processed.

[0177] The target color prediction model can be a neural network model for classification provided by brain.js (brain.JavaScript, the intelligent JavaScript language). brain.js is a library based on JavaScript (a programming language) that contains various neural network models.

[0178] Furthermore, the electronic device can determine the color group with the highest processing confidence from each group of colors to be processed, thus obtaining the target color group. The target color group has the highest processing confidence, indicating that each color in the target color group has the highest probability of representing the overall color features of the image to be processed.

[0179] In step S103, the electronic device can calculate the theme color of the image to be processed based on the pixel values ​​corresponding to each color to be processed in the target color group. The pixel value corresponding to a color to be processed is the pixel value of the pixel to which that color belongs.

[0180] The electronic device can select the color with the largest number in the target color group as the theme color of the image to be processed.

[0181] Alternatively, electronic devices can calculate the average pixel value corresponding to each color to be processed in the target color group to obtain the theme color of the image to be processed.

[0182] Alternatively, electronic devices can calculate the weighted sum of the pixel values ​​corresponding to each color to be processed in the target color group to obtain the theme color of the image to be processed.

[0183] In some embodiments, the electronic device can train a color prediction model of the initial structure to obtain a trained target color prediction model. Accordingly, see [link to relevant documentation]. Figure 5 , Figure 5 A flowchart of a model training method provided in an embodiment of the present invention, the method may include the following steps:

[0184] S501: Based on the color system to which each sample color in the sample image belongs, group the sample colors in the sample image to obtain multiple color groups, which are then used as sample color groups.

[0185] S502: Based on the sample colors in the sample color group, calculate the sample color difference value corresponding to the sample color group, and based on the number of samples corresponding to the sample colors in the sample color group, calculate the mean number of samples corresponding to the sample color group.

[0186] Among them, the sample color difference value represents the dispersion of each sample color in the sample color group; the mean number of samples represents the proportion of the sample color in the sample image in the sample color group; and the number of samples corresponding to a sample color is the number of pixels in the sample image that contain that sample color.

[0187] S503: Obtain the confidence level of the sample color grouping as the sample confidence level.

[0188] The sample confidence score represents the probability that a sample color in a sample color group can characterize the overall color features of the sample image.

[0189] S504: Based on the sample color difference value, the mean number of samples, and the sample confidence level, adjust the model parameters of the initial structure color prediction model until the preset convergence condition is met, and obtain the trained target color prediction model.

[0190] Based on the model training method provided in this invention, a color prediction model of the initial structure can be trained to obtain a target color prediction model. Then, based on the target color prediction model, the theme color of the image can be determined. Subsequently, the colors of other areas in the display interface besides the displayed image can be set to the theme color of the image, so that the colors of other areas in the display interface match the overall color of the displayed image. This allows users to have an immersive experience and improves the user experience when browsing images.

[0191] The sample colors can be all the colors contained in the sample image. Alternatively, to improve the accuracy of the trained target color prediction model, the electronic device can also determine a subset of colors from all the colors contained in the sample image as sample colors. The way the electronic device determines the sample colors in the sample image is similar to the way the electronic device determines the colors to be processed in the image to be processed, and can be referred to the relevant descriptions in the foregoing embodiments.

[0192] The way in which the electronic device groups the sample colors in the sample image is similar to the way the electronic device groups the colors to be processed in the image to be processed, and can be referred to the relevant description in the foregoing embodiments.

[0193] For each sample color group, the electronic device calculates the color difference value between every two adjacent sample colors in the sample color group, arranged in descending order of the number of samples corresponding to each color. Then, the electronic device calculates the average of the color difference values ​​corresponding to the sample color group to obtain the sample color difference value corresponding to the sample color group.

[0194] The way in which the electronic device calculates the color difference value between each two adjacent sample colors in a sample color group is similar to the way in which the electronic device calculates the color difference value between each two adjacent colors to be processed in a color group to be processed. Please refer to the relevant description in the foregoing embodiments.

[0195] For each sample color group, the electronic device calculates the average number of samples corresponding to each sample color in that group, thus obtaining the average number of samples for that sample color group. The number of samples corresponding to a sample color is the number of pixels in the sample image that contain that sample color.

[0196] For each sample color group, the electronic device can also obtain the sample confidence level of that sample color group, which can be pre-determined by the designer based on the theme color of the sample image. For example, if the theme color of the sample image is determined based on the sample colors included in that sample color group, then the sample confidence level of that sample color group is 1; if the theme color of the sample image is not determined based on the sample colors included in that sample color group, then the sample confidence level of that sample color group is 0.

[0197] Then, the electronic device generates training samples containing sample color difference values, sample number mean, and sample confidence, so as to train the color prediction model of the initial structure based on the obtained training samples.

[0198] For example, training samples can be represented as follows, where a represents the sample confidence of the sample color group, b represents the mean number of samples corresponding to the sample color group, and c represents the mean sample color difference value corresponding to the sample color group.

[0199] let info(input data) = {colorCount(color count): a, average(average): b, variance(variance): c;}

[0200] top50Count: 1, top50Average: 40, top50Variance: (25, 30, 20);

[0201] top20Count: 0, top20Average: 20, top20Variance: (20, 25, 20);

[0202] top10Count: 0, top10Average: 20, top10Variance: (15, 15, 10);

[0203] top5Count: 0, top5Average: 30, top5Variance: (3, 1, 10)}.

[0204] The training samples above represent the following: Arranged in descending order of the number of samples corresponding to each color, the sample confidence level for the group containing the first 50 colors is 1, the mean number of samples is 40, and the color difference is (25, 30, 20); the sample confidence level for the group containing the first 20 colors is 0, the mean number of samples is 20, and the color difference is (20, 25, 20); the sample confidence level for the group containing the first 10 colors is 0, the mean number of samples is 20, and the color difference is (15, 15, 10); and the sample confidence level for the group containing the first 5 colors is 0, the mean number of samples is 30, and the color difference is (3, 1, 10).

[0205] The electronic device inputs the sample color difference values ​​and the mean number of samples into the initial structure color prediction model, obtaining the confidence level (which can be called the prediction confidence level) of the sample color grouping output by the initial structure color prediction model. The electronic device calculates the loss function value representing the difference between the sample confidence level and the prediction confidence level, and adjusts the model parameters of the initial structure color prediction model based on the calculated loss function value until a preset convergence condition is reached, resulting in a trained target color prediction model. The learning rate for adjusting the model parameters by the electronic device can be 0.01, or it can be 0.02, etc., but it is not limited to these.

[0206] The preset convergence condition can be that the number of training iterations reaches a preset number, for example, the preset number of iterations can be 2,000,000, or the preset number of iterations can also be 2,500,000, but it is not limited to these. The preset convergence condition can also be that the loss function value obtained by multiple consecutive calculations is less than a third threshold, for example, the third threshold can be 0.005, or the third threshold can also be 0.002, but it is not limited to these.

[0207] In addition, after determining the sample color difference value and the mean number of samples, the electronic device can also normalize the sample color difference value and the mean number of samples respectively. For example, the sample color difference value can be normalized to log10 and the mean number of samples can be normalized to [0, 1] respectively. This can reduce the computational load of the electronic device and improve the efficiency of model training.

[0208] In some embodiments, when the image to be processed is extracted from the original image, after calculating the theme color of the image to be processed, if the electronic device is a client, the electronic device can directly use the theme color of the image to be processed as the theme color of the original image to which the image to be processed belongs, and store the theme color of the original image. Subsequently, when the original image needs to be displayed, the electronic device sets the colors of other areas in the display interface according to the theme color of the original image; for example, it sets the menu bar in the display interface to the theme color of the original image.

[0209] In some embodiments, after step S103, the method may further include the following steps: using the theme color of the image to be processed as the theme color of the original image, and storing the theme color of the original image.

[0210] If the electronic device acts as a server, after calculating the theme color of the image to be processed, it can use that theme color as the theme color of the original image and store it. Subsequently, when the electronic device receives a request from a client to retrieve the original image, it can send the original image and its theme color to the client. Correspondingly, the client can display the target image on its screen and set the colors of all other areas of the screen except the target image to the target image's theme color, thus improving the user experience when browsing images.

[0211] See Figure 6 , Figure 6 A flowchart of an image display method provided in an embodiment of the present invention, the method being applied to a server, and the method may include the following steps:

[0212] S601: Receives a request from the client to retrieve the target image.

[0213] S602: Obtain the target image and the theme color of the target image.

[0214] The theme color of the target image is obtained by the server based on the theme color determination method in the aforementioned embodiments.

[0215] S603: Send the target image and the theme color of the target image to the client so that after receiving the target image and the theme color of the target image, the client displays the target image in the client's display interface and sets the color of other areas in the display interface except for the target image to the theme color of the target image.

[0216] Based on the image display method provided in this embodiment of the invention, the client can set the color of other areas in the display interface besides the displayed image to the theme color of the image, so that the color of other areas in the display interface matches the overall color of the displayed image, thereby enabling users to have an immersive experience and improving the user experience of browsing images.

[0217] When a client needs to display a target image, it can send a request to the server to retrieve the target image. Upon receiving this request, the server can determine if it has the target image's theme color stored locally. If it does, the server sends the target image and its theme color to the client.

[0218] If the theme color of the target image is not stored, the server determines the theme color of the target image according to the theme color determination method provided in this embodiment of the invention, and sends the target image and the theme color of the target image to the client.

[0219] Correspondingly, when the client displays the received target image in the display interface, it can set other areas of the display interface besides the target image (e.g., the menu bar) to the theme color of the target image.

[0220] For example, the server can record the URL (Universal Resource Locator) and theme color of each image. The image URL represents the address where the image can be retrieved. When a request to retrieve the target image indicated by that URL is received, the server determines whether to store the theme color corresponding to that URL.

[0221] If the theme color corresponding to the URL is stored, the server retrieves the target image indicated by the URL and the theme color corresponding to the URL, thus obtaining the theme color of the target image. Subsequently, the server sends the target image and the theme color of the target image to the client.

[0222] If the theme color of the target image indicated by the URL is not stored, the server obtains the target image indicated by the URL and determines the theme color of the target image according to the theme color determination method provided in the embodiments of the present invention. Then, the server sends the target image and the theme color of the target image to the client.

[0223] In some embodiments, an electronic device may start two processes, which may be referred to as a first process and a second process, respectively, and the first process and the second process may communicate with each other.

[0224] The first process can determine the color to be processed from the colors contained in the image to be processed, group these colors, obtain the corresponding groups of colors to be processed for the image, and send the grouping results to the second process. The second process can calculate the confidence level of each group of colors to be processed for the image and send the confidence level of each group to the first process. The first process can then determine the theme color of the image to be processed based on the confidence levels of each group of colors to be processed.

[0225] See Figure 7 , Figure 7 This is a flowchart illustrating an image display method provided in an embodiment of the present invention. The method is applied to an image display system, which includes a client and a server.

[0226] When a client needs to display a target image, it can request the service from the server. In other words, the client sends a request to the server to retrieve the target image based on its URL.

[0227] When the server receives the retrieval request, it verifies the URL, meaning the server retrieves the target image according to that URL. The server can also use a color-picking module to determine if the color value corresponding to the target image is cached in the cache dictionary. This color value is the theme color of the target image in the aforementioned embodiment. If the theme color of the target image is cached in the cache dictionary, the server can retrieve it from the cache dictionary using the color-picking module; that is, the server obtains the cached theme color of the target image through the color-picking module. The cache dictionary is used to store the mapping between the theme color of an image and the image's URL.

[0228] If the theme color of the target image is not cached, the server can extract the image colors using a color picking module. This means the server extracts the colors to be processed from the target image using the color picking module and determines the colors contained within that image. Then, the server performs numerical processing using the color picking module. Specifically, the server filters out brighter, darker, and less prominent colors from the image to obtain the colors to be processed. Based on these colors, the server determines the theme color of the image to be processed, which is then used as the theme color of the target image.

[0229] After obtaining the result, the server can concatenate the color value with other data. That is, after obtaining the theme color of the target image, the server concatenates the theme color with the target image to obtain the result corresponding to the request. Then, the server can return the result to the client, sending the target image and its theme color. Correspondingly, when displaying the target image, the client can set the colors of other areas of the display interface according to the theme color of the target image.

[0230] Based on the above processing, colors in the image to be processed can be filtered according to various filtering conditions. For example, colors with a small proportion, bright colors, and dark colors can be filtered out, improving the accuracy of the determined theme color. Furthermore, the theme color determination method provided in this embodiment of the invention has a wide coverage. This method can be deployed on a server, directly determining the theme color of the image. The server can communicate with various different clients, such as clients using Android systems, clients using iOS systems, and web clients. The server can directly provide the theme color of the requested image to various clients.

[0231] and Figure 1 For the corresponding method implementation examples, see [link to relevant documentation]. Figure 8 , Figure 8 This is a structural diagram of a theme color determination device provided in an embodiment of the present invention. The device includes:

[0232] The color grouping module 801 is used to group the colors in the image to be processed according to the color system to which each color belongs, and obtain multiple color groups as the color groups to be processed.

[0233] The target color grouping determination module 802 is used to determine the target color group from each color group to be processed based on a first number corresponding to each color to be processed in each color group to be processed; wherein, the first number corresponding to a color to be processed is: the number of pixels in the image to be processed that contain the color to be processed;

[0234] The theme color determination module 803 is used to calculate the theme color of the image to be processed based on the pixel values ​​corresponding to each color to be processed in the target color group.

[0235] Optionally, the color grouping module 801 is specifically used to cluster each color to be processed based on the color system to which each color to be processed belongs in the image to be processed, to obtain multiple color groups as color groups to be processed; wherein, the first color difference value between the cluster centers of any two color groups to be processed is greater than a first threshold; the first color difference value between each color to be processed and the cluster center of its respective color group to be processed is less than the first color difference value between the color to be processed and the cluster centers of other color groups to be processed.

[0236] Optionally, the device further includes:

[0237] The color determination module is used to group the colors to be processed in the image according to the color system to which each color belongs, and obtain multiple color groups before the color grouping module 801 performs the operation of determining the first second number of colors from the colors contained in the image to be processed, according to the first number of each color to be processed in the image in descending order, as the colors to be processed.

[0238] Optionally, the target color grouping determination module 802 is specifically used to, for each color group to be processed, calculate the color difference value corresponding to the color group to be processed based on each color to be processed in the color group to be processed, and calculate the average number of colors to be processed corresponding to the color group to be processed based on a first number corresponding to each color to be processed in the color group to be processed; wherein, the color difference value represents the dispersion of each color to be processed in the color group to be processed; the average number of colors to be processed represents the proportion of each color to be processed in the color group to be processed in the image to be processed;

[0239] The color difference value to be processed and the mean number of samples to be processed are input into a pre-trained target color prediction model to obtain the confidence score of the color group to be processed output by the target color prediction model, which is used as the confidence score of the sample group to be processed. The target color prediction model is trained based on the sample color difference value, the mean number of samples, and the sample confidence score of the sample color group. The sample color group is obtained by grouping the sample colors in the sample image. The sample color difference value represents the dispersion of each sample color in the sample color group; the mean number of samples represents the proportion of the sample colors in the sample color group in the sample image.

[0240] From each color group to be processed, determine the color group with the highest confidence level and use it as the target color group.

[0241] Optionally, the target color group determination module 802 is specifically used to, for each color group to be processed, calculate the color difference value between each two adjacent colors in the color group to be processed, according to the first number of each color to be processed in the color group to be processed arranged in descending order, as a second color difference value; calculate the average value of each second color difference value corresponding to the color group to be processed to obtain the color difference value to be processed corresponding to the color group to be processed.

[0242] Calculate the average of the first number corresponding to each color in the color group to be processed, and obtain the average number of colors to be processed corresponding to the color group to be processed.

[0243] Optionally, the device further includes:

[0244] The color determination module is used to group the colors to be processed in the image to be processed according to the color system to which each color belongs, and obtain multiple color groups before the color grouping module 801 performs the following steps: for each pixel in the image to be processed, if the brightness value of the color of the pixel belongs to a first preset brightness range, the color of the pixel is determined as a candidate color; and the color to be processed is determined from each candidate color.

[0245] or,

[0246] For each pixel in the image to be processed, if the brightness value of the pixel's color belongs to a second preset brightness range and the saturation value of the color does not belong to a preset saturation range, the color of the pixel is determined as a candidate color; from each candidate color, the color to be processed is determined; wherein, the second preset brightness range belongs to the first preset brightness range.

[0247] Optionally, the color determination module is specifically used to determine, from each candidate color, a candidate color whose first number is greater than a second threshold, as the color to be processed; wherein, the first number corresponding to a candidate color is: the number of pixels in the image to be processed containing that candidate color.

[0248] Optionally, the device further includes:

[0249] The image to be processed acquisition module is used to perform the following steps in the color grouping module 801: group the colors to be processed in the image to be processed according to the color system to which each color to be processed belongs, and obtain multiple color groups. Before the color grouping is performed, the original image is acquired and the image area other than the specified object in the original image is extracted to obtain the image to be processed.

[0250] The brightness value determination module is used to calculate the brightness value and saturation value of the color of each pixel in the image to be processed, based on the pixel value of that pixel.

[0251] Optionally, the device further includes:

[0252] The theme color storage module is used to, after the theme color determination module 803 calculates the theme color of the image to be processed based on the pixel values ​​corresponding to each color to be processed in the target color group, use the theme color of the image to be processed as the theme color of the original image and store the theme color of the original image.

[0253] Based on the theme color determination device provided in this embodiment of the invention, the theme color of the image to be processed can be determined. Furthermore, the theme color of the image to be processed can be determined based on the number of pixels containing the color to be processed, that is, based on the proportion of the color to be processed in the image, thus improving the accuracy of the determined theme color. Subsequently, the colors of other areas in the display interface besides the displayed image can be set as the theme color of the image, making the colors of other areas in the display interface match the overall color of the displayed image. This allows users to obtain an immersive experience and improves the user experience when browsing images.

[0254] and Figure 6 For the corresponding method implementation examples, see [link to relevant documentation]. Figure 9 , Figure 9 This is a structural diagram of an image display device provided in an embodiment of the present invention. The device is applied to a server and includes:

[0255] The request receiving module 901 is used to receive the request sent by the client for the target image;

[0256] Theme color acquisition module 902 is used to acquire the target image and the theme color of the target image; wherein, the theme color of the target image is obtained by the server based on any of the theme color determination methods described in the first aspect above;

[0257] The theme color sending module 903 is used to send the target image and the theme color of the target image to the client, so that after the client receives the target image and the theme color of the target image, it displays the target image in the client's display interface and sets the color of other areas in the display interface except for the target image to the theme color of the target image.

[0258] Based on the image display device provided in this embodiment of the invention, the client can set the color of other areas in the display interface besides the displayed image to the theme color of the image, so that the color of other areas in the display interface matches the overall color of the displayed image, thereby enabling the user to obtain an immersive experience and improving the user experience of browsing images.

[0259] and Figure 5 For the corresponding method implementation examples, see [link to relevant documentation]. Figure 10 , Figure 10 This is a structural diagram of a model training device provided in an embodiment of the present invention. The device includes:

[0260] The sample color grouping module 1001 is used to group the sample colors contained in the sample image according to the color system to which each sample color belongs, and obtain multiple color groups as sample color groups.

[0261] The sample color difference value determination module 1002 is used to calculate the sample color difference value corresponding to the sample color group based on each sample color in the sample color group, and to calculate the average number of samples corresponding to the sample color group based on the number of samples corresponding to the sample colors in the sample color group; wherein, the sample color difference value represents the dispersion of each sample color in the sample color group; the average number of samples represents the proportion of the sample colors in the sample color group in the sample image; and the number of samples corresponding to a sample color is the number of pixels in the sample image containing that sample color.

[0262] The sample confidence acquisition module 1003 is used to acquire the confidence of the sample color group as the sample confidence; wherein, the sample confidence represents the probability that the sample color in the sample color group can characterize the overall color features of the sample image;

[0263] The model parameter adjustment module 1004 is used to adjust the model parameters of the initial structure color prediction model based on the sample color difference value, the mean number of samples, and the sample confidence level, until the preset convergence condition is reached, so as to obtain the trained target color prediction model.

[0264] Based on the model training apparatus provided in this embodiment of the invention, a color prediction model of the initial structure can be trained to obtain a target color prediction model. Then, based on the target color prediction model, the theme color of the image can be determined. Subsequently, the colors of other areas in the display interface besides the displayed image can be set to the theme color of the image, so that the colors of other areas in the display interface match the overall color of the displayed image. This allows users to have an immersive experience and improves the user experience when browsing images.

[0265] This invention also provides an electronic device, such as... Figure 11 As shown, it includes a processor 1101, a communication interface 1102, a memory 1103 and a communication bus 1104, wherein the processor 1101, the communication interface 1102 and the memory 1103 communicate with each other through the communication bus 1104.

[0266] Memory 1103 is used to store computer programs;

[0267] When the processor 1101 executes the program stored in the memory 1103, it implements the theme color determination method step, the image display method step, or the model training method step described in any of the above embodiments.

[0268] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not indicate that there is only one bus or one type of bus.

[0269] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0270] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0271] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0272] In another embodiment of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, it implements any of the theme color determination methods, any of the image display methods, or any of the model training methods described in the above embodiments.

[0273] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the theme color determination methods described in the above embodiments, or any of the image display methods described in the above embodiments, or any of the model training methods described in the above embodiments.

[0274] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).

[0275] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0276] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of apparatus, electronic devices, computer-readable storage media, and computer program products are basically similar to the method embodiments, and therefore the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0277] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A dominant color determination method, characterized by, The method comprises: grouping each to-be-processed color in a to-be-processed picture according to a color system to which each to-be-processed color contained in the to-be-processed picture belongs, to obtain a plurality of color groups as to-be-processed color groups; determining a target color group from each to-be-processed color group based on a first number corresponding to each to-be-processed color in the to-be-processed color group; wherein the first number corresponding to one to-be-processed color is the number of pixel points in the to-be-processed picture containing the to-be-processed color; calculating a theme color of the to-be-processed picture according to pixel values corresponding to each to-be-processed color in the target color group; determining the target color group from each to-be-processed color group based on the first number corresponding to each to-be-processed color in the to-be-processed color group, comprises: for each to-be-processed color group, calculating a to-be-processed color difference value corresponding to the to-be-processed color group based on each to-be-processed color in the to-be-processed color group, and calculating a to-be-processed number average value corresponding to the to-be-processed color group based on the first number corresponding to each to-be-processed color in the to-be-processed color group; wherein the to-be-processed color difference value represents the dispersion degree of each to-be-processed color in the to-be-processed color group; and the to-be-processed number average value represents the proportion of to-be-processed colors in the to-be-processed color group in the to-be-processed picture; inputting the to-be-processed color difference value and the to-be-processed number average value into a pre-trained target color prediction model to obtain a confidence of the to-be-processed color group output by the target color prediction model as a to-be-processed confidence; wherein the target color prediction model is obtained by training based on a sample color difference value, a sample number average value and a sample confidence of a sample color group; the sample color group is obtained by grouping sample colors in a sample picture; the sample color difference value represents the dispersion degree of each sample color in the sample color group; and the sample number average value represents the proportion of sample colors in the sample color group in the sample picture; determining, from each to-be-processed color group, a color group with the maximum to-be-processed confidence as the target color group.

2. The method of claim 1, wherein, The grouping each to-be-processed color in a to-be-processed picture according to a color system to which each to-be-processed color contained in the to-be-processed picture belongs, to obtain a plurality of color groups as to-be-processed color groups, comprises: clustering each to-be-processed color based on a color system to which each to-be-processed color in a to-be-processed picture belongs, to obtain a plurality of color groups as to-be-processed color groups; wherein a first color difference value between clustering centers of each two to-be-processed color groups is greater than a first threshold value; and a first color difference value between each to-be-processed color and a clustering center of a to-be-processed color group to which the to-be-processed color belongs is less than a first color difference value between the to-be-processed color and a clustering center of another to-be-processed color group.

3. The method of claim 2, wherein, Before the grouping each to-be-processed color in a to-be-processed picture according to a color system to which each to-be-processed color contained in the to-be-processed picture belongs, to obtain a plurality of color groups as to-be-processed color groups, the method further comprises: Determine, from colors contained in the to-be-processed picture, a first quantity of colors as to-be-processed colors according to a descending order of the first quantity corresponding to each to-be-processed color in the to-be-processed picture.

4. The method of claim 1, wherein, The method further includes: For each to-be-processed color group, calculate a color difference value between each adjacent two to-be-processed colors in the to-be-processed color group as a second color difference value according to a descending order of the first quantity corresponding to each to-be-processed color in the to-be-processed color group; and calculate an average value of each second color difference value corresponding to the to-be-processed color group to obtain the to-be-processed color difference value corresponding to the to-be-processed color group. Calculate an average value of the first quantity corresponding to each to-be-processed color in the to-be-processed color group to obtain the to-be-processed quantity average value corresponding to the to-be-processed color group.

5. The method of claim 1, wherein, Before the grouping of the to-be-processed colors in the to-be-processed picture according to the color families to which the to-be-processed colors belong, the method further includes: For each pixel point in the to-be-processed picture, if the luminance value of the color of the pixel point belongs to a first preset luminance interval, determine the color of the pixel point as a candidate color; and determine the to-be-processed colors from the candidate colors. Or, For each pixel point in the to-be-processed picture, if the luminance value of the color of the pixel point belongs to a second preset luminance interval and the saturation value of the color does not belong to a preset saturation interval, determine the color of the pixel point as a candidate color; and determine the to-be-processed colors from the candidate colors; wherein the second preset luminance interval belongs to the first preset luminance interval.

6. The method of claim 5, wherein, The method further includes: Determine, from the candidate colors, a candidate color with a first quantity greater than a second threshold value as a to-be-processed color; wherein the first quantity corresponding to a candidate color is the number of pixel points in the to-be-processed picture containing the candidate color.

7. The method of claim 5, wherein, Before the grouping of the to-be-processed colors in the to-be-processed picture according to the color families to which the to-be-processed colors belong, the method further includes: Obtain an original picture and extract an image region other than a specified object in the original picture to obtain a to-be-processed picture; For each pixel point in the to-be-processed picture, calculate the luminance value and the saturation value of the color of the pixel point based on the pixel value of the pixel point.

8. The method of claim 7, wherein, After the calculation of the theme color of the to-be-processed picture according to the pixel value corresponding to each to-be-processed color in the target color group, the method further includes: Take the theme color of the to-be-processed picture as the theme color of the original picture, and store the theme color of the original picture.

9. A picture display method characterized by, The method is applied to a server, and the method includes: receiving a request for a target picture sent by a client; obtaining the target picture and a theme color of the target picture, wherein the theme color of the target picture is obtained based on the theme color determination method in any one of claims 1 to 8; sending the target picture and the theme color of the target picture to the client, so that the client displays the target picture in a display interface of the client and sets a color of an area other than the target picture in the display interface to the theme color of the target picture after receiving the target picture and the theme color of the target picture.

10. A model training method, comprising: The method comprises: grouping sample colors contained in a sample picture according to color families to which the sample colors belong, to obtain a plurality of color groups as sample color groups; calculating a sample color difference value corresponding to each sample color group based on sample colors in the sample color group, and calculating a sample number average value corresponding to the sample color group based on a sample number corresponding to the sample colors in the sample color group; wherein the sample color difference value represents a dispersion degree of each sample color in the sample color group; the sample number average value represents a proportion of the sample colors in the sample picture; and a sample number corresponding to a sample color is a number of pixel points containing the sample color in the sample picture; obtaining a confidence degree of the sample color group as a sample confidence degree; wherein the sample confidence degree represents a probability that the sample colors in the sample color group can represent overall color features of the sample picture; adjusting model parameters of an initial structure color prediction model based on the sample color difference value, the sample number average value and the sample confidence degree until a preset convergence condition is reached, to obtain a trained target color prediction model.

11. A dominant color determination apparatus characterized by comprising: The device comprises: a to-be-processed color grouping module configured to group each to-be-processed color in a to-be-processed picture according to a color family to which each to-be-processed color belongs, to obtain a plurality of color groups as to-be-processed color groups; a target color group determination module configured to determine a target color group from each to-be-processed color group based on a first number corresponding to each to-be-processed color in each to-be-processed color group; wherein the first number corresponding to a to-be-processed color is a number of pixel points containing the to-be-processed color in the to-be-processed picture; a theme color determination module configured to calculate a theme color of the to-be-processed picture according to pixel values corresponding to each to-be-processed color in the target color group; the target color group determination module is specifically configured to: For each to-be-processed color group, a to-be-processed color difference value corresponding to the to-be-processed color group is calculated based on each to-be-processed color in the to-be-processed color group, and a to-be-processed number average corresponding to the to-be-processed color group is calculated based on a first number corresponding to each to-be-processed color in the to-be-processed color group; wherein the to-be-processed color difference value represents a dispersion degree of each to-be-processed color in the to-be-processed color group; and the to-be-processed number average represents a proportion of to-be-processed colors in the to-be-processed color group in the to-be-processed picture; The to-be-processed color difference value and the to-be-processed number average are input into a pre-trained target color prediction model to obtain a confidence of the to-be-processed color group output by the target color prediction model as a to-be-processed confidence; wherein the target color prediction model is obtained by training based on a sample color difference value, a sample number average and a sample confidence of a sample color group; the sample color group is obtained by grouping sample colors in a sample picture; the sample color difference value represents a dispersion degree of each sample color in the sample color group; and the sample number average represents a proportion of sample colors in the sample color group in the sample picture; A color group with a maximum to-be-processed confidence is determined from each to-be-processed color group as a target color group.

12. A picture display device, characterized by comprising: The device is applied to a server, and the device comprises: a request receiving module configured to receive an acquisition request for a target picture sent by a client; a theme color obtaining module configured to obtain the target picture and a theme color of the target picture; wherein the theme color of the target picture is obtained by the server based on the theme color determination method in any one of claims 1 to 8; a theme color sending module configured to send the target picture and the theme color of the target picture to the client, so that the client displays the target picture in a display interface of the client and sets a color of an area other than the target picture in the display interface to the theme color of the target picture after receiving the target picture and the theme color of the target picture.

13. A model training apparatus, comprising: The device comprises: a sample color grouping module configured to group sample colors contained in a sample picture according to color families to which the sample colors belong, to obtain a plurality of color groups as sample color groups; a sample color difference value determining module configured to calculate a sample color difference value corresponding to a sample color group based on each sample color in the sample color group, and calculate a sample number average corresponding to the sample color group based on a sample number corresponding to each sample color in the sample color group; wherein the sample color difference value represents a dispersion degree of each sample color in the sample color group; and the sample number average represents a proportion of sample colors in the sample color group in the sample picture; and a sample number corresponding to a sample color is a number of pixel points containing the sample color in the sample picture. A sample confidence obtaining module is configured to obtain a confidence of the sample color group as a sample confidence, wherein the sample confidence represents a probability that a sample color in the sample color group can represent an overall color feature of the sample picture. A model parameter adjusting module is configured to adjust model parameters of an initial structure of a color prediction model based on the sample color difference value, the sample number mean value and the sample confidence until a preset convergence condition is reached to obtain a trained target color prediction model.

14. An electronic device, comprising: The device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus. The memory is configured to store a computer program. The processor is configured to execute the program stored in the memory to implement the method steps in any one of claims 1-8, or claim 9, or claim 10.

15. A computer-readable storage medium, characterized in that, The computer program is stored in the computer readable storage medium, and the computer program is executed by the processor to implement the method steps in any one of claims 1-8, or claim 9, or claim 10.

Citation Information

Patent Citations

  • Image theme color extraction method and device and electronic equipment

    CN110969170A

  • Image color extraction method and device, electronic equipment and storage medium

    CN114120002A