A copywriting color matching method and device, electronic equipment and storage medium

By analyzing the color information and text semantics of the banner background image, a color saliency map is generated, and the color selection of the copy is automatically optimized. This solves the problems of poor readability and low efficiency of the copy color scheme, and achieves good matching with the banner style and efficient color matching.

CN115147503BActive Publication Date: 2026-02-03BEIJING SANKUAI ONLINE TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110343800.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-30
Publication Date
2026-02-03
Estimated Expiration
2041-03-30

AI Technical Summary

Technical Problem

In existing technologies, copywriting color schemes suffer from poor readability, poor color matching with banner style, and low color matching efficiency.

Method used

By obtaining the color information of the banner background image, analyzing it using HSV and Lab color spaces, generating a color saliency map, and combining text semantics and color mapping relationships, the text color is automatically determined to meet constraints such as brightness, hue, and saturation, thus optimizing the text color selection.

Benefits of technology

It achieves a good match between the text color and the banner style, improves readability and color matching efficiency, reduces manual intervention, and enhances the prominence of the text in the banner.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115147503B_ABST
    Figure CN115147503B_ABST
Patent Text Reader

Abstract

The application provides a text color matching method and device, electronic equipment and storage medium. The method comprises: obtaining a background picture for displaying a target text to be matched, and position information of the target text in the background picture; obtaining color information of the background picture in an HSV color space and a Lab color space; obtaining a color saliency map of the background picture relative to a region where the target text is located based on the color information and a constraint condition of text color matching, and obtaining at least one alternative text color in the color saliency map; wherein the constraint condition comprises at least one of a brightness constraint condition, a hue constraint condition, a saturation constraint condition and a lightness constraint condition, and the constraint condition is obtained based on the color information; and obtaining a final text color of the target text from the alternative text color. Thus, the beneficial effects of not needing to manually set the alternative color of the text in advance, improving the readability of the text color matching, and improving the matching degree with the background color are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a text color matching method, apparatus, electronic device, and storage medium. Background Technology

[0002] In the design of smart banner ads, the copy is the main element that attracts users' attention. The copy content needs to stand out from the banner and be presented to users with good visual readability.

[0003] There are two common text color schemes: One approach is to analyze the background color information of the text area in the banner and pre-set some alternative colors for matching. However, matching colors can only guarantee contrast and cannot achieve a match with the overall style of the banner. The other approach is to consider the style of each banner and set a separate set of corresponding text color schemes based on the background and other decorations. This method requires a significant investment of manpower to change the banner background and requires a corresponding set of text color schemes.

[0004] The above analysis shows that the aforementioned copywriting color scheme has problems such as poor readability, poor matching effect with the banner style, and low color matching efficiency. Summary of the Invention

[0005] This invention provides a text color matching method, apparatus, electronic device, and storage medium to solve the problems of poor readability, poor matching effect with banner style, and low color matching efficiency in related technologies.

[0006] To solve the above-mentioned technical problems, the present invention is implemented as follows:

[0007] In a first aspect, embodiments of the present invention provide a text color matching method, including:

[0008] Obtain the background image used to display the target text to be matched with the color scheme, and the position information of the target text in the background image;

[0009] Obtain the color information of the background image in the HSV color space and the Lab color space; wherein, the color information includes at least one of the following: the first average color value of the background area in the background image used to display the target text in the HSV color space, the second average color value of the background area in the Lab color space, the first background image converted to the HSV color space, and the second background image converted to the Lab color space;

[0010] Based on the color information and the constraints of the text color scheme, a color saliency map of the background image relative to the area where the target text is located is obtained, and at least one alternative text color is obtained from the color saliency map; wherein, the constraints include at least one of lightness constraints, hue constraints, saturation constraints, and brightness constraints, and the constraints are set based on the color information;

[0011] Obtain the final text color of the target text from the candidate text colors.

[0012] Optionally, the step of obtaining the color information of the background image in the HSV color space and the Lab color space includes:

[0013] In the RGB color space, a Gaussian filter is applied to the background image;

[0014] Obtain the background area for displaying the target text from the background image after Gaussian filtering;

[0015] The first average color value of the background area in the HSV color space and the second average color value of the background area in the Lab color space are obtained; wherein, the first average color value includes the average hue, average saturation, and average lightness, and the second average color value includes at least the average brightness.

[0016] The background image after Gaussian filtering is converted to the HSV color space and the Lab color space respectively to obtain the first background image and the second background image.

[0017] Optionally, the step of obtaining a color saliency map of the background image relative to the area where the target text is located based on the color information and the constraints of the text color scheme, and obtaining at least one alternative text color from the color saliency map, includes:

[0018] Based on the first background image and the second background image, a saliency map that satisfies the constraints under each color parameter is obtained. The color parameter includes at least one of hue, saturation, brightness, and luminance.

[0019] Based on the saliency map under each color parameter, a color saliency map of the background image relative to the area where the target text is located is obtained. The color value of each pixel in the color saliency map is determined according to the color parameter of the pixel at the same coordinate position in the corresponding saliency map.

[0020] Obtain the target pixel point whose color value is greater than a preset color threshold in the color saliency map, and obtain the color of the pixel point in the first background image that has the same coordinates as the target pixel point as the color of the target pixel point;

[0021] The K colors with the highest number of target pixels are selected as candidate text colors, where K is a positive integer.

[0022] Optionally, the step of obtaining saliency maps that satisfy the constraints under each color parameter based on the first background image and the second background image includes:

[0023] Based on the hue value of each pixel in the first background image, the pixel region in the first background image whose hue value satisfies the hue constraint condition is obtained to obtain a hue saliency map. The hue constraint condition includes the absolute value of the difference between the hue value of the pixel and the average hue value within a first value range.

[0024] And / or, based on the saturation value of each pixel in the first background image, mark the pixel regions in the first background image whose saturation values ​​satisfy the saturation constraint conditions to obtain a saturation saliency map, wherein the saturation constraint conditions include the saturation value of the pixel being higher than the saturation threshold;

[0025] And / or, based on the brightness value of each pixel in the first background image, mark the pixel regions in the first background image whose brightness values ​​satisfy the brightness constraint conditions to obtain a brightness saliency map, wherein the brightness constraint conditions include the brightness value of the pixel being higher than the brightness threshold;

[0026] And / or, based on the brightness value of each pixel in the second background image, mark the pixel regions in the second background image whose brightness values ​​satisfy the brightness constraint conditions to obtain a brightness saliency map, wherein the brightness constraint conditions include the absolute value of the difference between the brightness value of the pixel and the brightness threshold within a second value range.

[0027] Optionally, the step of obtaining a color saliency map of the background image relative to the area where the target text is located based on the saliency map under each color parameter, wherein the color value of each pixel in the color saliency map is determined according to the color parameter of the pixel at the same coordinate position in the corresponding saliency map, includes:

[0028] For a saliency map under any color parameter, the value of the color parameter of each pixel in the saliency map is normalized.

[0029] For any pixel in the color saliency map, the color value of the pixel is obtained by multiplying the values ​​of the color parameters of the corresponding coordinate positions in the saliency map under each color parameter.

[0030] Optionally, the step of selecting the K colors with the highest number of target pixels as candidate text colors includes:

[0031] The color of the target pixel is converted to the RGB color space, and the number of target pixels under each color is counted in the RGB color space;

[0032] In addition to the specified color, the K colors with the highest number of target pixels in the RGB color space are selected as the text colors.

[0033] Optionally, before the step of obtaining the final text color of the target text from the candidate text colors, the method further includes:

[0034] Obtain keywords from the semantic meaning of the target text;

[0035] By using a keyword-color mapping model, colors that have a mapping relationship with each keyword are obtained and used as candidate text colors for the target text.

[0036] The keyword-color mapping model is trained using sample texts of multiple known keywords and sample images that have a mapping relationship with each keyword.

[0037] Optionally, before the step of obtaining the color that has a mapping relationship with each of the keywords through the keyword-color mapping relationship model, and using it as a candidate text color for the target text, the method further includes:

[0038] Extract the keywords from each sample text and use them as sample keywords;

[0039] For any of the sample keywords, perform image retrieval using the sample keywords as query terms, and obtain the L images with the highest matching degree to the sample keywords, which are used as sample images related to the sample keywords, where L is a positive integer;

[0040] Extract the M colors with the highest number of pixels in each sample image related to the same sample keyword, and perform cluster analysis on the colors of each sample image related to the same sample keyword to obtain the N highest colors as candidate colors that have a mapping relationship with the sample keyword, thereby forming a mapping relationship model between keywords and colors.

[0041] Optionally, before the step of obtaining the final text color of the target text from the candidate text colors, the method further includes:

[0042] Obtain the background color information of the text area in the background image, and determine the color brightness of the text area based on the background color information and the brightness threshold. The text area is the background area in the background image used to display the target text. The background color information includes at least one of the first color average value of the text area in the HSV color space and the second color average value of the text area in the Lab color space.

[0043] Based on the color brightness results, a color that satisfies readability is obtained from the background color information of the text area and used as a candidate text color for the target text.

[0044] Optionally, the step of obtaining the final text color of the target text from the candidate text colors includes:

[0045] Based on the background color of the background image and the proportion of the target text area relative to the background image, a color sorting model is used to obtain the color matching score for each candidate text.

[0046] The candidate text color with the highest matching score is selected as the text color of the target text in the background image.

[0047] Secondly, embodiments of the present invention provide another method for text color matching, including:

[0048] Obtain keywords from the semantic meaning of the target text;

[0049] By using a keyword-color mapping model, colors that have a mapping relationship with each keyword are obtained and used as candidate text colors for the target text.

[0050] Obtain the final text color of the target text from the candidate text colors.

[0051] The keyword-color mapping model is trained using sample texts of multiple known keywords and sample images that have a mapping relationship with each keyword.

[0052] Optionally, before the step of obtaining the color that has a mapping relationship with each of the keywords through the keyword-color mapping relationship model, and using it as a candidate text color for the target text, the method further includes:

[0053] Extract the keywords from each sample text and use them as sample keywords;

[0054] For any of the sample keywords, perform image retrieval using the sample keywords as query terms, and obtain the L images with the highest matching degree to the sample keywords, which are used as sample images related to the sample keywords, where L is a positive integer;

