Image color extraction method, device, electronic device and storage medium
By determining multiple candidate color systems of the target image in image color extraction and selecting a color system with a large area as the theme color, the problem of low accuracy in extracting theme colors in the prior art is solved, and the immersion and user experience of the page are improved.
Patent Information
- Application Number
- CN202111249159.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-26
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2041-10-26
AI Technical Summary
The calculation method of extracting the theme colors of the image in the prior art is single, and the overall presentation effect of the image is not taken into account, resulting in the accuracy of the extracted theme colors, which cannot accurately express the color of the image, thereby affecting the immersion of the page.
By determining the multiple candidate color systems to which the multiple target colors in the target image belong, and selecting the target candidate color system with a larger area as the theme color, it is ensured that the theme color can more accurately express the overall color of the image.
It improves the accuracy of image color extraction, making the page immersion based on theme color rendering better, meeting users' visual needs and improving user experience.
Smart Images

Figure CN114120002B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to an image color extraction method, device, electronic device and storage medium. Background Art
[0002] When displaying a page, the client usually extracts the theme color that can represent the theme image of the page, and renders the page using the theme color to increase the immersion of the entire page, thereby meeting the user's visual needs and improving the user's experience.
[0003] In the related art, the general solution for extracting theme colors is: the client processes the theme image, enumerates each pixel line by line, calculates the area ratio of each color in the theme image, and determines the color with the highest area ratio as the theme color. This method of extracting theme colors has a single calculation method and does not consider the overall presentation effect of the theme image. The accuracy of the extracted theme colors is low, and there is a situation where the color of the theme image cannot be accurately expressed, resulting in a poor sense of immersion in pages rendered based on theme colors. Summary of the invention
[0004] The present disclosure provides an image color extraction method, device, electronic device and storage system to at least solve the problem that the calculation method in the related art is single, the overall presentation effect of the theme image is not considered, the accuracy of the extracted theme color is low, and the color of the theme image cannot be accurately expressed, resulting in a poor immersion of the page rendered based on the theme color. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, there is provided an image color extraction method, comprising: determining a plurality of candidate color systems to which a plurality of target colors in a target image belong; the area proportion of each target color in the target image is greater than the area proportion of other colors other than the target color in the target image; determining at least one target candidate color system from the plurality of candidate color systems; wherein the area proportion of each target candidate color system in the target image is greater than the area proportion of other candidate color systems other than the target candidate color system in the target image; and determining a color in any one of the target candidate color systems as the theme color of the target image.
[0006] In a possible implementation, the method further includes: acquiring each color in the target image; deleting at least the color of each color whose area in the target image is less than a first preset threshold to obtain multiple candidate colors; and determining the multiple target colors from the multiple candidate colors.
[0007] In another possible implementation, at least deleting the colors among each color whose area ratio in the target image is less than a first preset threshold to obtain a plurality of candidate colors comprises: deleting the colors among each color whose area ratio in the target image is less than a first preset threshold, and at least one of black, white and gray to obtain the plurality of candidate colors.
[0008] In another possible implementation, at least deleting the colors in each of the colors whose area ratio in the target image is less than a first preset threshold to obtain a plurality of candidate colors comprises: deleting the colors in each of the colors whose area ratio in the target image is less than a first preset threshold, and, when each of the colors includes a first color, performing at least one replacement step to obtain the plurality of candidate colors; wherein the replacement step comprises: replacing the first color with a first preset color.
[0009] In another possible implementation, after determining a color in any one of the target candidate color systems as the theme color of the target image, the method further includes: when the theme color is other colors other than black, white and gray, adjusting the brightness value and saturation value of the theme color to corresponding preset ranges respectively; when the theme color is black, adjusting the hue value of the theme color to reach a second preset threshold; when the theme color is a second color, replacing the second color with a second preset color.
[0010] In another possible implementation, the method further includes: receiving a theme color extraction request sent by a client, the theme color extraction request being used to request acquisition of the theme color of the target image; and sending an RGB value corresponding to the theme color so that the client can render the page where the target image is located according to the RGB value.
[0011] According to a second aspect of an embodiment of the present disclosure, an image color extraction device is provided, comprising: a determination module, configured to determine multiple candidate color systems to which multiple target colors in a target image belong; the area proportion of each target color in the target image is greater than the area proportion of other colors other than the target color in the target image; a matching module, configured to determine at least one target candidate color system from the multiple candidate color systems; wherein the area proportion of each target candidate color system in the target image is greater than the area proportion of other candidate color systems other than the target candidate color system in the target image; and an extraction module, configured to determine a color in any target candidate color system as a theme color of the target image.
[0012] In a possible embodiment, the device also includes: an acquisition module, configured to execute: acquiring each color in the target image; deleting at least the color of each color whose area in the target image is less than a first preset threshold to obtain multiple candidate colors; and determining the multiple target colors from the multiple candidate colors.
[0013] In another possible implementation, the acquisition module is specifically configured to execute: deleting the color whose area in the target image is less than a first preset threshold, and at least one of black, white and gray, to obtain the multiple candidate colors.
[0014] In another possible implementation, the acquisition module is specifically configured to execute: deleting the colors in each color whose area ratio in the target image is less than a first preset threshold, and when each color includes the first color, executing at least one replacement step to obtain the multiple candidate colors; wherein the replacement step includes: replacing the first color with a first preset color.
[0015] In another possible implementation, the device further includes an adjustment module configured to execute: when the theme color is other colors other than black, white and gray, respectively adjusting the brightness value and saturation value of the theme color to corresponding preset ranges; when the theme color is black, adjusting the hue value of the theme color to reach a second preset threshold; when the theme color is a second color, replacing the second color with a second preset color.
[0016] In another possible implementation, the device also includes a receiving module configured to execute: receiving a theme color extraction request sent by a client, the theme color extraction request being used to request acquisition of the theme color of the target image; and sending an RGB value corresponding to the theme color so that the client can render the page where the target image is located according to the RGB value.
[0017] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor executable instructions; wherein the processor is configured to execute instructions to implement the image color extraction method of the above-mentioned first aspect and any possible implementation manner thereof.
[0018] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the image color extraction method in the above-mentioned first aspect and any possible implementation manner thereof.
[0019] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided. The computer program product includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the image color extraction method of the first aspect and any possible implementation manner thereof.
[0020] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects: by first determining the target candidate color system with a relatively large area ratio on the target image in the process of determining the theme color, and then determining the theme color based on any target candidate color system, the overall color presentation effect of the target image is taken into consideration when determining the theme color, and the target candidate color system with a relatively large area ratio is determined as the theme color, thereby more accurately expressing the color of the target image, improving the immersion of the page rendered based on the theme color, and then meeting the visual needs of the user and improving the user's experience. In addition, compared with the prior art of directly determining the color with the highest area ratio as the theme color, it can also avoid filtering out the same color system colors with adjacent hue values and low area ratio in the target image, resulting in the filtering out of the color system with a relatively large area ratio, so that the color system to which the finally selected theme color belongs has a relatively low area ratio on the target image and cannot accurately express the color of the target image.
[0021] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0023] Figure 1 is a flow chart of a method for extracting image color according to an exemplary embodiment;
[0024] Figure 2 is a flow chart of another method for extracting color from an image according to an exemplary embodiment;
[0025] Figure 3 is a flow chart of another method for extracting color from an image according to an exemplary embodiment;
[0026] Figure 4 is a block diagram of an image color extraction device according to an exemplary embodiment;
[0027] Figure 5 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0028] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0030] Before a detailed introduction to the image color extraction method provided by the present invention, a brief introduction to the application scenarios, implementation environment and related elements involved in the present invention is first given.
[0031] First, the application scenarios involved in the present disclosure are briefly introduced.
[0032] With the continuous improvement of material and spiritual life, rich, youthful, personalized, and immersive colors have gradually become the mainstream of page design. In order to meet the visual needs of users and enhance the user product experience, designers need to extract a certain color from an image on the page for page rendering to enhance the immersion of the entire page. This color that can represent the tone and atmosphere of the entire image is called the image theme color, which can achieve the effect of "thousands of pages, thousands of faces" to a certain extent.
[0033] In the prior art, the general solution for extracting theme colors is: the client processes the theme image, enumerates each pixel line by line, calculates the area ratio of each color in the theme image, and determines the color with the highest area ratio as the theme color. This method of extracting theme colors has a single calculation method and does not consider the overall presentation effect of the theme image. The accuracy of the extracted theme colors is low, and there is a situation where the color of the theme image cannot be accurately expressed, resulting in a poor sense of immersion in pages rendered based on theme colors.
[0034] In addition, the prior art solutions are also easily affected by similar colors when determining the theme color. Among them, similar colors refer to colors with the same hue properties but different hue values, that is, colors within a 15° angle on the color wheel corresponding to the 24-color system.
[0035] Specifically, if the subject image includes 5 colors, namely color A, color B, color C, color D and color E. Among them, the area of color A accounts for 10%, the area of color B accounts for 15%, the area of color C accounts for 20%, the area of color D accounts for 25%, and the area of color E accounts for 30%. When colors A, B and C belong to the first color system of the 24 color systems, that is, the color system corresponding to 0°-15° on the color wheel, color D belongs to the fifth color system of the 24 color systems, that is, the color system corresponding to 60°-75° on the color wheel, and color E belongs to the twelfth color system of the 24 color systems, that is, the color system corresponding to 165°-180° on the color wheel.
[0036] At this time, if the theme color is determined based on the method of the prior art, color E will be determined as the theme color due to the influence of the similar colors composed of color A, color B and color C. However, the twelfth color system to which color E belongs accounts for 30% of the area on the target image, and the first color system to which color A, color B and color C belong accounts for 45% of the area on the target image, and the first color system and the twelfth color system are complementary colors on the color wheel, with strong color contrast. Obviously, the theme color selected in the prior art, that is, color E, cannot accurately express the color of the theme image.
[0037] In response to the above problems, the present disclosure provides an image color extraction method, which first determines the target candidate color system with a relatively large area ratio on the target image in the process of determining the theme color, and then determines the theme color based on any target candidate color system, so as to take into account the overall color presentation effect of the target image when determining the theme color, and determine the target candidate color system with a relatively large area ratio as the theme color, thereby more accurately expressing the color of the target image, improving the immersion of the page rendered based on the theme color, and then meeting the visual needs of the user and improving the user's experience. In addition, compared with the prior art of directly determining the color with the highest area ratio as the theme color, it can also avoid filtering out the same color system colors with adjacent hue values and low area ratio in the target image, resulting in the filtering out of the color system with a relatively large area ratio, so that the color system to which the finally selected theme color belongs has a low area ratio on the target image and cannot accurately express the color of the target image.
[0038] Next, the implementation environment (implementation architecture) involved in the present disclosure is briefly introduced below.
[0039] The image color extraction method provided in the embodiment of the present disclosure can be applied to electronic devices. The electronic device can be a terminal device or a server. The terminal device can be a smart phone, a tablet computer, a handheld computer, a vehicle terminal, a desktop computer, and a laptop computer. The server can be any server or server cluster, which is not limited in the present disclosure.
[0040] Again, in order to facilitate the understanding of this application, the relevant elements involved in this application are described.
[0041] HSB, also known as HSV, represents a color mode. In HSB mode, H (hues) represents hue, S (saturation) represents saturation, and B (brightness) represents brightness.
[0042] RGB represents a color mode, which is obtained by changing the three color channels of red (R), green (G), and blue (B) and superimposing them on each other to obtain various colors. RGB represents the colors of the three channels of red, green, and blue, and the RGB value represents the color values of the three channels of red, green, and blue. Among them, the value ranges of R, G, and B in the RGB value are all 0 to 255, and the values of R, G, and B are represented by the numbers 0, 1, 2, ..., 255. For ease of understanding, the task processing method provided by the present disclosure is specifically introduced below in conjunction with the accompanying drawings.
[0043] Figure 1 FIG. 1 is a flowchart of a method for extracting color from an image according to an exemplary embodiment, and the method is used in an electronic device. Figure 1 As shown, the image color extraction method includes the following steps.
[0044] In S101 , a plurality of candidate color systems to which a plurality of target colors in a target image belong are determined.
[0045] The area proportion of each target color in the target image is greater than the area proportion of other colors other than the target color in the target image.
[0046] Optionally, the area ratio of each target color in the target image can be determined based on the pixel ratio of each target color. The pixel ratio of each color in the target image refers to the percentage of the number of pixels of each color in the number of pixels of the target image. It should be noted that other colors other than the target color refer to other colors before the target color included in the target image.
[0047] In one embodiment, the multiple target colors are all colors in the target image. By dividing all colors in the target image into color systems, multiple candidate color systems are obtained for extracting the theme color, which can ensure the integrity of the candidate color system to which the colors in the target image belong, thereby improving the accuracy of determining the theme color.
[0048] In another embodiment, the multiple target colors are partial colors in the target image. By screening all colors in the target image and dividing only partial colors in the target image into color systems, multiple candidate color systems are obtained for extracting the theme color, which greatly reduces the amount of calculation, improves the speed of extracting the theme color, and further improves the response speed of page display.
[0049] Optionally, the target image can be acquired by the electronic device from the page to be rendered.
[0050] In one embodiment, a target page on an electronic device needs to be rendered, and a target image is configured on the target page. The electronic device obtains the target image and determines a plurality of candidate color systems to which a plurality of target colors in the target image belong.
[0051] Optionally, the target image may be sent to the electronic device by a client of the page to be rendered.
[0052] In one embodiment, a target page on a client needs to be rendered, and a target image is configured on the target page. Before rendering the target page, the client sends a theme color extraction request to the electronic device, and the theme color extraction request includes the target image. After receiving the theme color extraction request, the electronic device determines multiple candidate color systems to which multiple target colors in the target image belong.
[0053] Optionally, after obtaining the target image, the electronic device first obtains each color of the target image, and determines the color that meets the conditions among each color as the target color. For example, the color whose ranking of area proportion on the target image is greater than or equal to 10 can be determined as the target color. After determining multiple target colors, the electronic device determines multiple candidate color systems to which the multiple target colors belong.
[0054] It should be noted that the present disclosure determines multiple candidate color systems to which multiple target colors belong based on 24 color systems. Among them, the 24 color systems correspond to a 360° color wheel. Each color system occupies 15 degrees, that is, 0-15° is a color system, 15°-30° is a color system, and so on, the 360° color wheel is divided into 24 color systems.
[0055] In one embodiment, the position of a target color on the color wheel is determined according to the hue value of the target color, thereby obtaining the color system to which the target color belongs. Based on this, multiple candidate color systems to which multiple target colors belong can be obtained. Among them, the candidate color systems to which different target colors belong can be the same or different.
[0056] Optionally, after obtaining all the colors of the target image, the electronic device determines the color that meets the preset conditions as the target color, thereby obtaining multiple target colors. Among them, the area ratio of the target color that meets the preset conditions includes: the area ratio of the target color is greater than the area ratio of other colors other than the target color in each color. By screening all the colors in the target image and determining the color with an area ratio greater than other colors as the target color, it can reduce the amount of calculation for determining the candidate color system, increase the speed of determining the theme color, and improve the user experience, and it can also ensure that the candidate color system determined based on the target color can accurately express the overall color perception of the target image.
[0057] In one embodiment, the electronic device determines the target color according to the target threshold. For example, the electronic device presets a target threshold, and determines the color whose area ratio is greater than the target threshold as the target color, thereby obtaining multiple target colors. The area ratio of the target color obtained in this way meets the preset condition.
[0058] In another embodiment, the electronic device sorts all colors in the target image according to the area proportion of each color to obtain an ordered color set. Furthermore, according to the predetermined number of target colors, a preset number of colors can be sequentially selected from the ordered color set to obtain multiple target colors.
[0059] In S102, at least one target candidate color system is determined from a plurality of candidate color systems.
[0060] The area proportion of each target candidate color system in the target image is greater than the area proportion of other candidate color systems other than the target candidate color system in the target image.
[0061] Optionally, the target candidate color system is the candidate color system with the largest area ratio among the multiple candidate color systems.
[0062] In one embodiment, after obtaining multiple candidate color systems, the electronic device first determines the sum of the area proportions of all target colors in each candidate color system, and uses the sum of the area proportions of all target colors in a candidate color system as the area proportion of the candidate color system. Further, the candidate color system with the largest area proportion is determined as the target candidate color system. By selecting the candidate color system with the largest area proportion as the target candidate color system, it can be finally determined that the color system to which the theme color belongs has the largest proportion in the target image, thereby enabling the theme color to more accurately express the color of the target image, thereby improving the immersion of the page rendered based on the theme color and improving the user experience.
[0063] Optionally, the target candidate color system is each candidate color system whose area ratio is greater than a first threshold among the multiple candidate color systems.
[0064] In one embodiment, after obtaining multiple candidate color systems, the electronic device first determines the sum of the area proportions of all target colors in each candidate color system, and uses the sum of the area proportions of all target colors in a candidate color system as the area proportion of the candidate color system. Further, each candidate color system whose area proportion is greater than the first threshold is determined as a target candidate color system. By selecting a candidate color system whose area proportion is greater than the first threshold as a target candidate color system, a larger selection range is provided for the target candidate color system, and the diversity of the target candidate color system selection is improved without affecting the accuracy of the theme color, thereby improving the diversity of the theme color.
[0065] In S103, any color in the target candidate color system is determined as the theme color of the target image.
[0066] Optionally, the target color with the largest area in the target candidate color system is determined as the theme color.
[0067] In one embodiment, the electronic device determines the color with the highest area ratio in the target candidate color system as the theme color of the target image. By determining the color with the highest area ratio in the target candidate color system as the theme color, the color of the target image can be expressed more accurately, thereby improving the accuracy of the theme color.
[0068] Optionally, a target color whose area ratio is greater than a target threshold in the target candidate color system is determined as the theme color.
[0069] In one embodiment, the electronic device determines the target color whose area ratio is greater than the target threshold in the target candidate color system as the theme color in the target image. In the case where there are multiple target colors whose area ratio is greater than the target threshold, any target color whose area ratio is greater than the target threshold can be determined as the theme color. By selecting the target color whose area ratio is greater than the target threshold as the theme color, a larger selection range is provided for the theme color, and the diversity of theme color selection is improved without affecting the accuracy of the theme color.
[0070] In the above embodiment, in the process of determining the theme color, the target candidate color system with a relatively large area ratio on the target image is first determined, and then the theme color is determined based on any target candidate color system, so that the overall color presentation effect of the target image is taken into consideration when determining the theme color, and the target candidate color system with a relatively large area ratio is determined as the theme color, thereby more accurately expressing the color of the target image, improving the immersion of the page rendered based on the theme color, and then meeting the visual needs of the user and improving the user's experience. In addition, compared with the prior art of directly determining the color with the highest area ratio as the theme color, it can also avoid filtering out the same color system colors with adjacent hue values and low area ratio in the target image, resulting in the filtering out of the color system with a relatively large area ratio, so that the color system to which the finally selected theme color belongs has a relatively low area ratio on the target image, and cannot accurately express the color of the target image.
[0071] Specifically, if the subject image includes 5 colors, namely color A, color B, color C, color D and color E. Among them, the area of color A accounts for 10%, the area of color B accounts for 15%, the area of color C accounts for 20%, the area of color D accounts for 25%, and the area of color E accounts for 30%. When colors A, B and C belong to the first color system of the 24 color systems, that is, the color system corresponding to 0°-15° on the color wheel, color D belongs to the fifth color system of the 24 color systems, that is, the color system corresponding to 60°-75° on the color wheel, and color E belongs to the twelfth color system of the 24 color systems, that is, the color system corresponding to 165°-180° on the color wheel.
[0072] At this time, based on the image color extraction method disclosed in the present invention, the first color system to which color A, color B, and color C belong is first determined as the target candidate color system, and then the theme color is determined based on the target candidate color system. Obviously, the theme color selected by the present invention, that is, color A, color B, or color C, can more accurately express the color of the theme image because there are multiple similar colors in the target image, and the sum of the area proportions of the multiple similar colors is the largest in the area occupied by the target image.
[0073] In one possible implementation, combining Figure 1 ,like Figure 2 As shown, the image color extraction method further includes: S104-S106. It should be noted that S104-S106 are executed by the electronic device.
[0074] In S104, each color in the target image is obtained.
[0075] Optionally, the colors in the target image may be extracted through a prefix tree to obtain each color in the target image.
[0076] In one embodiment, the color in the target image may be extracted by the following steps 1 to 4:
[0077] Step 1: Decompose each color in the target image into RGB, where the value range of each color is [0,256), that is, 8 bits. For example, if R is (221)10, the corresponding binary can be represented as (11011101)2. Therefore, a binary tree can be used to represent a color. Furthermore, RGB can be represented in binary.
[0078] Step 2: In order to represent three colors in the same bit, considering that each color has only 0 and 1, each bit of the three colors can be represented by octal, thereby compressing the color into an 8-bit number.
[0079] Step 3: After color compression, construct a prefix tree (trie) to represent each color in a similar way to string processing. Because color compression was done before, each parent node of this prefix tree has 8 child nodes, and the height (depth) of the tree is 8. Each node has a count field to record the total count under the current node.
[0080] Step 4: Count each color in the target image according to the number of prefix trees (trie).
[0081] In S105, at least one color of each color whose area ratio in the target image is less than a first preset threshold is deleted to obtain a plurality of candidate colors.
[0082] Optionally, the first preset threshold may be 1%.
[0083] In one embodiment, the first preset threshold value may be adjusted according to the number of all colors in the target image. For example, when the number of all colors in the target image is large, there is a situation where the proportion of all colors is relatively small. In this case, a smaller first preset threshold value may be selected.
[0084] Exemplarily, the correspondence between the number of colors in the target image and the first preset threshold value may be preconfigured. After the number of colors in the target image is determined, a suitable first preset threshold value is determined according to the correspondence.
[0085] In S106 , a plurality of target colors are determined from the plurality of candidate colors.
[0086] Optionally, after obtaining a plurality of candidate colors, the electronic device determines a plurality of candidate colors that meet a preset condition as target colors, thereby obtaining a plurality of target colors.
[0087] In one embodiment, the electronic device determines the target color according to the target threshold. For example, the electronic device presets a target threshold, and determines the candidate color whose area ratio is greater than the target threshold as the target color, thereby obtaining multiple target colors. The area ratio of the target color obtained in this way meets the preset condition.
[0088] In another embodiment, the electronic device sorts multiple candidate colors according to the area ratio of each candidate color to obtain an ordered candidate color set. Furthermore, according to the number of predetermined target colors, a preset number of candidate colors can be sequentially selected from the ordered candidate color set to obtain multiple target colors.
[0089] In the above embodiment, by deleting colors whose area proportion is less than a first preset threshold in each color, multiple candidate colors are obtained, and multiple target colors are determined from the multiple candidate colors. On the one hand, colors that have little impact on the color perception of the target image can be filtered out, thereby reducing the number of target colors and thereby reducing the amount of calculation for determining the candidate color system. On the other hand, it can avoid colors whose area proportion is less than the first preset threshold being determined as theme colors, which makes it impossible to accurately express the color of the target image, resulting in poor immersion of pages rendered based on theme colors.
[0090] In one possible implementation, at least the colors whose area ratio in each color is less than a first preset threshold are deleted to obtain multiple candidate colors, including: deleting the colors whose area ratio in each color is less than the first preset threshold, and at least one of black, white and gray to obtain multiple candidate colors.
[0091] Optionally, after obtaining all colors in the target image, the electronic device first deletes colors whose area ratio is less than a first preset threshold from among all colors to obtain multiple third colors, and then deletes at least one of black, white and gray from among the multiple third colors to obtain multiple candidate colors.
[0092] Optionally, based on different application scenarios of the theme color, it is pre-configured whether to delete black, white or gray in each application scenario.
[0093] In one embodiment, the preset white deletion corresponds to the first deletion mark, the black deletion corresponds to the second deletion mark, and the gray deletion corresponds to the third deletion mark. Further, the application scenario is pre-divided into a day mode and a night mode. The day mode corresponds to the second deletion mark and the third deletion mark, respectively, and the night mode corresponds to the first deletion mark and the third deletion mark, respectively.
[0094] When it is determined that the application scenario of the theme color is daytime mode, and black exists among multiple third colors, based on the correspondence between daytime mode and the second deletion mark, black among multiple third colors is deleted. When it is determined that the application scenario of the theme color is daytime mode, and gray exists among multiple third colors, based on the correspondence between daytime mode and the third deletion mark, gray among multiple third colors is deleted. When it is determined that the application scenario of the theme color is daytime mode, and black and gray exist among multiple third colors, based on the correspondence between daytime mode and the second deletion mark, black among multiple third colors is deleted, and based on the correspondence between daytime mode and the third deletion mark, gray among multiple third colors is deleted. When it is determined that the application scenario of the theme color is daytime mode, and white, black and gray exist among multiple third colors, based on the correspondence between daytime mode and the second deletion mark, black among multiple third colors is deleted, and based on the correspondence between daytime mode and the third deletion mark, gray among multiple third colors is deleted.
[0095] When it is determined that the application scenario of the theme color is night mode, and white exists among multiple third colors, based on the correspondence between the night mode and the first deletion mark, delete the white among the multiple third colors. When it is determined that the application scenario of the theme color is night mode, and gray exists among multiple third colors, based on the correspondence between the night mode and the third deletion mark, delete the gray among the multiple third colors. When it is determined that the application scenario of the theme color is night mode, and white and gray exist among multiple third colors, based on the correspondence between the night mode and the first deletion mark, delete the white among the multiple third colors, and based on the correspondence between the night mode and the third deletion mark, delete the gray among the multiple third colors. When it is determined that the application scenario of the theme color is day mode, and white, black and gray exist among multiple third colors, based on the correspondence between the night mode and the first deletion mark, delete the white among the multiple third colors, and based on the correspondence between the night mode and the third deletion mark, delete the gray among the multiple third colors.
[0096] In another embodiment, the preset white deletion corresponds to the fourth deletion mark, the black deletion corresponds to the fifth deletion mark, and the gray deletion corresponds to the sixth deletion mark. Further, the application scenarios are pre-divided into holiday mode and non-holiday mode. Among them, the holiday mode corresponds to the first deletion mark, the second deletion mark and the third deletion mark, respectively, to ensure that the page of the holiday mode is brighter. The non-holiday mode does not correspond to any deletion mark.
[0097] When it is determined that the application scenario of the theme color is a holiday mode, and white exists among the multiple third colors, based on the correspondence between the holiday mode and the first deletion mark, white among the multiple third colors is deleted. When it is determined that the application scenario of the theme color is a holiday mode, and black exists among the multiple third colors, based on the correspondence between the holiday mode and the second deletion mark, black among the multiple third colors is deleted. When it is determined that the application scenario of the theme color is a holiday mode, and gray exists among the multiple third colors, based on the correspondence between the holiday mode and the third deletion mark, gray among the multiple third colors is deleted. When it is determined that the application scenario of the theme color is a holiday mode, and white, black and gray exist among the multiple third colors, based on the correspondence between the holiday mode and the first deletion mark, white among the multiple third colors is deleted, based on the correspondence between the holiday mode and the second deletion mark, black among the multiple third colors is deleted, and based on the correspondence between the holiday mode and the third deletion mark, gray among the multiple third colors is deleted.
[0098] It should be noted that the application scenarios can also be divided according to the pages where the theme color is used, for example, divided into home pages and non-home pages, and then different deletion flags are configured for different application scenarios to determine whether to delete black, white and gray among multiple third colors according to the application scenario of the theme color.
[0099] It can be understood that the application scene of the theme color can be determined based on the scene where the target image is located. In one embodiment, the application scene of the theme color is the same as the scene where the target image is located.
[0100] In one embodiment, after the electronic device obtains multiple third colors, it first determines whether black, white or gray exists in the multiple third colors. To determine whether black, white or gray exists in the target color, the following steps 1 to 3 can be used, and black is used as an example for explanation.
[0101] Step 1: Project the saturation value and brightness value of the third color into a two-dimensional space constructed by the saturation value and the brightness value.
[0102] Step 2: When the coordinate point corresponding to the saturation value and brightness value of the third color is within a preset range, the target color is determined to be black. The two-dimensional space may have the saturation value as the horizontal axis and the brightness value as the vertical axis. Alternatively, the saturation value may be the vertical axis and the brightness value may be the horizontal axis, which is not limited in the present disclosure.
[0103] The preset range may be determined by the following method: preselect a coordinate point in a two-dimensional space, and use a rectangle formed by the coordinate point, the origin, the X-axis, and the Y-axis as the preset range.
[0104] In the above embodiment, multiple candidate colors are obtained by deleting at least one of black, white and gray included in the target image, so that multiple target colors are determined from the multiple candidate colors and do not include at least one of black, white and gray, thereby filtering out one of black, white and gray in the candidate color system, avoiding at least one of black, white and gray from being determined as the theme color, thereby meeting the requirements of specific application scenarios for black, white and gray, and further achieving that the theme color extracted based on the image color extraction method disclosed in the present invention can cover the needs of more businesses for the use of theme colors.
[0105] In one possible implementation, at least one color whose area ratio is less than a second threshold value is deleted from each color to obtain multiple candidate colors, including: deleting the color whose area ratio is less than the second threshold value from each color, and when each color includes the first color, performing at least one replacement step to obtain multiple candidate colors; wherein the replacement step includes: replacing the first color with a first preset color.
[0106] In another embodiment, the first color is black. When the first color is black, the first preset color is the fifth color. For example, the fifth color may be another color in the same color system as black, and the visual perception of the fifth color is better than that of black. The visual perception of different colors can be determined by sample data. For example, a sample of 10 people is selected, and for each person, the visual perception of each color in the color system to which black belongs is counted, and the color with the highest visual perception of the color system to which black belongs is determined as the fifth color.
[0107] In one embodiment, the first color is white. When the first color is white, the first preset color is the sixth color. For example, the sixth color may be another color in the same color system as white, and the visual perception of the sixth color is better than that of white. The visual perception of different colors can be determined by sample data. For example, a sample of 10 people is selected, and for each person, the visual perception of each color in the color system to which white belongs is counted, and the color with the highest visual perception of the color system to which white belongs is determined as the sixth color.
[0108] In another embodiment, the first color is gray. When the first color is gray, the first preset color is the seventh color. For example, the seventh color may be another color in the same color system as gray, and the visual perception of the seventh color is better than that of gray. The visual perception of different colors can be determined by sample data. For example, a sample of 10 people is selected, and for each person, the visual perception of each color in the color system to which gray belongs is statistically analyzed, and the color with the highest visual perception in the color system to which gray belongs is determined as the seventh color.
[0109] Optionally, after obtaining all colors in the target image, the electronic device first deletes all colors whose total color area ratio is less than the second threshold to obtain multiple fourth colors, and then performs at least one replacement step on the multiple fourth colors to obtain multiple candidate colors.
[0110] Optionally, the fifth color, the sixth color and the seventh color may be predetermined according to an application scenario of the theme color.
[0111] In one embodiment, different fifth colors, sixth colors, and seventh colors are configured for different application scenarios. Exemplarily, the application scenarios are divided into a day mode and a night mode, wherein the fifth color, sixth color, and seventh color of the day mode may be bright colors, and the fifth color, sixth color, and seventh color of the night mode may be dark colors.
[0112] Optionally, based on different application scenarios of the theme color, replacement steps to be performed in each application scenario are pre-configured.
[0113] In one embodiment, the application scenario is pre-divided into a day mode and a night mode. The day mode is configured to perform two replacement steps of replacing black with the fifth color and replacing gray with the seventh color. The night mode is configured to perform two replacement steps of replacing white with the sixth color and replacing gray with the seventh color.
[0114] When it is determined that the application scenario of the theme color is the daytime mode, two replacement steps of replacing black with the fifth color and replacing gray with the seventh color are performed on the plurality of fourth colors. It can be understood that if black does not exist in the plurality of fourth colors, the replacement step of replacing black with the fifth color is not performed. If gray does not exist in the plurality of fourth colors, the replacement step of replacing gray with the seventh color is not performed.
[0115] In another embodiment, the application scenario is pre-divided into a holiday mode and a non-holiday mode. The holiday mode is configured to perform three replacement steps of replacing black with the fifth color, replacing white with the sixth color, and replacing gray with the seventh color, so as to ensure that the page in the holiday mode is brighter. The non-holiday mode is not configured with a replacement step.
[0116] When it is determined that the application scenario of the theme color is a holiday mode, three replacement steps are performed on the multiple fourth colors: replacing black with the fifth color, replacing white with the sixth color, and replacing gray with the seventh color. It can be understood that if black does not exist in the multiple fourth colors, the replacement step of replacing black with the fifth color is not performed. If white does not exist in the multiple fourth colors, the replacement step of replacing white with the sixth color is not performed. If gray does not exist in the multiple fourth colors, the replacement step of replacing gray with the seventh color is not performed.
[0117] It should be noted that the application scenarios can also be divided according to the pages where the theme color is used, for example, divided into home pages and non-home pages, and then different replacement steps are configured for different application scenarios to determine whether to execute the replacement step and which replacement step to execute according to the application scenario of the theme color.
[0118] It can be understood that the application scene of the theme color can be determined based on the scene where the target image is located. Exemplarily, the application scene of the theme color is the same as the scene where the target image is located.
[0119] In one embodiment, when the client requests the electronic device to obtain the theme color in the target image, the client determines the scene identifier corresponding to the target image and sends it to the electronic device, so that the electronic device determines the application scene corresponding to the scene identifier as the application scene of the theme color.
[0120] In another embodiment, there is a page to be rendered on the electronic device, and a target image is configured on the page to be rendered. At this time, the electronic device determines a scene identifier corresponding to the target image, and determines the scene corresponding to the scene identifier as an application scene of the theme color.
[0121] In the above embodiment, by replacing the first color included in the target image, for example, replacing black, white or gray, multiple candidate colors are obtained, thereby improving the visual perception of the multiple candidate colors, and then improving the visual perception of the theme color determined in the candidate color system, so that the theme color can meet the requirements of the specific application scenario for the first color, and then the theme color extracted based on the image color extraction method disclosed in the present invention can cover the needs of more businesses for the use of theme colors.
[0122] In a possible implementation, after determining a color in the target candidate color system as the theme color of the target image, the image color extraction method further includes: when the theme color is other than black, white and gray, adjusting the brightness value and saturation value of the theme color to corresponding preset ranges respectively.
[0123] In one implementation, when the theme color is other than black, white and gray, or when the theme color is a color, the electronic device adjusts the saturation value and the brightness value of the theme color to corresponding preset ranges.
[0124] It should be noted that, in this embodiment, the color is other colors besides black, white and gray.
[0125] In one example, after obtaining the theme color, the electronic device determines whether the theme color is a color, that is, whether it is a color other than black, white, and gray. If the theme color is a color, the saturation value and brightness value of the theme color are adjusted respectively, so that the adjusted saturation value and brightness value are respectively located in the corresponding preset intervals, and the page is rendered based on the adjusted theme color, or the RGB value corresponding to the adjusted theme color is sent to the client that needs to render the page.
[0126] Take the saturation value as an example. For example, the saturation value of the theme color is 20, which belongs to the range of 0 to 100. The preset interval corresponding to the saturation value is 20 to 70. It can be understood that the current saturation value accounts for 20% of the current interval. At this time, the saturation value is adjusted proportionally so that the adjusted saturation value still accounts for 20% of the preset interval. The 20% share of the interval of 20 to 70 is (70-20)*20%=10, that is, 10 corresponding points are added with 20 as the starting point. It can be seen that in this embodiment, the current saturation value of 20 needs to be adjusted to 30.
[0127] It should be noted that the principle of adjusting the brightness value is the same as that of adjusting the saturation value, which will not be repeated here.
[0128] In the above embodiment, by adjusting the saturation value and brightness value of the theme color when the theme color is other than black, white and gray, the visual effect of the theme color is improved, so that the page rendered based on the theme color can better meet the user's visual requirements.
[0129] In a possible implementation, after determining a color in the target candidate color system as the theme color of the target image, the image color extraction method further includes: when the theme color is black, adjusting the hue value of the theme color to reach a second preset threshold.
[0130] In one implementation, after the electronic device obtains the theme color, if the theme color is black, the hue value of the candidate theme color is adjusted to a second preset threshold to obtain the theme color.
[0131] Optionally, the second preset threshold may be 8. It should be noted that the second preset threshold may be adjusted according to the application scenario of the theme color, which is not limited in the present disclosure. The application scenario of the theme color may be determined according to the scenario where the target image is located.
[0132] In one example, after obtaining the theme color, the electronic device determines whether the theme color is black. If the theme color is black, the hue value of the theme color is adjusted to 8, and the page is rendered based on the adjusted theme color, or the RGB value corresponding to the adjusted theme color is sent to the client that needs to render the page.
[0133] In the above embodiment, when the theme color is black, the hue value of the theme color is adjusted to improve the visual effect of the theme color, so that the page rendered based on the theme color can better meet the visual requirements of the user.
[0134] In a possible implementation, after determining a color in the target candidate color system as the theme color of the target image, the method further includes: when the theme color is the second color, replacing the second color with a second preset color.
[0135] Optionally, when the second color is white, white is replaced by the eighth color.
[0136] Optionally, the eighth color may be predetermined according to an application scenario of the theme color. The application scenario of the theme color may be determined based on the scene where the target image is located. In one embodiment, the application scenario of the theme color is the same as the scene where the target image is located.
[0137] In one embodiment, when the client requests the electronic device to obtain the theme color in the target image, the client determines the scene identifier corresponding to the target image and sends it to the electronic device, so that the electronic device determines the application scene corresponding to the scene identifier as the application scene of the theme color.
[0138] In another embodiment, there is a page to be rendered on the electronic device, and a target image is configured on the page to be rendered. At this time, the electronic device determines a scene identifier corresponding to the target image, and determines the scene corresponding to the scene identifier as an application scene of the theme color.
[0139] In one embodiment, different eighth colors are configured for different application scenarios. Exemplarily, the application scenarios are divided into a day mode and a night mode, wherein the eighth color of the day mode may be a brighter color, and the eighth color of the night mode may be a darker color.
[0140] Optionally, when the second color is gray, the gray is replaced by the ninth color.
[0141] Optionally, the ninth color may be predetermined according to an application scenario of the theme color. The application scenario of the theme color may be determined based on the scene where the target image is located. In one embodiment, the application scenario of the theme color is the same as the scene where the target image is located.
[0142] In one embodiment, different ninth colors are configured for different application scenarios. Exemplarily, the application scenarios are divided into a day mode and a night mode, wherein the ninth color of the day mode may be a brighter color, and the ninth color of the night mode may be a darker color.
[0143] In the above embodiment, by replacing the second color with the second preset color when the theme color is the second color, for example, when the second color is white, white is replaced with the eighth color, and when the second color is black, black is replaced with the ninth color, the visual effect of the theme color is improved, so that the page rendered based on the theme color can better meet the visual requirements of the user.
[0144] In a possible implementation, Figure 3 As shown, the image color extraction method also includes: S107-S108.
[0145] In S107, a theme color extraction request sent by the client is received, where the theme color extraction request is used to request to obtain the theme color of the target image.
[0146] In one implementation, before rendering a page, the client sends a theme color extraction request to the electronic device, requesting the electronic device to obtain the theme color on the target image.
[0147] Exemplarily, when there are multiple images on the page to be rendered, the client determines the target image based on a preset rule. For example, the preset rule may be a rule manually set in advance.
[0148] In S108 , the RGB value corresponding to the theme color is sent so that the client can render the page where the target image is located according to the RGB value.
[0149] In one implementation, after receiving the RGB value corresponding to the theme color sent by the electronic device, the client renders the page based on the RGB value.
[0150] It should be noted that RGB represents the colors of the three channels: red, green, and blue.
[0151] In the above embodiment, the electronic device extracts the theme color of the target image based on the request of the client, and returns the RGB value corresponding to the theme color to the client after the extraction is completed, so that the client can render the page. Compared with the prior art in which the theme color is extracted by the client using the theme color, the present disclosure extracts the theme color by a dedicated electronic device, which can improve the computing efficiency and processing efficiency, so that the theme color extraction can be processed in batches, thereby meeting the request volume and response time requirements of various services on the client, saving labor costs and resources, and being able to support multiple online services.
[0152] In addition, by using a dedicated electronic device to extract the theme color, the color extraction strategy configured in the electronic device can be isolated from the client, so that the client is unaware of changes in the color extraction strategy, reducing the cost of iterating the color extraction strategy required for the client to extract the theme color, and also facilitating the adjustment of the color extraction strategy, enabling the color extraction strategy to take effect in real time.
[0153] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the method. In order to realize the above functions, it includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0154] The embodiment of the present disclosure also provides an image color extraction device.
[0155] Figure 4 is a block diagram of an image color extraction device according to an exemplary embodiment. Figure 4 The image color extraction device 400 includes a determination module 401, a matching module 402 and an extraction module 403.
[0156] The determination module 401 is configured to determine multiple candidate color systems to which multiple target colors in a target image belong; the area proportion of each target color in the target image is greater than the area proportion of other colors other than the target color in the target image. Figure 1 , the determination module 401 can be used to execute S101.
[0157] The matching module 402 is configured to determine at least one target candidate color system from the plurality of candidate color systems; wherein the area proportion of each target candidate color system in the target image is greater than the area proportion of other candidate color systems other than the target candidate color system in the target image. Figure 1 , the matching module 402 can be used to execute S102.
[0158] The extraction module 403 is configured to determine any color in the target candidate color system as the theme color of the target image. Figure 1 , the extraction module 403 can be used to execute S103.
[0159] In a possible implementation, the device further includes: an acquisition module configured to execute: acquiring each color in the target image; deleting at least one color whose area ratio in the target image is less than a first preset threshold value, to obtain a plurality of candidate colors; and determining the plurality of target colors from the plurality of candidate colors. Figure 2 , the acquisition module can be used to execute S104-S106.
[0160] In another possible implementation, the acquisition module is specifically configured to execute: deleting the color whose area in the target image is less than a first preset threshold, and at least one of black, white and gray, to obtain the multiple candidate colors.
[0161] In another possible implementation, the acquisition module is specifically configured to execute: deleting the colors in each color whose area ratio in the target image is less than a first preset threshold, and when each color includes the first color, executing at least one replacement step to obtain the multiple candidate colors; wherein the replacement step includes: replacing the first color with a first preset color.
[0162] In another possible implementation, the device further includes an adjustment module configured to execute: when the theme color is other colors other than black, white and gray, respectively adjusting the brightness value and saturation value of the theme color to corresponding preset ranges; when the theme color is black, adjusting the hue value of the theme color to reach a second preset threshold; when the theme color is a second color, replacing the second color with a second preset color.
[0163] In another possible implementation, the device further includes a receiving module configured to: receive a theme color extraction request sent by a client, the theme color extraction request being used to request to obtain the theme color of the target image; and send an RGB value corresponding to the theme color, so that the client can render the page where the target image is located according to the RGB value. Figure 3 , the receiving module can be used to execute S107-S108.
[0164] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0165] Figure 5 FIG. 1 is a block diagram of an electronic device according to an exemplary embodiment. Figure 5 As shown, the electronic device 500 includes but is not limited to: a processor 501 and a memory 502 .
[0166] The memory 502 is used to store executable instructions of the processor 501. It is understood that the processor 501 is configured to execute instructions to implement the above embodiment. Figures 1 to 4 The image color extraction method shown in any one of the items.
[0167] It should be noted that those skilled in the art can understand that Figure 5The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include Figure 5 More or fewer components may be shown, or certain components may be combined, or the components may be arranged differently.
[0168] The processor 501 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 502 and calling data stored in the memory 502, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 501 may include one or more processing units; optionally, the processor 501 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 501.
[0169] The memory 502 can be used to store software programs and various data. The memory 502 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application program required by at least one functional module (such as an image acquisition module, a positioning module, a hidden variable acquisition module or an image generation module, etc.). In addition, the memory 502 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0170] In an exemplary embodiment, the present disclosure also provides a computer-readable storage medium including instructions, such as a memory 502 including instructions, and the instructions can be executed by a processor 501 of an electronic device 500 to complete the above embodiment. Figures 1 to 3 The image color extraction method shown in any one of the items.
[0171] In actual implementation, the processing functions of the determination module 401, the matching module 402 and the extraction module 403 can be Figure 5 The processor 501 shown calls the program code in the memory 502 to implement. The specific execution process can be referred to Figures 1 to 3 The description of any of the image color extraction methods shown will not be repeated here.
[0172] Optionally, the computer-readable storage medium may be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0173] In an exemplary embodiment, the present disclosure also provides a computer program product including one or more instructions, which can be executed by the processor 501 of the electronic device 500 to complete the above-mentioned embodiment. Figures 1 to 3 The image color extraction method shown in any one of the items.
[0174] It should be noted that when the instructions in the computer-readable storage medium or one or more instructions in the computer program product are executed by the processor 501 of the electronic device 500, the above-mentioned embodiments are implemented. Figures 1 to 3 Each process of the image color extraction method embodiment shown in any one of the items can achieve the same as in the above embodiment Figures 1 to 3 The image color extraction method shown in any of the items has the same technical effect, so to avoid repetition, it will not be repeated here.
[0175] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0176] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for extracting color from an image, characterized in that: include: Get each color in the target image; Deleting the color whose area proportion in the target image is less than a first preset threshold value among each color, to obtain a plurality of third colors; When the application scene of the target image is a daytime mode, black and gray are deleted from the plurality of third colors to obtain a plurality of candidate colors; When the application scene of the target image is a night mode, deleting white and gray from the plurality of third colors to obtain a plurality of candidate colors; determining a plurality of target colors from the plurality of candidate colors; Determine a plurality of candidate color systems to which the plurality of target colors in the target image belong; the area proportion of each target color in the target image is greater than the area proportion of other colors other than the target color in the target image; Determine at least one target candidate color system from the multiple candidate color systems; wherein the area proportion of each target candidate color system in the target image is greater than the area proportion of other candidate color systems other than the target candidate color system in the target image; A color in any target candidate color system is determined as a theme color of the target image.
2. The image color extraction method according to claim 1, characterized in that: The method further comprises: Get each color in the target image; At least one color of each color whose area ratio in the target image is less than a first preset threshold is deleted to obtain a plurality of candidate colors; The plurality of target colors are determined from the plurality of candidate colors.
3. The image color extraction method according to claim 2, characterized in that: The step of at least deleting the color whose area ratio in the target image is less than a first preset threshold value among each color to obtain a plurality of candidate colors includes: The plurality of candidate colors are obtained by deleting the colors whose area ratio in the target image is less than a first preset threshold and at least one of black, white and gray.
4. The image color extraction method according to claim 2, characterized in that: The step of at least deleting the color whose area ratio in the target image is less than a first preset threshold value among each color to obtain a plurality of candidate colors includes: Delete the colors whose area proportion in the target image is less than a first preset threshold in each of the colors, and when the first color is included in each of the colors, perform at least one replacement step to obtain the multiple candidate colors; wherein the replacement step includes: replacing the first color with a first preset color.
5. The image color extraction method according to claim 1, characterized in that: After determining a color in any target candidate color system as the theme color of the target image, the method further includes: When the theme color is other than black, white and gray, respectively adjusting the brightness value and saturation value of the theme color to corresponding preset ranges; When the theme color is black, adjusting the hue value of the theme color to reach a second preset threshold; When the theme color is a second color, the second color is replaced by a second preset color.
6. The image color extraction method according to any one of claims 1 to 5, characterized in that: The method further comprises: Receive a theme color extraction request sent by a client, where the theme color extraction request is used to request to obtain the theme color of the target image; The RGB value corresponding to the theme color is sent so that the client can render the page where the target image is located according to the RGB value.
7. An image color extraction device, characterized in that: include: The acquisition module is configured to execute acquisition of each color in the target image; delete the color whose area ratio in the target image is less than a first preset threshold value among the colors to obtain a plurality of third colors; when the application scene of the target image is a day mode, delete black and gray among the plurality of third colors to obtain a plurality of candidate colors; when the application scene of the target image is a night mode, delete white and gray among the plurality of third colors to obtain a plurality of candidate colors; and determine a plurality of target colors from the plurality of candidate colors; A determination module is configured to determine a plurality of candidate color systems to which the plurality of target colors in the target image belong; the area proportion of each target color in the target image is greater than the area proportion of other colors other than the target color in the target image; A matching module, configured to determine at least one target candidate color system from the multiple candidate color systems; wherein the area proportion of each target candidate color system in the target image is greater than the area proportion of other candidate color systems other than the target candidate color system in the target image; The extraction module is configured to determine a color in any target candidate color system as a theme color of the target image.
8. The image color extraction device according to claim 7, characterized in that: The device further includes: an acquisition module configured to execute: Get each color in the target image; At least one color of each color whose area ratio in the target image is less than a first preset threshold is deleted to obtain a plurality of candidate colors; The plurality of target colors are determined from the plurality of candidate colors.
9. The image color extraction device according to claim 8, characterized in that: The acquisition module is specifically configured to execute: The plurality of candidate colors are obtained by deleting the colors whose area ratio in the target image is less than a first preset threshold and at least one of black, white and gray.
10. The image color extraction device according to claim 8, characterized in that: The acquisition module is specifically configured to execute: Delete the colors whose area proportion in the target image is less than a first preset threshold in each of the colors, and when the first color is included in each of the colors, perform at least one replacement step to obtain the multiple candidate colors; wherein the replacement step includes: replacing the first color with a first preset color.
11. The image color extraction device according to claim 7, characterized in that: The apparatus further comprises an adjustment module configured to execute: When the theme color is other than black, white and gray, respectively adjusting the brightness value and saturation value of the theme color to corresponding preset ranges; When the theme color is black, adjusting the hue value of the theme color to reach a second preset threshold; When the theme color is a second color, the second color is replaced by a second preset color.
12. The image color extraction device according to any one of claims 7 to 11, characterized in that: The apparatus further includes a receiving module configured to execute: Receive a theme color extraction request sent by a client, where the theme color extraction request is used to request to obtain the theme color of the target image; The RGB value corresponding to the theme color is sent so that the client can render the page where the target image is located according to the RGB value.
13. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the image color extraction method according to any one of claims 1 to 6.
14. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the image color extraction method according to any one of claims 1 to 6.
15. A computer program product, characterized in that The computer program product comprises computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the image color extraction method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Page color adjusting method and device and electronic equipment
CN110377860A
Image theme color extraction method and device and electronic equipment
CN110969170A