Picture style processing method and system and readable storage medium

By calculating the brightness contrast between the background main color and the foreground color of the image and adjusting the foreground color brightness according to a preset threshold, the problem of low efficiency in traditional image color processing is solved, and the prominence and readability of the foreground color on the background color are achieved.

CN120689440APending Publication Date: 2025-09-23SHANGHAI QISHENG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510626976.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-15
Publication Date
2025-09-23

AI Technical Summary

Technical Problem

Traditional image color processing methods rely on the designer's experience, are inefficient, and make it difficult to ensure the scientific and rationality of color matching. This results in the foreground color not being prominent enough on the background color, affecting the effectiveness of information communication.

Method used

By obtaining the background main color and foreground color of the image, the brightness contrast is calculated and compared with the preset threshold. If the contrast is less than the threshold, the foreground color brightness is adjusted to make the contrast greater than or equal to the threshold. If the contrast is greater than or equal to the threshold, the foreground color brightness is retained, the background main color is calculated using a clustering algorithm, and the contrast is calculated through linear correction.

Benefits of technology

An effective combination of foreground and background colors is achieved, making the foreground color more prominent on the background color, improving the readability and visual experience of the information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120689440A_ABST
    Figure CN120689440A_ABST
Patent Text Reader

Abstract

The invention discloses a picture style processing method and system and a computer readable storage medium. The picture style processing method comprises the following steps: acquiring a picture, and extracting a background main color of the picture and a foreground color of the picture; the contrast ratio between the foreground color and the background main color is calculated; if the contrast ratio is smaller than the preset threshold value, adjusting the brightness value of the foreground color to enable the contrast ratio to be larger than or equal to the preset threshold value; and if the contrast ratio is greater than or equal to the preset threshold value, retaining the brightness value of the foreground color. According to the technical scheme, the picture can be effectively processed, so that the foreground color and the background color of the picture are effectively matched, and the foreground color is more remarkable than the background color.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of content generation technology, and in particular to a picture style processing method, a processing system, and a computer-readable storage medium. Background Art

[0002] In image design and processing, the color matching between an image's foreground and background elements is crucial to its visual effectiveness. Appropriate color combinations can improve information readability and enhance the user's visual experience. However, inappropriate color combinations can lead to poor communication, hindering user understanding of the image's content and even overlooking the content conveyed by the foreground color. Traditional image color processing often relies on the designer's experience to manually select foreground and background colors. This method is inefficient and struggles to ensure a scientific and rational color matching, failing to effectively highlight the foreground color. Summary of the Invention

[0003] In view of the defects in the prior art, the present invention provides a picture style processing method that can effectively process a picture so that its foreground color and background color are effectively matched, making the foreground color more prominent on the background color.

[0004] This application provides a method for processing image style, which includes:

[0005] Obtain a picture, and extract the background main color and the foreground color of the picture;

[0006] Calculating the brightness contrast between the foreground color and the background main color;

[0007] comparing the contrast with a preset threshold;

[0008] If the contrast is less than the preset threshold, adjusting the brightness value of the foreground color so that the contrast is greater than or equal to the preset threshold;

[0009] If the contrast is greater than or equal to the preset threshold, the brightness value of the foreground color is retained.

[0010] In one aspect, the step of adjusting the brightness value of the foreground color comprises:

[0011] Lower the brightness value of the foreground color.

[0012] In one aspect, the step of lowering the brightness of the foreground color element comprises:

[0013] The brightness value of the foreground color is lowered by a preset adjustment coefficient.

[0014] In one aspect, the preset threshold is T, which satisfies: 3.5≤T≤5.5.

[0015] In one aspect, the step of extracting the background main color of the image includes:

[0016] The background main color of the image is calculated based on a clustering algorithm.

[0017] In one aspect, the step of calculating the contrast between the background dominant color and the foreground color comprises:

[0018] deriving a background relative brightness value based on the background main color, and deriving a foreground relative brightness value based on the foreground color;

[0019] The foreground relative brightness value is compared with the background relative brightness value to obtain a brightness contrast ratio.

[0020] In one aspect, the foreground relative brightness value is defined as L1, the background relative brightness value is defined as L2, and the contrast is defined as L, then:

[0021] L = (L1 + 0.05) / (L2 + 0.05).

[0022] In one aspect, the color components of the foreground color are defined as R1, G1, and B1, and the R1, G1, and B1 components are normalized to satisfy the following conditions:

[0023] R0=R1 / 255, G0=G1 / 255, B0=B1 / 255, where R0 represents the normalized result of the R1 component, G0 represents the normalized result of the G1 component, and B0 represents the normalized result of the B1 component;