[0055] Extract the M colors with the highest number of pixels in each sample image related to the same sample keyword, and perform cluster analysis on the colors of each sample image related to the same sample keyword to obtain the N highest colors as candidate colors that have a mapping relationship with the sample keyword, thereby forming a mapping relationship model between keywords and colors.

[0056] Optionally, before the step of obtaining the final text color of the target text from the candidate text colors, the method further includes:

[0057] Obtain the background image used to display the target text to be matched with the color scheme, and the position information of the target text in the background image;

[0058] Obtain the color information of the background image in the HSV color space and the Lab color space; wherein, the color information includes at least one of the following: the first average color value of the background area in the background image used to display the target text in the HSV color space, the second average color value of the background area in the Lab color space, the first background image converted to the HSV color space, and the second background image converted to the Lab color space;

[0059] Based on the color information and the constraints of the text color scheme, a color saliency map of the background image relative to the area where the target text is located is obtained, and at least one alternative text color is obtained from the color saliency map; wherein, the constraints include at least one of lightness constraints, hue constraints, saturation constraints, and brightness constraints, and the constraints are set based on the color information.

[0060] Optionally, before the step of obtaining the final text color of the target text from the candidate text colors, the method further includes:

[0061] Obtain the background color information of the text area in the background image, and determine the color brightness of the text area based on the background color information and the brightness threshold. The text area is the background area in the background image used to display the target text. The background color information includes at least one of the first color average value of the text area in the HSV color space and the second color average value of the text area in the Lab color space.

[0062] Based on the color brightness results, a color that satisfies readability is obtained from the background color information of the text area and used as a candidate text color for the target text.

[0063] Thirdly, embodiments of the present invention provide a text color matching device, including:

[0064] The background image acquisition module is used to acquire a background image for displaying the target text to be matched with colors, as well as the position information of the target text in the background image;

[0065] The color information acquisition module is used to acquire the color information of the background image in the HSV color space and the Lab color space; wherein, the color information includes at least one of the following: the first average color value of the background area of ​​the background image used to display the target text in the HSV color space, the second average color value of the background area in the Lab color space, the first background image converted to the HSV color space, and the second background image converted to the Lab color space;

[0066] The first candidate color acquisition module is used to acquire a color saliency map of the background image relative to the area where the target text is located, based on the color information and the constraints of the text color scheme, and to acquire at least one candidate text color in the color saliency map; wherein, the constraints include at least one of lightness constraints, hue constraints, saturation constraints, and brightness constraints, and the constraints are set based on the color information.

[0067] The text color acquisition module is used to obtain the final text color of the target text from the candidate text colors.

[0068] Optionally, the color information acquisition module includes:

[0069] The Gaussian filtering submodule is used to perform Gaussian filtering on the background image in the RGB color space;

[0070] The text area acquisition submodule is used to acquire the background area for displaying the target text from the background image after Gaussian filtering;

[0071] The color average acquisition submodule is used to acquire the first color average value of the background area in the HSV color space and the second color average value of the background area in the Lab color space; wherein, the first color average value includes the hue average value, the saturation average value, and the lightness average value, and the second color average value includes at least the lightness average value.

[0072] The color space conversion submodule is used to convert the background image after Gaussian filtering to the HSV color space and the Lab color space respectively, to obtain the first background image and the second background image.

[0073] Optionally, the first candidate color acquisition module includes:

[0074] The unit parameter saliency map acquisition submodule is used to acquire saliency maps that satisfy the constraints under each color parameter based on the first background image and the second background image, wherein the color parameters include at least one of hue, saturation, brightness, and luminance.

[0075] The color saliency map acquisition submodule is used to acquire the color saliency map of the background image relative to the area where the target text is located, based on the saliency map under each color parameter. The color value of each pixel in the color saliency map is determined according to the color parameter of the pixel at the same coordinate position in the corresponding saliency map.

[0076] The target pixel acquisition submodule is used to acquire target pixels whose color value is greater than a preset color threshold in the color saliency map, and to acquire the color of the pixel in the first background image that has the same coordinates as the target pixel as the color of the target pixel.

[0077] The first candidate color acquisition submodule is used to count the K colors with the most target pixels as candidate text colors, where K is a positive integer.

[0078] Optionally, the unit parameter saliency map acquisition submodule is specifically used for:

[0079] Based on the hue value of each pixel in the first background image, the pixel region in the first background image whose hue value satisfies the hue constraint condition is obtained to obtain a hue saliency map. The hue constraint condition includes the absolute value of the difference between the hue value of the pixel and the average hue value within a first value range.

[0080] And / or, based on the saturation value of each pixel in the first background image, mark the pixel regions in the first background image whose saturation values ​​satisfy the saturation constraint conditions to obtain a saturation saliency map, wherein the saturation constraint conditions include the saturation value of the pixel being higher than the saturation threshold;

[0081] And / or, based on the brightness value of each pixel in the first background image, mark the pixel regions in the first background image whose brightness values ​​satisfy the brightness constraint conditions to obtain a brightness saliency map, wherein the brightness constraint conditions include the brightness value of the pixel being higher than the brightness threshold;

[0082] And / or, based on the brightness value of each pixel in the second background image, mark the pixel regions in the second background image whose brightness values ​​satisfy the brightness constraint conditions to obtain a brightness saliency map, wherein the brightness constraint conditions include the absolute value of the difference between the brightness value of the pixel and the brightness threshold within a second value range.

[0083] Optionally, the color saliency map acquisition submodule is specifically used for:

[0084] For a saliency map under any color parameter, the value of the color parameter of each pixel in the saliency map is normalized.

[0085] For any pixel in the color saliency map, the color value of the pixel is obtained by multiplying the values ​​of the color parameters of the corresponding coordinate positions in the saliency map under each color parameter.

[0086] Optionally, the first candidate color acquisition submodule is specifically used for:

[0087] The color of the target pixel is converted to the RGB color space, and the number of target pixels under each color is counted in the RGB color space;

[0088] In addition to the specified color, the K colors with the highest number of target pixels in the RGB color space are selected as the text colors.

[0089] Optionally, the device further includes:

[0090] The keyword acquisition module is used to acquire keywords from the semantic meaning of the target text.

[0091] The second candidate color acquisition module is used to acquire colors that have a mapping relationship with each of the keywords through a keyword-color mapping relationship model, and use them as candidate text colors for the target text.

[0092] The keyword-color mapping model is trained using sample texts of multiple known keywords and sample images that have a mapping relationship with each keyword.

[0093] Optionally, the device further includes:

[0094] The sample keyword acquisition module is used to extract keywords from each sample text and use them as sample keywords.

[0095] The image retrieval module is used to perform image retrieval for any of the sample keywords, using the sample keywords as query terms, and to obtain the L images with the highest matching degree with the sample keywords as sample images related to the sample keywords, where L is a positive integer;

[0096] The mapping relationship construction module is used to extract the M colors with the highest number of pixels in each sample image related to the same sample keyword, and perform cluster analysis on the colors of each sample image related to the same sample keyword to obtain the N highest colors as candidate colors that have a mapping relationship with the sample keyword, thereby forming a mapping relationship model between keywords and colors.

[0097] Optionally, the device further includes:

[0098] The color brightness and darkness determination module is used to obtain the background color information of the text area in the background image, and to determine the color brightness and darkness result of the text area based on the background color information and the brightness and darkness boundary threshold. The text area is the background area in the background image used to display the target text. The background color information includes at least one of the first color average value of the text area in the HSV color space and the second color average value of the text area in the Lab color space.

[0099] The third candidate color acquisition module is used to obtain a color that meets readability requirements from the background color information of the text area based on the color brightness result, and use it as a candidate text color for the target text.

[0100] Optionally, the text color acquisition module includes:

[0101] The matching score prediction module is used to obtain the matching score of each candidate text color based on the background color of the background image and the text area ratio of the target text relative to the background image through a color sorting model.

[0102] The text color determination module is used to obtain the candidate text color with the highest matching score, and use it as the text color of the target text in the background image.

[0103] Fourthly, embodiments of the present invention provide another text color matching device, including:

[0104] The keyword acquisition module is used to acquire keywords from the semantic meaning of the target text.

[0105] The second candidate color acquisition module is used to acquire colors that have a mapping relationship with each of the keywords through a keyword-color mapping relationship model, and use them as candidate text colors for the target text.

[0106] The text color acquisition module is used to acquire the final text color of the target text from the candidate text colors;

[0107] The keyword-color mapping model is trained using sample texts of multiple known keywords and sample images that have a mapping relationship with each keyword.

[0108] Optionally, the device further includes:

[0109] The sample keyword acquisition module is used to extract keywords from each sample text and use them as sample keywords.

[0110] The image retrieval module is used to perform image retrieval for any of the sample keywords, using the sample keywords as query terms, and to obtain the L images with the highest matching degree with the sample keywords as sample images related to the sample keywords, where L is a positive integer;

[0111] The mapping relationship construction module is used to extract the M colors with the highest number of pixels in each sample image related to the same sample keyword, and perform cluster analysis on the colors of each sample image related to the same sample keyword to obtain the N highest colors as candidate colors that have a mapping relationship with the sample keyword, thereby forming a mapping relationship model between keywords and colors.

[0112] Optionally, the device further includes:

[0113] The background image acquisition module is used to acquire a background image for displaying the target text to be matched with colors, as well as the position information of the target text in the background image;

[0114] The color information acquisition module is used to acquire the color information of the background image in the HSV color space and the Lab color space; wherein, the color information includes at least one of the following: the first average color value of the background area of ​​the background image used to display the target text in the HSV color space, the second average color value of the background area in the Lab color space, the first background image converted to the HSV color space, and the second background image converted to the Lab color space;

[0115] The first candidate color acquisition module is used to acquire a color saliency map of the background image relative to the area where the target text is located based on the color information and the constraints of the text color scheme, and to acquire at least one candidate text color in the color saliency map; wherein, the constraints include at least one of lightness constraints, hue constraints, saturation constraints, and brightness constraints, and the constraints are set based on the color information.

[0116] Optionally, the device further includes:

[0117] The color brightness and darkness determination module is used to obtain the background color information of the text area in the background image, and to determine the color brightness and darkness result of the text area based on the background color information and the brightness and darkness boundary threshold. The text area is the background area in the background image used to display the target text. The background color information includes at least one of the first color average value of the text area in the HSV color space and the second color average value of the text area in the Lab color space.

[0118] The third candidate color acquisition module is used to obtain a color that meets readability requirements from the background color information of the text area based on the color brightness result, and use it as a candidate text color for the target text.

[0119] Fifthly, embodiments of the present invention further provide an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the text color matching method as described in the first and second aspects.

[0120] In a sixth aspect, embodiments of the present invention further provide a computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the text color matching method as described in the first and second aspects.

[0121] In this embodiment of the invention, by analyzing the color information of the banner background image, with the aim of color readability and prominence, the color scheme of the text is generated from dimensions such as brightness, saturation, and hue. The color scheme has the advantages of good readability and color matching with the background decorative elements. At the same time, the text content is analyzed, and the semantic color of the text is mined using web crawling and clustering analysis techniques, so that it is more in line with the style and concept expressed by the poster on an aesthetic basis. In the process of building the matching degree model, colors from multiple color spaces are used, and information such as position and area are added as input features of the model.

[0122] Moreover, the technical solution provided by the embodiments of the present invention does not require manual setting of alternative colors for the text in advance. The text color is obtained from the analysis of the banner background with the aim of color readability and prominence. A color saliency map is generated from multiple dimensions such as brightness, saturation, and hue of the color, and the obtained color can make the text recognition more prominent.

[0123] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description

[0124] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0125] Figure 1 This is a flowchart illustrating the steps of a text color matching method in an embodiment of the present invention;

[0126] Figure 2A This is a poster example from an embodiment of the present invention;

[0127] Figure 2B This is a schematic diagram of a visual logic line in an embodiment of the present invention;

[0128] Figure 3 This is a flowchart of another text color matching method in an embodiment of the present invention;

[0129] Figure 4 This is a schematic diagram of a visually salient color recall process in an embodiment of the present invention;

[0130] Figure 5 This is a flowchart of another text color matching method in an embodiment of the present invention;

[0131] Figure 6 This is a schematic diagram of a color recall process based on light and dark contrast in an embodiment of the present invention;

[0132] Figure 7 This is a schematic diagram of a text color matching process in an embodiment of the present invention;

[0133] Figure 8 This is a flowchart of another text color matching method in an embodiment of the present invention;

[0134] Figure 9 This is a schematic diagram of the structure of a text color matching device according to an embodiment of the present invention;

[0135] Figure 10 This is a schematic diagram of another text color matching device in an embodiment of the present invention;

[0136] Figure 11 This is a schematic diagram of another text color matching device in an embodiment of the present invention;

[0137] Figure 12 This is a schematic diagram of another text color matching device in an embodiment of the present invention;

[0138] Figure 13This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0139] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0140] Reference Figure 1 The diagram illustrates a flowchart of a text color matching method according to an embodiment of the present invention.

[0141] Step 110: Obtain the background image used to display the target text to be matched with color, and the position information of the target text in the background image;

[0142] Step 120: Obtain the color information of the background image in the HSV color space and the Lab color space; wherein, the color information includes at least one of the following: the first average color value of the background area in the background image used to display the target text in the HSV color space, the second average color value of the background area in the Lab color space, the first background image converted to the HSV color space, and the second background image converted to the Lab color space;

[0143] Step 130: Based on the color information and the constraints of the text color scheme, obtain the color saliency map of the background image relative to the area where the target text is located, and obtain at least one alternative text color from the color saliency map; wherein, the constraints include at least one of the lightness constraints, hue constraints, saturation constraints, and brightness constraints, and the constraints are set based on the color information;

[0144] Step 140: Obtain the final text color of the target text from the candidate text colors.

[0145] In practical applications, the poster generation process is characterized by large production volume and diverse styles. Moreover, copywriting is an important part of poster design. Copywriting design needs to ensure that the text colors are clear against the background, have strong contrast, match the background colors, and conform to the overall style.

[0146] Therefore, in this embodiment of the invention, the proposed text color matching process is to determine the text color matching by referring to the background color contained in the background image used to display the text based on visual salience, so as to achieve a color matching effect that highlights the text content and conforms to the overall style of the poster.

[0147] Visual salience, in particular, considers the visual logic that guides users through the poster's viewing process. Visual points should be prominent and responsive. By extracting potential salience colors from the poster's background image and using them as text colors, the prominence of the text can be enhanced, and it should also align with the overall style of the poster. For example... Figure 2A The image shown is an example of a poster, such as... Figure 2B As shown Figure 2A A schematic diagram of the visual logic lines for each part of the poster shown.

[0148] The specific implementation scheme can be as follows: Based on the color information of the poster background, that is, the background image used to display the target text, in the HSV (Hue, Saturation, Value) color space and in the Lab color space, and based on the visual saliency characteristics, obtain the color saliency map of the background image relative to the text area from at least one of the four constraints: color contrast, color hue (i.e., hue), color saturation, and color brightness, and then obtain the text color from the color saliency map.

[0149] The text area can be understood as the background area in the background image used to display the target text. In this embodiment of the invention, the text area can be determined in the background image based on the size of the target text, the display coordinates of the target text in the background image, and other positional information. This embodiment of the invention does not limit this.

[0150] The Lab color space consists of three elements: lightness (L), a and b are two color channels. A includes colors ranging from dark green (low lightness value) to gray (medium lightness value) to bright pink (high lightness value); b includes colors ranging from bright blue (low lightness value) to gray (medium lightness value) to yellow (high lightness value).