[0024] Performing linear correction on R0, G0, and B0 respectively satisfies:

[0025] R l1 ≈(R0+0.055) / 1.055 2.4

[0026] G l1 ≈(G0+0.055) / 1.055 2.4

[0027] B l1 ≈(B0+0.055) / 1.055 2.4

[0028] R l1 Represents the linear correction result of R0 component, G l1 represents the linear correction result of G0 component, B l1 Represents the linear correction result of the B0 component, then:

[0029] L1=0.2126×R l1+0.7152×G l1 +0.0722×B l1 ;

[0030] Define the color components of the background main color as R2, G2, and B2 respectively. Normalize the R2, G2, and B2 components to meet the following conditions:

[0031] R`=R2 / 255, G`=G2 / 255, B`=B2 / 255, where R` represents the normalized result of the R2 component, G` represents the normalized result of the G2 component, and B` represents the normalized result of the B2 component;

[0032] Performing linear correction on R', G', and B' respectively satisfies:

[0033] R l2 ≈(R`+0.055) / 1.055 2.4

[0034] G l2 ≈(G`+0.055) / 1.055 2.4

[0035] B l2 ≈(B`+0.055) / 1.055 2.4

[0036] R l2 Represents the linear correction result of the R' component, G l2 represents the linear correction result of G' component, B l2 Represents the linear correction result of the B' component, then:

[0037] L2=0.2126×R l2 +0.7152×G l2 +0.0722×B l2 .

[0038] In addition, in order to solve the above problems, the present application also provides a picture style processing system, which includes:

[0039] An acquisition module, the acquisition module is used to acquire a picture and extract the background main color and the foreground color of the picture;

[0040] A calculation module, configured to calculate a brightness contrast ratio between the foreground color and the background main color;

[0041] A comparison module, configured to compare the contrast with a preset threshold;

[0042] If the contrast is less than a preset threshold, adjusting the brightness value of the foreground color so that the contrast is greater than or equal to the preset threshold;

[0043] If the contrast is greater than or equal to the preset threshold, the brightness value of the foreground color is retained.

[0044] In addition, in order to solve the above problems, the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the image style processing method described above.

[0045] The beneficial effects of the present invention are as follows: extracting the background main color and foreground color from an image, calculating the brightness contrast between the foreground color and the background main color, and then comparing the contrast with a pre-set threshold. If the contrast is less than the preset threshold, it means that the brightness of the foreground color is low and not obvious enough in the entire image, thereby adjusting the brightness value of the foreground color so that the contrast is greater than or equal to the preset threshold; if the contrast is greater than or equal to the preset threshold, it means that the foreground color is relatively obvious in the entire image, thereby retaining the brightness value of the foreground color. It can be seen that the technical solution of the present application processes the image so that the foreground color and the background color are effectively matched, making the foreground color more prominent on the background color. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly describes the drawings required for the specific embodiments or the description of the prior art. Similar elements or parts are generally identified by similar reference numerals throughout the drawings. Elements or parts in the drawings are not necessarily drawn to scale.

[0047] Figure 1 This is a schematic diagram of the process steps of the image style processing method of this application;

[0048] Figure 2 Schematic diagram of the steps of lowering the foreground color brightness value in the image style processing method of this application;

[0049] Figure 3 Schematic diagram of the steps of lowering the foreground color brightness value according to a preset adjustment coefficient in the image style processing method of this application;

[0050] Figure 4 Schematic diagram of the steps for calculating the background main color in the image style processing method of this application;

[0051] Figure 5 Schematic diagram of the steps for calculating contrast in the image style processing method of this application;

[0052] Figure 6 This is a schematic diagram of the principle of the image style processing method of this application;

[0053] Figure 7 This is a structural diagram of the digital human video generation system of this application.

[0054] Description of the drawings: 100, acquisition module; 200, calculation module; 300, comparison module. DETAILED DESCRIPTION

[0055] The following embodiments of the technical solution of the present invention will be described in detail with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention and are therefore only examples and are not intended to limit the scope of protection of the present invention.

[0056] It should be noted that, unless otherwise specified, the technical or scientific terms used in this application should have the common meanings understood by those skilled in the art to which the present invention belongs.

[0057] like Figure 1 and Figure 6 As shown, the present application provides a method for processing image style, which includes:

[0058] Step S10: Obtain an image and extract the background and foreground colors. The image can be provided by artificial intelligence or retrieved from a database. Generally, the provided image is a full-body photo. If only the upper body is shown, the algorithm can also be used to fill in the image.

[0059] Step S20, calculating the brightness contrast between the foreground color and the background main color; performing brightness comparison between the foreground color and the background main color to obtain a contrast ratio, which reflects the brightness difference between the two.

[0060] Step S30: Compare the contrast with a preset threshold; the preset threshold can be adjusted and modified as needed.

[0061] In step S31, if the contrast is less than a preset threshold, the brightness of the foreground color is adjusted so that the contrast is greater than or equal to the preset threshold. A contrast less than the preset threshold indicates that the image as a whole is light in color. To highlight the foreground color, the brightness of the foreground color can be compared to increase the contrast. For example, if the foreground color is a displayed font, the contrast can be increased to highlight the font color.

[0062] Step S32: If the contrast is greater than or equal to the preset threshold, retain the brightness value of the foreground color. If the contrast is greater than or equal to the preset threshold, it means that the image as a whole is dark, so retaining the brightness value of the current foreground color can also meet the requirements.

[0063] In this embodiment, the primary background color and foreground color are extracted from an image, the brightness contrast between the foreground color and the primary background color is calculated, and then the contrast is compared with a pre-set threshold. If the contrast is less than the preset threshold, it means that the brightness of the foreground color is low and not obvious enough in the entire image. Therefore, the brightness value of the foreground color is adjusted so that the contrast is greater than or equal to the preset threshold. If the contrast is greater than or equal to the preset threshold, it means that the foreground color is relatively obvious in the entire image, and thus the brightness value of the foreground color is retained. It can be seen that the technical solution of this application processes the image so that the foreground color and the background color are effectively matched, making the foreground color more prominent against the background color.

[0064] like Figure 2 As shown, in one embodiment of the present application, the step of adjusting the brightness value of the foreground color includes:

[0065] Step S310: lowering the brightness of the foreground color. This can make the foreground color darker, thereby making the foreground color stand out against the background main color.

[0066] like Figure 3 As shown, in one embodiment of the present application, the step of lowering the brightness of the foreground color element includes:

[0067] Step S311, lower the brightness value of the foreground color through a preset adjustment coefficient. For example, if an adjustment coefficient is set to 0.5, in the HSV (Hue, Saturation, Value) color space, assuming that the original brightness value of the foreground color is V1, the adjusted brightness value V2 = V1*0.5, so that the degree of darkening of the foreground element color can be quantitatively controlled, and the adjustment coefficient can be flexibly modified according to the actual image effect and needs to obtain the best contrast and visual effect. Assuming the adjustment coefficient is 1.5, the adjusted brightness value V2 = V1*1.5, by changing the adjustment coefficient, the degree of brightening of the foreground element color can be flexibly controlled, thereby achieving an ideal color contrast effect.

[0068] In one embodiment of the present application, the preset threshold is T, which satisfies: 3.5≤T≤5.5. The preset threshold is a criterion for determining whether the foreground color needs to be adjusted. The preset threshold T can be equal to 3.5, or can be equal to one of 4, 4.5, 5, or 5.5.

[0069] like Figure 4 As shown, in one embodiment of the present application, the step of extracting the background main color of the image includes:

[0070] Step S110, calculate the background main color of the image based on the clustering algorithm. The clustering algorithm is an unsupervised learning algorithm, which aims to divide similar data points in the data set into the same group, and there are large differences between data points in different groups. In the scenario of obtaining the style color of the image, the clustering algorithm can find the representative color from the many pixel colors of the image, that is, the style color of the image. Furthermore, the basic principle of the clustering algorithm is to define the "similarity" between data points and divide the data points into different clusters based on the similarity. Usually, similarity can be measured by distance metrics, such as Euclidean distance, Manhattan distance, etc. In color clustering, Euclidean distance is often used to calculate the difference between different colors.

[0071] like Figure 5 As shown, in one embodiment of the present application, the step of calculating the contrast between the background main color and the foreground color includes:

[0072] Step S210, the background relative brightness value is obtained according to the background main color, and the foreground relative brightness value is obtained according to the foreground color. In this embodiment, contrast mainly refers to brightness contrast, and the background relative brightness value and foreground relative brightness value can be obtained by color transformation.

[0073] In step S220 , the foreground relative brightness value is compared with the background relative brightness value to obtain a brightness contrast ratio.

[0074] In one embodiment of the present application, the foreground relative brightness value is defined as L1, the background relative brightness value is defined as L2, and the contrast is L, which satisfies: L=(L1+0.05) / (L2+0.05), and the contrast is calculated accordingly.

[0075] Furthermore, the color components of the foreground color are defined as R1, G1, and B1, and the R1, G1, and B1 components are normalized to meet the following conditions:

[0076] R0=R1 / 255, G0=G1 / 255, B0=B1 / 255, where R0 represents the normalized result of the R1 component, G0 represents the normalized result of the G1 component, and B0 represents the normalized result of the B1 component; normalization facilitates linear correction.

[0077] Performing linear correction on R0, G0, and B0 respectively satisfies:

[0078] R l1 ≈(R0+0.055) / 1.055 2.4

[0079] G l1 ≈(G0+0.055) / 1.055 2.4

[0080] Bl1 ≈(B0+0.055) / 1.055 2.4

[0081] R l1 Represents the linear correction result of R0 component, G l1 represents the linear correction result of G0 component, B l1 Represents the linear correction result of the B0 component, then:

[0082] L1=0.2126×R l1 +0.7152×G l1 +0.0722×B l1 ; Thus, the relative brightness of the foreground is obtained through the transformation of RGB colors.

[0083] Define the color components of the background main color as R2, G2, and B2 respectively. Normalize the R2, G2, and B2 components to meet the following requirements:

[0084] R`=R2 / 255, G`=G2 / 255, B`=B2 / 255, where R` represents the normalized result of the R2 component, G` represents the normalized result of the G2 component, and B` represents the normalized result of the B2 component; normalization facilitates linear correction.

[0085] Performing linear correction on R', G', and B' respectively satisfies:

[0086] R l2 ≈(R`+0.055) / 1.055 2.4