[0151] Color information may include the first color average value Y of the background area in the background image used to display the target text in the HSV color space. HSV =(Y H ,Y S ,Y V The background area's second color average value X in the Lab color space Lab =(X L X a ,X bThe background image can be at least one of the following: a first background image converted to the HSV color space, and a second background image converted to the Lab color space. The specific content included in the color information can be customized as needed, and this embodiment of the invention does not limit this. For example, the color information of the corresponding background image can be obtained based on the color information targeted by the set constraints. Moreover, in this embodiment of the invention, any of the above-mentioned color information can be obtained through any available method, and this embodiment of the invention does not limit this either.

[0152] Furthermore, based on the acquired color information and the constraints of each text color scheme, a saliency map can be obtained from the background image relative to the area where the target text is located, which can be used to determine the color of the target text. Then, based on the saliency map under each constraint, a color saliency map satisfying each constraint can be obtained; that is, the color saliency map of the background image relative to the area where the target text is located. The background area that can be used to determine the color of the target text can be marked in the color saliency map. Therefore, at least one candidate text color can be obtained from the color saliency map; for example, at least one color with the highest percentage in the color saliency map can be selected as a candidate text color; and so on.

[0153] Furthermore, in this embodiment of the invention, when acquiring color information, constraints set for the text color scheme of the current background image can be referenced. For example, if the constraints include a brightness constraint, the acquired color information can include a first background image converted to the HSV color space to obtain the brightness value of each pixel in the background image. Moreover, the constraints can also be set based on the color information. For instance, if the brightness constraint includes a brightness threshold, to determine a reasonable brightness constraint, the first average color value of the background area used to display the target text in the HSV color space can be obtained, thereby obtaining the average brightness value of the text area to determine the brightness threshold included in the brightness constraint, and so on.

[0154] Then, based on the color information and the constraints of the text color scheme, a color saliency map of the background image relative to the target text area can be obtained. This color saliency map can include all regions in the original background image that satisfy the aforementioned constraints, and the color in each region is retained as the color of the corresponding pixel in the background image. At this point, the colors in these regions can be used as candidate colors for the target text.

[0155] Furthermore, color salience maps may contain a large number of colors, and the proportions of different colors within the map will vary. If all colors in the color salience map were used as candidate text colors, it would result in too many choices, and the visual effects of colors with different proportions would also differ. Therefore, at least one color should be selected from the color salience map as a candidate text color.

[0156] The method for obtaining candidate text colors from the color saliency map can be customized as needed, and this embodiment of the invention does not limit this. Furthermore, the number of candidate text colors obtained from the color saliency map can also be customized as needed, and this embodiment of the invention does not limit this. For example, at least one color with the highest pixel percentage under each color in the color saliency map can be selected as a candidate text color.

[0157] When color matching a target text, the final text color can be obtained from the various candidate text colors. Furthermore, one can choose a single candidate text color as the final target text color, or multiple candidate text colors can be combined to form the final target text color; this embodiment of the invention does not limit this. The method of obtaining the final target text color from the candidate text colors can also be customized according to requirements; this embodiment of the invention does not limit this.

[0158] For example, the final text color of the target text can be selected from candidate colors based on factors such as the text content of the target text and its readability relative to the background. Alternatively, the output scores of a color matching model can be used to rank the candidate text colors. This model can be trained using data from designers' offline annotations on whether background and text colors match (e.g., good, bad, average), and features such as text color, background color, and text area ratio, using an SVM. The highest-ranked candidate text color can then be selected as the final target text color. And so on.

[0159] It should also be noted that in this embodiment of the invention, if it is not necessary to refer to the first average color value of the background area of ​​the target text in the HSV color space and the second average color value of the background area in the Lab color space when determining the constraints, then when obtaining color information in step 120, the first average color value and the second average color value may not be obtained, and only the information currently required may be obtained. This embodiment of the invention does not limit this.

[0160] Reference Figure 3 In another embodiment, step 120 may further include:

[0161] Step 121: Perform Gaussian filtering on the background image in the RGB color space;

[0162] Step 122: Obtain the background area for displaying the target text from the background image after Gaussian filtering;

[0163] Step 123: Obtain the first average color value of the background area in the HSV color space and the second average color value of the background area in the Lab color space; wherein, the first average color value includes the average hue, average saturation, and average brightness, and the second average color value includes at least the average brightness.

[0164] Step 124: Convert the background image after Gaussian filtering to the HSV color space and the Lab color space respectively to obtain the first background image and the second background image.

[0165] Gaussian filtering is a linear smoothing filter suitable for eliminating Gaussian noise and widely used in image processing for noise reduction. Simply put, Gaussian filtering is a weighted average process applied to the entire image; the value of each pixel is obtained by weighted averaging of its own value and the values ​​of its neighboring pixels. Gaussian smoothing makes the entire image smoother, removes details, and filters out noise.

[0166] In this embodiment of the invention, to prevent details in the background image from standing out, a Gaussian filter with a window size of 7×7 can be applied to the background image in the RGB color space. Of course, the window size for the Gaussian filter can be customized as needed, and this embodiment of the invention does not limit this.

[0167] Furthermore, for the background image after Gaussian filtering, the background area used to display the target text can be obtained, and the first color average value Y of the background area in the HSV color space can be obtained. HSV =(Y H ,Y S ,Y V ), and the second color average value X of the background area in the Lab color space. Lab =(X L ,Xa,X b ); wherein, the first color average value includes the hue average value Y H Average saturation Y S Average brightness Y V The second color average value includes at least the brightness average value X. LSimultaneously, the Gaussian-filtered background image can be converted to the HSV color space and the Lab color space respectively to obtain the first background image and the second background image. Constraint conditions can then be determined in different color spaces.

[0168] For example, based on the lightness value, hue value, and saturation value of each pixel in the first background image in the HSV color space, lightness constraints, hue constraints, and saturation constraints can be determined respectively. Based on the lightness value of each pixel in the second background image in the Lab color space, lightness constraints can be determined, and so on.

[0169] Reference Figure 3 In another embodiment, step 130 may further include:

[0170] Step 131: Based on the first background image and the second background image, obtain saliency maps that satisfy the constraints under each color parameter, wherein the color parameters include at least one of hue, saturation, brightness, and luminance;

[0171] Step 132: Based on the saliency map under each color parameter, obtain the color saliency map of the background image relative to the area where the target text is located. The color value of each pixel in the color saliency map is determined according to the color parameter of the pixel at the same coordinate position in the corresponding saliency map.

[0172] Step 133: Obtain the target pixel point whose color value is greater than the preset color threshold in the color saliency map, and obtain the color of the pixel point in the first background image that has the same coordinates as the target pixel point as the color of the target pixel point;

[0173] Step 134: Count the K colors with the most target pixels as candidate text colors, where K is a positive integer.

[0174] In this embodiment of the invention, when setting constraints, different constraints can be set for different color parameters. The color parameters include at least one of hue, saturation, lightness, and brightness. That is, at least one of the above-mentioned lightness constraint, hue constraint, saturation constraint, and brightness constraint can be obtained.

[0175] Therefore, based on the first background image and the second background image, saliency maps satisfying the constraints for each color parameter can be obtained respectively. Moreover, to obtain a saliency map under the constraints of any color parameter, a background image containing the corresponding color parameter can be referenced, generally one of the first background image and the second background image.

[0176] Taking the brightness constraint as an example, when obtaining a saliency map that satisfies the brightness constraint, hue constraint, and saturation constraint, it can be based on a first background image containing the brightness value, hue value, and saturation value of each pixel. However, when obtaining a saliency map that satisfies the luminance constraint, it can be based on a second background image containing the luminance value of each pixel.

[0177] Furthermore, the size of the saliency map can be set to be consistent with the size of the original background image. For a saliency map under any color parameter constraint, the pixel colors in areas satisfying the constraint can be retained as the corresponding pixel colors in the background image. For areas not satisfying the constraint, the pixel colors can be uniformly set to a specified color (e.g., white RGB[255,255,255], black RGB[0,0,0], etc.). Alternatively, for each color parameter constraint, only the areas satisfying the constraint can be marked in the saliency map, and the pixel colors in each area can be read from the background image during subsequent color saliency map generation. This embodiment of the invention does not limit this approach. For example, the pixel colors in areas satisfying the constraint can be uniformly set to white RGB[255,255,255], while the pixel colors in areas not satisfying the constraint can be uniformly set to black RGB[0,0,0], thus marking the areas satisfying the constraint in the saliency map.

[0178] When obtaining the final color saliency map based on the saliency map for each color parameter, to determine the color of each pixel in the color saliency map, the overlapping regions that satisfy the corresponding constraints in each saliency map can be obtained. Then, the color value of each pixel in the original background image within the overlapping region can be obtained as the color value of the corresponding pixel in the color saliency map. Alternatively, when obtaining the color value of each pixel in the color saliency map, the color value of any pixel in the color saliency map can be set to color_map = mapL × mapH × mapS × mapV, where mapL represents the luminance value of the corresponding pixel in the saliency map satisfying the luminance constraint, mapH represents the hue value of the corresponding pixel in the saliency map satisfying the hue constraint, mapS represents the saturation value of the corresponding pixel in the saliency map satisfying the saturation constraint, and mapV represents the lightness value of the corresponding pixel in the saliency map satisfying the brightness constraint. In this case, the color saliency map can be obtained based on the color parameter values ​​of pixels at the same coordinate position in each saliency map. Furthermore, after obtaining the value of each pixel in the color saliency map based on the above formula, in order to represent the color value, the value of color_map can be adjusted to [0,255], etc. Of course, it is also possible not to make adjustments as needed, and this embodiment of the present invention does not limit this.

[0179] Furthermore, target pixels with color values ​​greater than a preset color threshold can be obtained from the color saliency map, and the color of the pixel in the first background image with the same coordinates as the target pixel can be obtained as the color of the target pixel. For regions in the color saliency map where the color value is not greater than the preset color threshold, their colors can be set to a specified color, such as [0,0,0]. The preset color threshold can be customized according to requirements, and this embodiment of the invention does not limit this. For example, the preset color threshold can be set to 30, etc.

[0180] For example, you can set if (Empty set), then the color value of any pixel in the color saliency map in the HSV color space is text′. HSV(i,j) It can be as follows:

[0181]

[0182] Among them, bg HSV(i,j) This indicates the color of the pixel in the first background image that has the same coordinates as this pixel.

[0183] Output text decoration color text′ HSV Convert it to the RGB color space to get text' RGBTherefore, the K colors with the highest number of target pixels can be selected as candidate text colors. The specific value of K can be customized according to requirements, and this embodiment of the invention does not limit this. For example, K can be set to a value of 5, then the top 5 colors with the highest number of target pixels can be selected as candidate text colors.

[0184] Of course, in this embodiment of the invention, target pixels whose color_map values ​​are within a specified range (e.g., greater than the preset color threshold mentioned above) can also be directly selected, and the color value of the corresponding target pixel in the original background image (that is, the color value of the pixel with the same coordinate position as the corresponding pixel in the background image) can be obtained as the color of the corresponding target pixel in the color saliency map. For other pixels whose color_map values ​​are not within the specified range, the color value of the corresponding pixel in the color saliency map can be determined to be a specified color (e.g., RGB[0,0,0], etc.). Since the original image is in the RGB color space, the color value of the target pixel obtained at this time is also the color value in the RGB color space, and there is no need to perform the above value conversion. Then, the K colors with the largest number of target pixels can be directly selected as candidate text colors for each target pixel.

[0185] Alternatively, in another embodiment, step 131 may further include:

[0186] Step 1311: Based on the hue value of each pixel in the first background image, obtain the pixel region in the first background image whose hue value satisfies the hue constraint condition, and obtain a hue saliency map. The hue constraint condition includes the absolute value of the difference between the hue value of the pixel and the average hue value within a first value range.

[0187] And / or, in step 1312, based on the saturation value of each pixel in the first background image, mark the pixel regions in the first background image whose saturation values ​​satisfy the saturation constraint conditions to obtain a saturation saliency map, wherein the saturation constraint conditions include the saturation value of the pixel being higher than the saturation threshold.

[0188] And / or, in step 1313, based on the brightness value of each pixel in the first background image, mark the pixel regions in the first background image whose brightness values ​​satisfy the brightness constraint conditions to obtain a brightness saliency map, wherein the brightness constraint conditions include the brightness value of the pixel being higher than the brightness threshold.

[0189] And / or, in step 1314, based on the brightness value of each pixel in the second background image, mark the pixel regions in the second background image whose brightness values ​​satisfy the brightness constraint conditions to obtain a brightness saliency map, wherein the brightness constraint conditions include the absolute value of the difference between the brightness value of the pixel and the brightness threshold within a second value range.

[0190] Considering the saliency of colors, the text color should have both brightness and hue contrast relative to the background. Meanwhile, colors with excessively low brightness and saturation lack hue distinction and should not be considered for text color selection. Therefore, four color selection principles can be derived, each corresponding to different constraints, to obtain a color saliency map.

[0191] Specifically, the selectable colors have a contrast between light and dark, so selection principle 1, i.e., a brightness constraint condition, can be set based on brightness. Specifically, a brightness threshold Lt = 73 can be set. Then, based on the brightness value of each pixel in the second background image, the region where the absolute value of the brightness difference with the brightness threshold is within a second value range (e.g., greater than 10) can be marked. Based on this brightness constraint condition, a brightness saliency map can be obtained, i.e., a saliency map mapL with the color parameter as brightness. Of course, in this embodiment of the invention, when setting the brightness threshold, the average brightness value of the text area in the background image can also be referenced. For example, the brightness threshold can be set to the average brightness value, or the average brightness value + / - a certain value, etc.

[0192] Selection principle 2 can be set based on hue, that is, hue (tone) constraint conditions: for example, obtain the colors whose absolute value of the hue difference is within the first value range (e.g. [20,160]) and obtain the hue saliency map mapH.

[0193] Selection principle 3 can be set based on saturation, that is, saturation constraint conditions: for example, if the color saturation S is too low, no color value is provided, and only the color value of the pixel point with the saturation value is higher than the saturation threshold is obtained to obtain the saturation saliency map mapS.

[0194] Selection principle 4 can be set based on brightness, that is, brightness constraint conditions: for example, if the brightness V of a color is too low, no color value is provided, and only the color value of the pixel point with the brightness value higher than the brightness threshold is obtained to obtain the brightness saliency map mapV.

[0195] The first value range, saturation threshold, brightness threshold, and second value range mentioned above can all be customized according to requirements, and can refer to the first color average value and the second color average value mentioned above. In this embodiment of the invention, no limitation is imposed.

[0196] Alternatively, in another embodiment, step 132 may further include:

[0197] Step 1321: For a saliency map under any color parameter, normalize the value of the color parameter for each pixel in the saliency map.

[0198] Step 1322: For any pixel in the color saliency map, the color value of the pixel is obtained by multiplying the values ​​of the color parameters of the corresponding coordinate positions of the pixels in the saliency map under each color parameter.

[0199] In practical applications, the value range for brightness is [0, 100], for hue it is [0°, 360°], and for saturation it is [0%, 100%], or [0, 1]. A higher saturation value indicates a more saturated color, and the value range for lightness is [0%, 100%]. Because the value ranges for different parameters are different, a unified calculation is not possible; therefore, it is necessary to normalize the values ​​of the color parameters.

[0200] For example, for each pixel, its brightness value is divided by 100 to obtain the normalized brightness value, i.e., the map. L ∈[0,1]. Accordingly, the hue value of each pixel can be normalized to obtain a map. H ∈[0,1].

[0201] After normalization, for any pixel in the color saliency map, the color value of the pixel is obtained by multiplying the values ​​of the color parameters of the corresponding coordinate positions in the saliency map under each color parameter.

[0202] For example, color_map = map L ×map H ×map S ×map V , where map L Represents the normalized brightness value, map H This represents the normalized hue value. Since the range of each color parameter is [0,1], the final obtained color_map, i.e., the color saliency map, also has a color value range of [0,1]. However, to determine the target pixel based on the color values ​​in the color saliency map, the color values ​​of each pixel in the color saliency map can be adjusted to [0,255]. This embodiment of the invention does not limit this adjustment.

[0203] Alternatively, in another embodiment, step 134 may further include:

[0204] Step 1341: Convert the color of the target pixel to the RGB color space, and count the number of target pixels under each color in the RGB color space;

[0205] Step 1342: In addition to the specified color, obtain the K colors with the largest number of target pixels in the RGB color space as the text colors.

[0206] In practical applications, the RGB color space is based on three primary colors: R (Red), G (Green), and B (Blue). Different degrees of layering are used to produce a rich and wide range of colors, hence it is commonly known as the three-primary-color model. In other words, the RGB color space more clearly reflects the color of each pixel from the user's perspective.

[0207] Therefore, in this embodiment of the invention, the color of each target pixel can be converted to the RGB color space, and the number of target pixels under each color can be counted in the RGB color space. Then, except for the specified color, the K colors with the highest number of target pixels in the RGB color space can be obtained as the text colors. The specified color can be customized according to requirements, and this embodiment of the invention does not limit it.

[0208] For example, the specified color can be set to [0,0,0], [255,255,255], etc. Of course, it is also possible not to set the specified color to be excluded, and this embodiment of the invention does not limit this.

[0209] like Figure 4 The diagram illustrates a color recall process based on visual saliency. The specific implementation involves using the color information of the poster's background image in the HSV and Lab color spaces. Based on visual saliency characteristics, and considering four constraints—color contrast, color hue, color saturation, and color brightness—a color saliency map of the background relative to the text area is obtained. The text color is then extracted from this color saliency map. The implementation steps are as follows:

[0210] (1) Apply a Gaussian filter with a window size of 7×7 to the background image bg of the banner (banner ad / poster) in the RGB color space;

[0211] (2) In the banner, obtain the background color (bg) of the text area. text Calculate bg text The average color value in the Lab and HSV color spaces is used to obtain X. Lab =(X L X a ,X b ) and Y HSV =(Y H ,YS ,Y V );

[0212] (3) Convert the Gaussian filtered bg to Lab and HSV color spaces to obtain bg Lab bg HSV ;

[0213] (4) The text color should be relative to the banner background. Considering the characteristics of color salience, the text color should have brightness contrast and hue contrast. At the same time, colors with too low brightness and too low saturation have no distinguishable hue and should not be used as candidate values ​​for text colors. Therefore, four color selection principles are derived to obtain a color salience map.

[0214] a. Selection Principle 1: Selectable colors should have contrast in brightness and darkness. Set the brightness / darkness threshold L. t =73, making the absolute value of the color brightness difference greater than 10, and obtain the map. L ∈[0,100],

[0215] b. Selection principle 2: Obtain colors whose absolute hue difference is in the range [20, 160], and obtain the map. H ∈{0,1},

[0216] c. Selection Principle 3: Color values ​​are not provided for colors with excessively low color saturation (S). (Obtain the map.) S ,

[0217] d. Selection principle 4: Color values ​​are not provided for colors with excessively low brightness (V). A map is then obtained. V .

[0218] (5) Based on the above four principles, four maps are obtained, and the color saliency map (color_map) is calculated.

[0219] color_map = map L / 100×map H ×map S ×map V ,

[0220] Then, adjust the color_map to [0,255].

[0221] (6) If

[0222]

[0223] (7) Output text decoration color text′ HSV Convert it to the RGB color space to get text' RGBTherefore, the K colors with the most target pixels (excluding the [0,0,0] color) can be selected as candidate text colors.

[0224] Reference Figure 5 In another embodiment, prior to step 140, the method may further include:

[0225] Step S1: Obtain keywords from the semantic meaning of the target text;

[0226] Step S2: Using a keyword-color mapping model, obtain the colors that have a mapping relationship with each keyword, and use them as candidate text colors for the target text.

[0227] The keyword-color mapping model is trained using sample texts of multiple known keywords and sample images that have a mapping relationship with each keyword.

[0228] Reference Figure 5 In another embodiment, prior to step S2, the method may further include:

[0229] Step S01: Obtain the keywords in each sample text as sample keywords;

[0230] Step S02: For any of the sample keywords, perform image retrieval using the sample keywords as query terms, and obtain the L images with the highest matching degree to the sample keywords as sample images related to the sample keywords;

[0231] Step S03: Extract the M colors with the highest number of pixels in each sample image related to the same sample keyword, and perform cluster analysis on the colors of each sample image related to the same sample keyword to obtain the N highest colors as candidate colors that have a mapping relationship with the sample keyword, thereby forming a mapping relationship model between keywords and colors.

[0232] In practical applications, the text to be displayed generally has a certain expressive meaning, that is, semantic meaning, and different semantic meanings may be appropriate for different colors. For example, when the text contains keywords such as "Christmas," the corresponding colors are generally white, red, gold, etc.

[0233] Therefore, in this embodiment of the invention, a text semantic color recall process can be constructed. Its main function is to recall the color of text semantics through a mapping relationship model between keywords and colors. Moreover, the keyword-color mapping relationship model can be trained using sample texts of multiple known keywords and sample images that have a mapping relationship with each of the known keywords.

[0234] In order to provide candidate text colors that are suitable for the semantic meaning of the target text, we can obtain the keywords in the semantic meaning of the target text, and then obtain the colors that have a mapping relationship with each keyword in the target text through the keyword-color mapping relationship model, and use them as candidate text colors for the target text.

[0235] In this embodiment of the invention, keywords in the semantics of the target text can be obtained by any available method, and this embodiment of the invention is not limited thereto. For example, special symbols such as emoticons in the target text can be removed to extract the semantics of the target text, and keywords in the semantics of the text can be analyzed by any available word segmentation model (or manually specified method). Of course, in this embodiment of the invention, keywords in the target text can also be analyzed directly, and this embodiment of the invention is not limited thereto.

[0236] The process of establishing the mapping relationship model between keywords and colors can be described as follows:

[0237] (1) Analyze each sample text using any available method, such as a word segmentation model (or a manually specified method), to obtain the keywords in it, which will then be used as sample keywords;

[0238] (2) Use each sample keyword as the query to call the image search API or any other available method to retrieve images and obtain L (e.g., 500) images with the highest matching degree with the sample keyword, which are used as sample images related to the sample keyword.

[0239] (3) For each sample image related to the same sample keyword, extract the M (e.g., 3) colors with the highest number of pixels, that is, the M main colors. Then, use any available clustering scheme such as kmeans clustering to perform cluster analysis on the colors extracted from each sample image related to the same sample keyword, and take the top N (e.g., N is 10) as candidate colors that have a mapping relationship with the sample keyword, thus forming a mapping relationship model between keywords and colors.

[0240] Of course, for each sample keyword, the number of times the color is extracted from each sample image related to the sample keyword can also be counted, and the N colors with the highest extraction frequency can be obtained as candidate colors that have a mapping relationship with the sample keyword. This embodiment of the invention does not limit this.

[0241] The text semantic color recall process involves extracting keywords corresponding to the text content of the target text, inputting them into a keyword-color mapping model for keyword matching, and then using the candidate colors of the J keywords with the highest matching degree to the target text as candidate text colors for the target text, where J is a positive integer. Here, L, M, N, and J are all positive integers, and the specific values ​​of L, M, N, and J can be customized according to requirements; this embodiment of the invention does not limit this.

[0242] Reference Figure 5 In another embodiment, prior to step 140, the method may further include:

[0243] Step T1: Obtain the background color information of the text area in the background image, and determine the color brightness of the text area based on the background color information and the brightness threshold. The text area is the background area in the background image used to display the target text. The background color information includes at least one of the first color average value of the text area in the HSV color space and the second color average value of the text area in the Lab color space.

[0244] Step T2: Based on the color brightness result, obtain a color that satisfies readability from the background color information of the text area, and use it as a candidate text color for the target text.

[0245] In addition, in this embodiment of the invention, color recall can also be performed based on readability to obtain candidate text colors with contrasting brightness and darkness. Specifically, the background color information of the text area in the background image can be obtained. Based on the background color information and the brightness and darkness threshold, the brightness and darkness of the text area can be determined. For each brightness and darkness condition, a color that satisfies readability can be calculated from the background color information of the text area and added to the candidate text color set as a candidate text color for the target text.

[0246] Furthermore, in this embodiment of the invention, candidate text colors that meet readability requirements can be obtained by any available color recall method based on light and dark contrast, and this embodiment of the invention does not limit this.

[0247] like Figure 6The diagram illustrates a process for retrieving candidate text colors for target text through color recall based on brightness and darkness contrast. It obtains a background image and the coordinates of the target text within the background image. This allows for the acquisition of the background area of ​​the target text, such as the main title and subtitle, i.e., the text area. Background color information, including the average first color value of the text area in the HSV color space and the average second color value of the text area in the Lab color space, is then obtained. Further, the brightness and darkness of the text area are determined based on a brightness and darkness threshold. If the brightness and / or luminance of the background area is less than the threshold, the background area is considered dark, and a relatively bright color can be selected as a candidate text color. Conversely, if the brightness and / or luminance is greater than the threshold, the background area is considered bright, and a relatively dark color can be selected as a candidate text color. The brightness and darkness threshold can be a threshold set for brightness and / or luminance, and its specific value can be customized according to requirements. This embodiment of the invention does not limit this specific value. For example, the light-dark boundary threshold can be set to a brightness of 60. In this case, when obtaining the background color information of the background area, only the average brightness of the background area can be obtained. Correspondingly, if the light-dark boundary threshold is set as a threshold for brightness, then when obtaining the background color information of the background area, only the average brightness of the background area can be obtained. This embodiment of the present invention does not limit this.

[0248] Reference Figure 5 In another embodiment, step 140 may further include:

[0249] Step 141: Based on the background color of the background image and the proportion of the target text area relative to the background image, obtain the color matching score of each candidate text color through a color sorting model.

[0250] Step 142: Obtain the candidate text color with the highest matching score, and use it as the text color of the target text in the background image.

[0251] As mentioned above, in practical applications, multiple candidate text colors can be obtained for the same target text. In particular, candidate text colors for the target text can be obtained through various methods such as color recall based on readability, color recall based on visual prominence, and color recall based on text semantics. In order to improve the display effect of text colors, the candidate text colors can be further sorted to obtain the text color with the best effect from each candidate text color.

[0252] Specifically, based on information such as the background color of the background image and the proportion of the target text area relative to the background image, a color sorting model can be used to obtain the matching score of each candidate text color, and then the candidate text color with the highest matching score can be selected as the text color of the target text in the background image.

[0253] The color sorting model can be trained using multiple sample data of background and text colors that have been offline labeled by designers to determine whether they match (e.g., good, bad, average). The model uses text color, background color, and text area ratio as features and is trained using machine learning models such as SVM (Support Vector Machine).

[0254] like Figure 7 The diagram illustrates a text color matching process. It mainly consists of four modules: a readability-based color recall module, a visually salient color recall module, a text semantic color recall module, and a sorting module. The overall structure is shown in the diagram below. Figure 7 The copywriting color matching section includes four modules. First, color recall is performed, including three modules: a color recall module based on readability, a color recall module based on visual salience, and a color recall module based on text semantics. Then, the sorting module completes the prediction of the matching scores of candidate copywriting colors, and finally outputs the candidate copywriting color with the best matching score as the copywriting color of the target copywriting.

[0255] Reference Figure 8 The diagram illustrates a flowchart of another text color matching method in an embodiment of the present invention.

[0256] Step 210: Obtain keywords from the semantic meaning of the target text;

[0257] Step 220: Using a keyword-color mapping model, obtain the colors that have a mapping relationship with each keyword, and use them as candidate text colors for the target text.

[0258] Step 230: Obtain the final text color of the target text from the candidate text colors.

[0259] The keyword-color mapping model is trained using sample texts of multiple known keywords and sample images that have a mapping relationship with each keyword.

[0260] Optionally, in this embodiment of the invention, before step 220, the following may be included:

[0261] Step 21: Obtain the keywords in each sample text as sample keywords;

[0262] Step 22: For any of the sample keywords, perform image retrieval using the sample keywords as query terms, and obtain the L images with the highest matching degree to the sample keywords as sample images related to the sample keywords, where L is a positive integer;

[0263] Step 23: Extract the M colors with the highest number of pixels in each sample image related to the same sample keyword, and perform cluster analysis on the colors of each sample image related to the same sample keyword to obtain the N highest colors as candidate colors that have a mapping relationship with the sample keyword, thereby forming a mapping relationship model between keywords and colors.

[0264] Optionally, in this embodiment of the invention, before step 230, the following may be included:

[0265] Step 31: Obtain the background image used to display the target text to be matched with the color, and the position information of the target text in the background image;

[0266] Step 32: Obtain the color information of the background image in the HSV color space and the Lab color space; wherein, the color information includes at least one of the following: the first average color value of the background area in the background image used to display the target text in the HSV color space, the second average color value of the background area in the Lab color space, the first background image converted to the HSV color space, and the second background image converted to the Lab color space;

[0267] Step 33: Based on the color information and the constraints of the text color scheme, obtain the color saliency map of the background image relative to the area where the target text is located, and obtain at least one alternative text color from the color saliency map; wherein, the constraints include at least one of the lightness constraints, hue constraints, saturation constraints, and brightness constraints, and the constraints are set based on the color information.

[0268] Optionally, in this embodiment of the invention, before step 230, the following may be included:

[0269] Step 41: Obtain the background color information of the text area in the background image, and determine the color brightness of the text area based on the background color information and the brightness threshold. The text area is the background area in the background image used to display the target text. The background color information includes at least one of the first color average value of the text area in the HSV color space and the second color average value of the text area in the Lab color space.

[0270] Step 42: Based on the color brightness result, obtain a color that satisfies readability from the background color information of the text area, and use it as a candidate text color for the target text.

[0271] In this embodiment of the invention, by analyzing the color information of the banner background image, with the aim of color readability and prominence, the color scheme of the text is generated from dimensions such as brightness, saturation, and hue. The color scheme has the advantages of good readability and color matching with the background decorative elements. At the same time, the text content is analyzed, and the semantic color of the text is mined using web crawling and clustering analysis techniques, so that it is more in line with the style and concept expressed by the poster on an aesthetic basis. In the process of building the matching degree model, colors from multiple color spaces are used, and information such as position and area are added as input features of the model.

[0272] Furthermore, the technical solution provided by this invention does not require pre-setting alternative colors for the text. Moreover, the text color is obtained from banner background analysis with the aim of color readability and prominence. A color saliency map is generated from multiple dimensions such as brightness, saturation, and hue, resulting in colors that make the text more prominent. In addition, by considering the semantic relevance between text content and text color, the text color can reflect the style of the poster itself or the conceptual color behind the text content.

[0273] Reference Figure 9 The diagram shows a structural schematic of a text color matching device according to an embodiment of the present invention.

[0274] The text color matching device of this invention includes: a background image acquisition module 310, a color information acquisition module 320, a first candidate color acquisition module 330, and a text color acquisition module 340.

[0275] The functions of each module and the interaction between them are described in detail below.

[0276] Background image acquisition module 310 is used to acquire a background image for displaying the target text to be matched with color, and the position information of the target text in the background image;

[0277] The color information acquisition module 320 is used to acquire the color information of the background image in the HSV color space and the Lab color space; wherein, the color information includes at least one of the following: the first average color value of the background area in the background image used to display the target text in the HSV color space, the second average color value of the background area in the Lab color space, the first background image converted to the HSV color space, and the second background image converted to the Lab color space;

[0278] The first candidate color acquisition module 330 is used to acquire a color saliency map of the background image relative to the area where the target text is located based on the color information and the constraints of the text color scheme, and to acquire at least one candidate text color in the color saliency map; wherein, the constraints include at least one of lightness constraints, hue constraints, saturation constraints, and brightness constraints, and the constraints are set based on the color information.

[0279] The text color acquisition module 340 is used to acquire the final text color of the target text from the candidate text colors.

[0280] Reference Figure 10 In this embodiment of the invention, the color information acquisition module 320 may further include:

[0281] Gaussian filtering submodule 321 is used to perform Gaussian filtering on the background image in the RGB color space;

[0282] The text area acquisition submodule 322 is used to acquire the background area for displaying the target text from the background image after Gaussian filtering;

[0283] Color average acquisition submodule 323 is used to acquire the first color average value of the background area in the HSV color space and the second color average value of the background area in the Lab color space; wherein, the first color average value includes the hue average value, the saturation average value, and the lightness average value, and the second color average value includes at least the lightness average value.

[0284] Color space conversion submodule 324 is used to convert the background image after Gaussian filtering to the HSV color space and the Lab color space respectively, to obtain the first background image and the second background image.

[0285] Reference Figure 10 In this embodiment of the invention, the first candidate color acquisition module 330 may further include:

[0286] The unit parameter saliency map acquisition submodule 331 is used to acquire saliency maps that satisfy the constraints under each color parameter based on the first background image and the second background image, wherein the color parameters include at least one of hue, saturation, brightness, and luminance.

[0287] Color saliency map acquisition submodule 332 is used to acquire the color saliency map of the background image relative to the area where the target text is located based on the saliency map under each color parameter. The color value of each pixel in the color saliency map is determined according to the color parameter of the pixel at the same coordinate position in the corresponding saliency map.

[0288] The target pixel acquisition submodule 333 is used to acquire target pixels whose color value is greater than a preset color threshold in the color saliency map, and to acquire the color of the pixel in the first background image that has the same coordinates as the target pixel as the color of the target pixel.

[0289] The first candidate color acquisition submodule 334 is used to count the K colors with the most target pixels as candidate text colors, where K is a positive integer.

[0290] Optionally, the unit parameter saliency map acquisition submodule 331 can be specifically used for:

[0291] Based on the hue value of each pixel in the first background image, the pixel region in the first background image whose hue value satisfies the hue constraint condition is obtained to obtain a hue saliency map. The hue constraint condition includes the absolute value of the difference between the hue value of the pixel and the average hue value within a first value range.

[0292] And / or, based on the saturation value of each pixel in the first background image, mark the pixel regions in the first background image whose saturation values ​​satisfy the saturation constraint conditions to obtain a saturation saliency map, wherein the saturation constraint conditions include the saturation value of the pixel being higher than the saturation threshold;

[0293] And / or, based on the brightness value of each pixel in the first background image, mark the pixel regions in the first background image whose brightness values ​​satisfy the brightness constraint conditions to obtain a brightness saliency map, wherein the brightness constraint conditions include the brightness value of the pixel being higher than the brightness threshold;

[0294] And / or, based on the brightness value of each pixel in the second background image, mark the pixel regions in the second background image whose brightness values ​​satisfy the brightness constraint conditions to obtain a brightness saliency map, wherein the brightness constraint conditions include the absolute value of the difference between the brightness value of the pixel and the brightness threshold within a second value range.

[0295] Optionally, the color saliency map acquisition submodule 332 can be specifically used for:

[0296] For a saliency map under any color parameter, the value of the color parameter of each pixel in the saliency map is normalized.

[0297] For any pixel in the color saliency map, the color value of the pixel is obtained by multiplying the values ​​of the color parameters of the corresponding coordinate positions in the saliency map under each color parameter.

[0298] Optionally, the first candidate color acquisition submodule 334 can be specifically used for:

[0299] The color of the target pixel is converted to the RGB color space, and the number of target pixels under each color is counted in the RGB color space;

[0300] In addition to the specified color, the K colors with the highest number of target pixels in the RGB color space are selected as the text colors.

[0301] Reference Figure 11 In this embodiment of the invention, the device may further include:

[0302] The keyword acquisition module 350 is used to acquire keywords in the semantics of the target text.

[0303] The second candidate color acquisition module 360 ​​is used to acquire colors that have a mapping relationship with each of the keywords through a keyword-color mapping relationship model, and use them as candidate text colors for the target text.

[0304] The keyword-color mapping model is trained using sample texts of multiple known keywords and sample images that have a mapping relationship with each keyword.

[0305] Reference Figure 11 In this embodiment of the invention, the device may further include:

[0306] The sample keyword acquisition module 370 is used to acquire keywords from each sample text and use them as sample keywords.

[0307] Image retrieval module 380 is used to perform image retrieval for any of the sample keywords, using the sample keywords as query terms, and obtain the L images with the highest matching degree with the sample keywords as sample images related to the sample keywords, where L is a positive integer;

[0308] The mapping relationship construction module 390 is used to extract the M colors with the highest number of pixels in each sample image related to the same sample keyword, and to perform cluster analysis on the colors of each sample image related to the same sample keyword to obtain the N highest colors as candidate colors that have a mapping relationship with the sample keyword, thereby forming a mapping relationship model between keywords and colors.

[0309] Reference Figure 11 In this embodiment of the invention, the device may further include:

[0310] Color brightness determination module 3110 is used to obtain background color information of the text area of ​​the background image, and determine the color brightness result of the text area according to the background color information and the brightness boundary threshold. The text area is the background area in the background image used to display the target text. The background color information includes at least one of the first color average value of the text area in the HSV color space and the second color average value of the text area in the Lab color space.

[0311] The third candidate color acquisition module 3120 is used to acquire a color that meets readability requirements from the background color information of the text area based on the color brightness result, and use it as a candidate text color for the target text.

[0312] Reference Figure 11 In this embodiment of the invention, the text color acquisition module 340 may further include:

[0313] The matching score prediction module 341 is used to obtain the matching score of each candidate text color based on the background color of the background image and the text area ratio of the target text relative to the background image through a color sorting model.

[0314] The text color determination module 342 is used to obtain the candidate text color with the highest matching score, and use it as the text color of the target text in the background image.

[0315] Reference Figure 12 The diagram shows a structural schematic of another text color matching device in an embodiment of the present invention.

[0316] The text color matching device of this invention includes: a keyword acquisition module 410, a second candidate color acquisition module 420, and a text color acquisition module 430.

[0317] The functions of each module and the interaction between them are described in detail below.

[0318] Keyword acquisition module 410 is used to acquire keywords in the semantics of the target text;

[0319] The second candidate color acquisition module 420 is used to acquire colors that have a mapping relationship with each of the keywords through a keyword-color mapping relationship model, and use them as candidate text colors for the target text.

[0320] The text color acquisition module 430 is used to acquire the final text color of the target text from the candidate text colors;

[0321] The keyword-color mapping model is trained using sample texts of multiple known keywords and sample images that have a mapping relationship with each keyword.

[0322] Optionally, the device may further include:

[0323] The sample keyword acquisition module is used to extract keywords from each sample text and use them as sample keywords.

[0324] The image retrieval module is used to perform image retrieval for any of the sample keywords, using the sample keywords as query terms, and to obtain the L images with the highest matching degree with the sample keywords as sample images related to the sample keywords, where L is a positive integer;

[0325] The mapping relationship construction module is used to extract the M colors with the highest number of pixels in each sample image related to the same sample keyword, and perform cluster analysis on the colors of each sample image related to the same sample keyword to obtain the N highest colors as candidate colors that have a mapping relationship with the sample keyword, thereby forming a mapping relationship model between keywords and colors.

[0326] Optionally, the device may further include:

[0327] The background image acquisition module is used to acquire a background image for displaying the target text to be matched with colors, as well as the position information of the target text in the background image;

[0328] The color information acquisition module is used to acquire the color information of the background image in the HSV color space and the Lab color space; wherein, the color information includes at least one of the following: the first average color value of the background area of ​​the background image used to display the target text in the HSV color space, the second average color value of the background area in the Lab color space, the first background image converted to the HSV color space, and the second background image converted to the Lab color space;

[0329] The first candidate color acquisition module is used to acquire a color saliency map of the background image relative to the area where the target text is located based on the color information and the constraints of the text color scheme, and to acquire at least one candidate text color in the color saliency map; wherein, the constraints include at least one of lightness constraints, hue constraints, saturation constraints, and brightness constraints, and the constraints are set based on the color information.

[0330] Optionally, the device may further include:

[0331] The color brightness and darkness determination module is used to obtain the background color information of the text area in the background image, and to determine the color brightness and darkness result of the text area based on the background color information and the brightness and darkness boundary threshold. The text area is the background area in the background image used to display the target text. The background color information includes at least one of the first color average value of the text area in the HSV color space and the second color average value of the text area in the Lab color space.

[0332] The third candidate color acquisition module is used to obtain a color that meets readability requirements from the background color information of the text area based on the color brightness result, and use it as a candidate text color for the target text.

[0333] The text color matching device provided in this embodiment of the invention can realize the various processes implemented in the above method embodiments, and will not be described again here to avoid repetition.

[0334] Preferably, the present invention also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the various processes of the above-described text color matching method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0335] This invention also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described text color matching method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.

[0336] Figure 13 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.

[0337] The electronic device 500 includes, but is not limited to, components such as: a radio frequency unit 501, a network module 502, an audio output unit 503, an input unit 504, a sensor 505, a display unit 506, a user input unit 507, an interface unit 508, a memory 509, a processor 510, and a power supply 511. Those skilled in the art will understand that... Figure 13The electronic device structures shown are not intended to limit the electronic device. An electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements. In embodiments of the present invention, the electronic device includes, but is not limited to, mobile phones, tablet computers, laptops, PDAs, in-vehicle terminals, wearable devices, and pedometers.

[0338] It should be understood that, in this embodiment of the invention, the radio frequency unit 501 can be used for receiving and transmitting signals during information transmission or calls. Specifically, it receives downlink data from the base station and processes it with the processor 510; additionally, it transmits uplink data to the base station. Typically, the radio frequency unit 501 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier, a duplexer, etc. Furthermore, the radio frequency unit 501 can also communicate with networks and other devices through a wireless communication system.

[0339] The electronic device provides users with wireless broadband internet access through the network module 502, such as helping users send and receive emails, browse web pages, and access streaming media.

[0340] The audio output unit 503 can convert audio data received by the radio frequency unit 501 or the network module 502 or stored in the memory 509 into audio signals and output them as sound. Furthermore, the audio output unit 503 can also provide audio output related to specific functions performed by the electronic device 500 (e.g., call signal reception sound, message reception sound, etc.). The audio output unit 503 includes a speaker, a buzzer, and a receiver, etc.