[0087] G l2 ≈(G`+0.055) / 1.055 2.4

[0088] B l2 ≈(B`+0.055) / 1.055 2.4

[0089] R l2 Represents the linear correction result of the R' component, G l2 represents the linear correction result of G' component, B l2 Represents the linear correction result of the B' component, then:

[0090] L2=0.2126×R l2 +0.7152×G l2 +0.0722×B l2 The relative brightness of the foreground is obtained by transforming the RGB color.

[0091] For example, the background main color is 3A7BD5 (hexadecimal), where 3A is R2, 7B is G2, and D5 is B2. Converting it to decimal, R2 is converted to 58, G2 is converted to 123, and B2 is converted to 213.

[0092] Normalize, R`=R2 / 255=58 / 255≈0.227, G`=G2 / 255=123 / 255≈0.482, B`=B2 / 255=213 / 255≈0.835, and perform gamma correction on each component, that is, linear correction:

[0093] R l2 ≈(R`+0.055) / 1.055 2.4 =(0.227+0.055) / 1.055 2.4 =0.042;

[0094] G l2 ≈(G`+0.055) / 1.055 2.4 =(0.482+0.055) / 1.055 2.4 =0.200;

[0095] B l2 ≈(B`+0.055) / 1.055 2.4 =(0.835+0.055) / 1.055 2.4 =0.743;