[0341] Input unit 504 is used to receive audio or video signals. Input unit 504 may include a graphics processing unit (GPU) 5041 and a microphone 5042. The GPU 5041 processes image data of still images or videos acquired by an image capture device (such as a camera) in video capture mode or image capture mode. The processed image frames can be displayed on display unit 506. The image frames processed by GPU 5041 can be stored in memory 509 (or other storage medium) or transmitted via radio frequency unit 501 or network module 502. Microphone 5042 can receive sound and process such sound into audio data. The processed audio data can be converted into a format that can be transmitted to a mobile communication base station via radio frequency unit 501 in telephone call mode.

[0342] The electronic device 500 also includes at least one sensor 505, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor. The ambient light sensor can adjust the brightness of the display panel 5061 according to the ambient light level, and the proximity sensor can turn off the display panel 5061 and / or backlight when the electronic device 500 is moved to the ear. As a type of motion sensor, an accelerometer sensor can detect the magnitude of acceleration in various directions (generally three axes). When stationary, it can detect the magnitude and direction of gravity and can be used to identify the posture of the electronic device (such as landscape / portrait switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc. The sensor 505 may also include a fingerprint sensor, pressure sensor, iris sensor, molecular sensor, gyroscope, barometer, hygrometer, thermometer, infrared sensor, etc., which will not be described in detail here.

[0343] The display unit 506 is used to display information input by the user or information provided to the user. The display unit 506 may include a display panel 5061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.

[0344] User input unit 507 can be used to receive input numerical or character information, and to generate key signal inputs related to user settings and function control of electronic devices. Specifically, user input unit 507 includes a touch panel 5071 and other input devices 5072. Touch panel 5071, also known as a touch screen, can collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near touch panel 5071). Touch panel 5071 may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 510, which receives and executes commands from the processor 510. In addition, touch panel 5071 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. Besides touch panel 5071, user input unit 507 may also include other input devices 5072. Specifically, other input devices 5072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, joysticks, etc., which will not be described in detail here.

[0345] Furthermore, the touch panel 5071 can cover the display panel 5061. When the touch panel 5071 detects a touch operation on or near it, it transmits the information to the processor 510 to determine the type of touch event. Subsequently, the processor 510 provides corresponding visual output on the display panel 5061 based on the type of touch event. Although in Figure 13 In this embodiment, the touch panel 5071 and the display panel 5061 are two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 5071 and the display panel 5061 can be integrated to realize the input and output functions of the electronic device. The specific implementation is not limited here.

[0346] Interface unit 508 serves as an interface for connecting external devices to electronic device 500. For example, external devices may include a wired or wireless headphone port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, and so on. Interface unit 508 can be used to receive input from external devices (e.g., data, power, etc.) and transmit the received input to one or more components within electronic device 500, or it can be used to transmit data between electronic device 500 and external devices.

[0347] The memory 509 can be used to store software programs and various data. The memory 509 may primarily include a program storage area and a data storage area. The program storage area may store the operating system, applications required for at least one function (such as sound playback, image playback, etc.), etc.; the data storage area may store data created based on the use of the mobile phone (such as audio data, phonebook, etc.). Furthermore, the memory 509 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0348] The processor 510 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 509, and by calling data stored in the memory 509, it performs various functions and processes data, thereby providing overall monitoring of the electronic device. The processor 510 may include one or more processing units; preferably, the processor 510 may integrate an application processor and a modem processor. The application processor mainly handles the operating system, user interface, and applications, while the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 510.