[0096] thus:

[0097] L2=0.2126×R l2 +0.7152×G l2 +0.0722×B l2 =0.2126×0.042+0.7152×0.200+0.072

[0098] 2×0.743≈0.209. Assuming L1=1.0, then the contrast L=(L1+0.05) / (L2+0.05)=(1.0+0.05) / (0.209+0.05)=4.07. If the preset threshold is 4.5, then the foreground color should be adjusted to make it more prominent and more readable.

[0099] like Figure 7 As shown, the present application also provides a picture style processing system, which includes: an acquisition module 100, a calculation module 200 and a comparison module 300.

[0100] The acquisition module 100 is used to acquire an image and extract the background and foreground colors. The image can be provided by artificial intelligence or retrieved from a database. Generally, the provided image is a full-body photo. If the photo only shows the upper body, an algorithm can also be used to fill in the image.

[0101] The calculation module 200 is used to calculate the brightness contrast between the foreground color and the background main color; the foreground color and the background main color are compared in brightness to obtain the contrast, which reflects the brightness difference between the two.

[0102] The contrast module 300 is used to compare the contrast with a preset threshold; if the contrast is less than the preset threshold, the brightness value of the foreground color is adjusted so that the contrast is greater than or equal to the preset threshold; if the contrast is greater than or equal to the preset threshold, the brightness value of the foreground color is retained. The preset threshold can be adjusted and modified as needed. If the contrast is less than the preset threshold, it means that the image as a whole belongs to the light color system. In this way, in order to highlight the foreground color, the brightness value of the foreground color can be compared to increase the contrast. For example, if the foreground color is the displayed font, the contrast can be increased to highlight the font color. If the contrast is greater than or equal to the preset threshold, it means that the image as a whole belongs to the dark color system. In this way, retaining the brightness value of the current foreground color can also meet the requirements.