[0349] The electronic device 500 may also include a power supply 511 (such as a battery) for supplying power to various components. Preferably, the power supply 511 can be logically connected to the processor 510 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system.

[0350] In addition, the electronic device 500 includes some functional modules not shown, which will not be described in detail here.

[0351] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0352] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0353] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of the present invention.

[0354] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0355] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0356] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0357] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0358] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0359] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0360] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A text color scheme method, characterized in that, include: Obtain the background image used to display the target text to be matched with the color scheme, and the position information of the target text in the background image; Obtain the color information of the background image in the HSV color space and the Lab color space; wherein, the color information includes at least one of the following: the first average color value of the background area in the background image used to display the target text in the HSV color space, the second average color value of the background area in the Lab color space, the first background image converted to the HSV color space, and the second background image converted to the Lab color space; Based on the color information and the constraints of the text color scheme, a color saliency map of the background image relative to the area where the target text is located is obtained, and at least one alternative text color is obtained from the color saliency map; wherein, the constraints include at least one of lightness constraints, hue constraints, saturation constraints, and brightness constraints, and the constraints are set based on the color information; Obtain the final text color of the target text from the candidate text colors; The step of obtaining a color saliency map of the background image relative to the area where the target text is located based on the color information and the constraints of the text color scheme, and obtaining at least one alternative text color from the color saliency map, includes: Based on the first background image and the second background image, a saliency map that satisfies the constraints under each color parameter is obtained. The color parameter includes at least one of hue, saturation, brightness, and luminance. Based on the saliency map under each color parameter, a color saliency map of the background image relative to the area where the target text is located is obtained. The color value of each pixel in the color saliency map is determined according to the color parameter of the pixel at the same coordinate position in the corresponding saliency map. Obtain the target pixel point whose color value is greater than a preset color threshold in the color saliency map, and obtain the color of the pixel point in the first background image that has the same coordinates as the target pixel point as the color of the target pixel point; The K colors with the highest number of target pixels are selected as candidate text colors, where K is a positive integer. The step of obtaining saliency maps that satisfy the constraints under each color parameter based on the first background image and the second background image includes: Based on the hue value of each pixel in the first background image, the pixel region in the first background image whose hue value satisfies the hue constraint condition is obtained to obtain a hue saliency map. The hue constraint condition includes the absolute value of the difference between the hue value of the pixel and the average hue value within a first value range. And / or, based on the saturation value of each pixel in the first background image, mark the pixel regions in the first background image whose saturation values ​​satisfy the saturation constraint conditions to obtain a saturation saliency map, wherein the saturation constraint conditions include the saturation value of the pixel being higher than the saturation threshold; And / or, based on the brightness value of each pixel in the first background image, mark the pixel regions in the first background image whose brightness values ​​satisfy the brightness constraint conditions to obtain a brightness saliency map, wherein the brightness constraint conditions include the brightness value of the pixel being higher than the brightness threshold; And / or, based on the brightness value of each pixel in the second background image, mark the pixel regions in the second background image whose brightness values ​​satisfy the brightness constraint conditions to obtain a brightness saliency map, wherein the brightness constraint conditions include the absolute value of the difference between the brightness value of the pixel and the brightness threshold within a second value range.

2. The method according to claim 1, characterized in that, The step of obtaining the color information of the background image in the HSV color space and the Lab color space includes: In the RGB color space, a Gaussian filter is applied to the background image; Obtain the background area for displaying the target text from the background image after Gaussian filtering; Obtain the first average color value of the background area in the HSV color space, and the second average color value of the background area in the Lab color space; wherein, the first average color value includes the average hue, average saturation, and average brightness, and the second average color value includes at least the average brightness. The background image after Gaussian filtering is converted to the HSV color space and the Lab color space respectively to obtain the first background image and the second background image.

3. The method according to claim 1, characterized in that, The step of obtaining a color saliency map of the background image relative to the area where the target text is located, based on the saliency map under each color parameter, wherein the color value of each pixel in the color saliency map is determined according to the color parameters of the pixels at the same coordinate position in the corresponding saliency map, includes: For a saliency map under any color parameter, the value of the color parameter of each pixel in the saliency map is normalized. For any pixel in the color saliency map, the color value of the pixel is obtained by multiplying the values ​​of the color parameters of the corresponding coordinate positions in the saliency map under each color parameter.

4. The method according to claim 3, characterized in that, The step of selecting the K colors with the highest number of target pixels as candidate text colors includes: The color of the target pixel is converted to the RGB color space, and the number of target pixels under each color is counted in the RGB color space; In addition to the specified color, the K colors with the highest number of target pixels in the RGB color space are selected as the text colors.

5. According to claim 1 The method described in any one of the following four cases, characterized in that, before the step of obtaining the final text color of the target text from the candidate text colors, it further includes: Obtain keywords from the semantic meaning of the target text; By using a keyword-color mapping model, colors that have a mapping relationship with each keyword are obtained and used as candidate text colors for the target text. The keyword-color mapping model is trained using sample texts of multiple known keywords and sample images that have a mapping relationship with each keyword.

6. The method according to claim 5, characterized in that, Before the step of obtaining the color that has a mapping relationship with each keyword through the keyword-color mapping relationship model, and using it as the candidate text color for the target text, the method further includes: Extract the keywords from each sample text and use them as sample keywords; For any of the sample keywords, perform image retrieval using the sample keywords as query terms, and obtain the L images with the highest matching degree to the sample keywords, which are used as sample images related to the sample keywords, where L is a positive integer; Extract the M colors with the highest number of pixels in each sample image related to the same sample keyword, and perform cluster analysis on the colors of each sample image related to the same sample keyword to obtain the N highest colors as candidate colors that have a mapping relationship with the sample keyword, thereby forming a mapping relationship model between keywords and colors.

7. According to claim 1 The method described in any one of the following 4, characterized in that, Before the step of obtaining the final text color of the target text from the candidate text colors, the method further includes: Obtain the background color information of the text area in the background image, and determine the color brightness of the text area based on the background color information and the brightness threshold. The text area is the background area in the background image used to display the target text. The background color information includes at least one of the first color average value of the text area in the HSV color space and the second color average value of the text area in the Lab color space. Based on the color brightness results, a color that satisfies readability is obtained from the background color information of the text area and used as a candidate text color for the target text.

8. The method according to claim 1, characterized in that, The step of obtaining the final text color of the target text from the candidate text colors includes: Based on the background color of the background image and the proportion of the target text area relative to the background image, a color sorting model is used to obtain the color matching score for each candidate text. The candidate text color with the highest matching score is selected as the text color of the target text in the background image.

9. A text color matching device, characterized in that, include: The background image acquisition module is used to acquire a background image for displaying the target text to be matched with colors, as well as the position information of the target text in the background image; The color information acquisition module is used to acquire the color information of the background image in the HSV color space and the Lab color space; wherein, the color information includes at least one of the following: the first average color value of the background area of ​​the background image used to display the target text in the HSV color space, the second average color value of the background area in the Lab color space, the first background image converted to the HSV color space, and the second background image converted to the Lab color space; The first candidate color acquisition module is used to acquire a color saliency map of the background image relative to the area where the target text is located, based on the color information and the constraints of the text color scheme, and to acquire at least one candidate text color in the color saliency map; wherein, the constraints include at least one of lightness constraints, hue constraints, saturation constraints, and brightness constraints, and the constraints are set based on the color information; The text color acquisition module is used to acquire the final text color of the target text from the candidate text colors; The first candidate color acquisition module further includes the step of acquiring a color saliency map of the background image relative to the area where the target text is located based on the color information and the constraints of the text color scheme, and acquiring at least one candidate text color in the color saliency map, including: Based on the first background image and the second background image, a saliency map that satisfies the constraints under each color parameter is obtained. The color parameter includes at least one of hue, saturation, brightness, and luminance. Based on the saliency map under each color parameter, a color saliency map of the background image relative to the area where the target text is located is obtained. The color value of each pixel in the color saliency map is determined according to the color parameter of the pixel at the same coordinate position in the corresponding saliency map. Obtain the target pixel point whose color value is greater than a preset color threshold in the color saliency map, and obtain the color of the pixel point in the first background image that has the same coordinates as the target pixel point as the color of the target pixel point; The K colors with the highest number of target pixels are selected as candidate text colors, where K is a positive integer. The step of obtaining saliency maps that satisfy the constraints under each color parameter based on the first background image and the second background image includes: Based on the hue value of each pixel in the first background image, the pixel region in the first background image whose hue value satisfies the hue constraint condition is obtained to obtain a hue saliency map. The hue constraint condition includes the absolute value of the difference between the hue value of the pixel and the average hue value within a first value range. And / or, based on the saturation value of each pixel in the first background image, mark the pixel regions in the first background image whose saturation values ​​satisfy the saturation constraint conditions to obtain a saturation saliency map, wherein the saturation constraint conditions include the saturation value of the pixel being higher than the saturation threshold; And / or, based on the brightness value of each pixel in the first background image, mark the pixel regions in the first background image whose brightness values ​​satisfy the brightness constraint conditions to obtain a brightness saliency map, wherein the brightness constraint conditions include the brightness value of the pixel being higher than the brightness threshold; And / or, based on the brightness value of each pixel in the second background image, mark the pixel regions in the second background image whose brightness values ​​satisfy the brightness constraint conditions to obtain a brightness saliency map, wherein the brightness constraint conditions include the absolute value of the difference between the brightness value of the pixel and the brightness threshold within a second value range.

10. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the text color matching method as described in any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the text color matching method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Data visualization method based on semantic resonance colors

    CN106354838A

  • Control text color change method and system, and electronic apparatus

    CN107704253A

  • Method, device for configuring text color in picture and electronic device

    CN109408177A