[0103] The specific embodiments and beneficial effects of the picture style processing system in this application can be found in the above-mentioned picture style processing method, which will not be repeated here.

[0104] The present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the image style processing method as described above is implemented.

[0105] The specific embodiments and beneficial effects of the computer-readable storage medium in this application can be found in the above-mentioned image style processing method, which will not be repeated here.

[0106] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some or all of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and description of the present invention.

Claims

1. A method for image style processing, characterized in that: The processing method comprises: Obtain a picture, and extract the background main color and the foreground color of the picture; Calculating the brightness contrast between the foreground color and the background main color; comparing the contrast with a preset threshold; If the contrast is less than the preset threshold, adjusting the brightness value of the foreground color so that the contrast is greater than or equal to the preset threshold; If the contrast is greater than or equal to the preset threshold, the brightness value of the foreground color is retained.

2. The processing method according to claim 1, characterized in that The step of adjusting the brightness value of the foreground color includes: Lower the brightness value of the foreground color.

3. The processing method according to claim 2, characterized in that The step of lowering the brightness of the foreground color element comprises: The brightness value of the foreground color is lowered by a preset adjustment coefficient.

4. The processing method according to claim 1, characterized in that The preset threshold is T, which satisfies: 3.5≤T≤5.

5.

5. The processing method according to claim 1, characterized in that The step of extracting the background main color of the image includes: The background main color of the image is calculated based on a clustering algorithm.

6. The processing method according to claim 1, characterized in that The step of calculating the contrast between the background main color and the foreground color comprises: deriving a background relative brightness value based on the background main color, and deriving a foreground relative brightness value based on the foreground color; The foreground relative brightness value is compared with the background relative brightness value to obtain a brightness contrast ratio.

7. The processing method according to claim 6, characterized in that Define the foreground relative brightness value as L1, the background relative brightness value as L2, and the contrast as L, then: L = (L1 + 0.05) / (L2 + 0.05).

8. The processing method according to claim 7, characterized in that: The color components of the foreground color are defined as R1, G1, and B1, and the R1, G1, and B1 components are normalized to meet the following conditions: R0=R1 / 255, G0=G1 / 255, B0=B1 / 255, where R0 represents the normalized result of the R1 component, G0 represents the normalized result of the G1 component, and B0 represents the normalized result of the B1 component; Performing linear correction on R0, G0, and B0 respectively satisfies: R l1 ≈(R0+0.055) / 1.055 2.4 G l1 ≈(G0+0.055) / 1.055 2.4 B l1 ≈(B0+0.055) / 1.055 2.4 R l1 Represents the linear correction result of R0 component, G l1 represents the linear correction result of G0 component, B l1 Represents the linear correction result of the B0 component, then: L1=0.2126×R l1 +0.7152×G l1 +0.0722×B l1 , Define the color components of the background main color as R2, G2, and B2 respectively. Normalize the R2, G2, and B2 components to meet the following conditions: R`=R2 / 255, G`=G2 / 255, B`=B2 / 255, where R` represents the normalized result of the R2 component, G` represents the normalized result of the G2 component, and B` represents the normalized result of the B2 component; Performing linear correction on R', G', and B' respectively satisfies: R l2 ≈(R`+0.055) / 1.055 2.4 G l2 ≈(G`+0.055) / 1.055 2.4 B l2 ≈(B`+0.055) / 1.055 2.4 R l2 Represents the linear correction result of the R' component, G l2 represents the linear correction result of G' component, B l2 Represents the linear correction result of the B' component, then: <h2 style=";text-align:left;direction:ltr">L2=0.2126×R<h2 style=";text-align:left;direction:ltr"> l2 <h2 style=";text-align:left;direction:ltr"> +0.7152×G<h2 style=";text-align:left;direction:ltr"> l2 <h2 style=";text-align:left;direction:ltr"> +0.0722×B<h2 style=";text-align:left;direction:ltr"> l2 <h2 style=";text-align:left;direction:ltr"> 。 9. A picture style processing system, characterized in that: The processing system comprises: An acquisition module, the acquisition module is used to acquire a picture and extract the background main color and the foreground color of the picture; A calculation module, configured to calculate a brightness contrast ratio between the foreground color and the background main color; A comparison module, configured to compare the contrast with a preset threshold; If the contrast is less than a preset threshold, adjusting the brightness value of the foreground color so that the contrast is greater than or equal to the preset threshold; If the contrast is greater than or equal to the preset threshold, the brightness value of the foreground color is retained.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processing method according to any one of claims 1 to 8 is implemented.