Method and apparatus for adjusting color of text
By calculating and adjusting the brightness and contrast of text color and background color, the problem of insufficient adaptation of single text color was solved, realizing the adaptation of multiple text colors and rich display effects, thus improving the user experience.
Patent Information
- Application Number
- CN202010668562.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-13
- Publication Date
- 2026-05-15
- Estimated Expiration
- 2040-07-13
AI Technical Summary
The existing single text color adaptation cannot meet the growing and diversified needs of users, especially in multi-colored backgrounds, where the brightness contrast between the text color and the background color is insufficient, making it difficult for users to read clearly.
By acquiring the background color and text color, calculating the brightness contrast, and adjusting the text color when the brightness contrast is less than a preset threshold to ensure that its brightness contrast with the background color reaches or exceeds the preset threshold, the specific method includes using an image subject color extraction algorithm and background attribute information to acquire the background color, and using the inverted color of the background color to adjust the text color when necessary.
It achieves adaptation to multiple text colors, enriches the diversity of text display, and improves the reading clarity for users against multi-colored backgrounds.
Smart Images

Figure CN114089994B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a method and apparatus for adjusting text color. Background Technology
[0002] In application development, text colors are typically black or white. However, as users interact with applications, skinning and theme changes have become increasingly common, and developers are increasingly abandoning monochrome backgrounds in favor of multi-colored image backgrounds to achieve more diverse display effects. Similarly, developers are using diverse text and background color values in more scenarios to highlight the hierarchy and structure of content. Therefore, simply using black and white for text is no longer sufficient to meet the growing needs of users. Summary of the Invention
[0003] This application provides a method and apparatus for adjusting text color.
[0004] In a first aspect, embodiments of this application provide a method for adjusting text color, comprising: obtaining the background color of a background and the text color of a target text in the background; calculating the brightness contrast between the text color and the background color; and, in response to a brightness contrast less than a preset contrast threshold, adjusting the text color based on the text color so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold.
[0005] In some embodiments, obtaining the background color of the background includes: extracting the background color of the image as the background according to an image subject color extraction algorithm; and / or obtaining the background color based on background attribute information.
[0006] In some embodiments, obtaining the background color based on the background attribute information includes: in response to determining that the background color represented by the background attribute information is a gradient color, and the gradient color is a color within a preset angle range threshold on a preset gradient color wheel, determining the color corresponding to a preset angle within the preset angle range threshold as the background color.
[0007] In some embodiments, the above-mentioned adjustment of the text color based on the text color in response to the brightness contrast being less than a preset contrast threshold, so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold, includes: in response to the brightness contrast being less than the preset contrast threshold, adjusting the text color of the target text based on the text color with the inverted color of the background color as the color adjustment direction, so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold.
[0008] In some embodiments, calculating the brightness contrast between the text color and the background color includes:
[0009] The brightness of the text color and background color can be calculated using the following formula: L=R×0.2126+G×0.7152+B×0.0722, where L represents brightness, R represents the color value in the red channel, G represents the color value in the green channel, and B represents the color value in the blue channel.
[0010] The brightness contrast between text color and background color is calculated using the following formula: C = (L1 + 0.05) / (L2 + 0.05), where L1 represents the brightness of the text color, L2 represents the brightness of the background color, and C represents the brightness contrast between the text color and the background color.
[0011] Secondly, embodiments of this application provide an apparatus for adjusting text color, comprising: an acquisition unit configured to acquire a background color of a background and a text color of target text in the background; a calculation unit configured to calculate the brightness contrast between the text color and the background color; and an adjustment unit configured to adjust the text color based on the text color in response to a brightness contrast less than a preset contrast threshold, so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold.
[0012] In some embodiments, the acquisition unit is further configured to: extract the background color of the image as a background according to the image subject color extraction algorithm; and / or acquire the background color based on the background attribute information.
[0013] In some embodiments, the acquisition unit is further configured to: in response to the determination that the background color represented by the attribute information of the background is a gradient color, and the gradient color is a color within a preset angle range threshold on a preset gradient color wheel, determine the color corresponding to the preset angle within the preset angle range threshold as the background color.
[0014] In some embodiments, the adjustment unit is further configured to: in response to a brightness contrast ratio less than a preset contrast threshold, adjust the text color of the target text based on the text color and with the inverted color of the background color as the color adjustment direction, so that the brightness contrast ratio between the adjusted text color and the background color is greater than or equal to the preset contrast threshold.
[0015] In some embodiments, the computing unit is further configured to:
[0016] The brightness of the text color and background color can be calculated using the following formula: L=R×0.2126+G×0.7152+B×0.0722, where L represents brightness, R represents the color value in the red channel, G represents the color value in the green channel, and B represents the color value in the blue channel.
[0017] The brightness contrast between text color and background color is calculated using the following formula: C = (L1 + 0.05) / (L2 + 0.05), where L1 represents the brightness of the text color, L2 represents the brightness of the background color, and C represents the brightness contrast between the text color and the background color.
[0018] Thirdly, embodiments of this application provide a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, it implements the method as described in any implementation of the first aspect.
[0019] Fourthly, embodiments of this application provide an electronic device, including: one or more processors; and a storage device storing one or more programs thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation of the first aspect.
[0020] The method and apparatus for adjusting text color provided in this application embodiment obtain the background color of the background and the text color of the target text in the background; calculate the brightness contrast between the text color and the background color; and adjust the text color based on the text color in response to the brightness contrast being less than a preset contrast threshold, so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold, thereby supporting the adaptation of diverse text colors and enriching the diversity of text display. Attached Figure Description
[0021] Other features, objects, and advantages of this application will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0022] Figure 1 This is an exemplary system architecture diagram in which one embodiment of this application can be applied;
[0023] Figure 2 This is a flowchart of an embodiment of the method for adjusting text color according to this application;
[0024] Figure 3 This is a schematic diagram illustrating an application scenario of the method for adjusting text color according to this embodiment;
[0025] Figure 4 This is a flowchart of yet another embodiment of the method for adjusting text color according to this application;
[0026] Figure 5 This is a structural diagram of one embodiment of the apparatus for adjusting text color according to this application;
[0027] Figure 6This is a schematic diagram of the structure of a computer system suitable for implementing the embodiments of this application. Detailed Implementation
[0028] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.
[0029] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0030] Figure 1 An exemplary architecture 100 for adjusting text color, to which the methods and apparatus of this application can be applied, is shown.
[0031] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105. Network 104 serves as the medium for providing communication links between terminal devices 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0032] Terminal devices 101, 102, and 103 can be hardware or software that supports network connectivity for data interaction and processing. When terminal devices 101, 102, and 103 are hardware, they can be various electronic devices supporting network connectivity, information interaction, display, and processing functions, including but not limited to smartphones, tablets, e-book readers, laptops, and desktop computers. When terminal devices 101, 102, and 103 are software, they can be installed in the aforementioned electronic devices. They can be implemented as multiple software programs or software modules, for example, to provide distributed services, or as a single software program or software module. No specific limitations are imposed here.
[0033] Server 105 can be a server providing various services, such as a background processing server that adjusts text color based on background and text colors sent by terminal devices 101, 102, and 103. The background processing server can determine the brightness and contrast of the background and text colors, and adjust the text color accordingly so that the user can clearly see the target text displayed against the background. Optionally, the background processing server can also feed back the adjustment information to the terminal devices for color adjustment. As an example, server 105 can be a cloud server.
[0034] It should be noted that a server can be either hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When the server is software, it can be implemented as multiple software programs or software modules (such as software programs or software modules used to provide distributed services), or as a single software program or software module. No specific limitations are made here.
[0035] It should also be noted that the method for adjusting text color provided in the embodiments of this disclosure can be executed by a server, by a terminal device, or by a combination of both. Accordingly, the various parts (e.g., units, subunits, modules, submodules) of the information processing apparatus can all be located in the server, all in the terminal device, or separately in the server and the terminal device.
[0036] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Any number of terminal devices, networks, and servers can be included depending on implementation needs. When the electronic device on which the method for adjusting text color runs does not need to transmit data with other electronic devices, the system architecture may only include the electronic device (e.g., a server or terminal device) on which the method for adjusting text color runs.
[0037] Continue to refer to Figure 2 The flowchart 200, illustrating an embodiment of a method for adjusting text color, includes the following steps:
[0038] Step 201: Obtain the background color of the background and the text color of the target text within the background.
[0039] In this embodiment, the execution entity of the method for adjusting text color (e.g.) Figure 1 The terminal device or server in the process can obtain the background color of the background and the text color of the target text in the background.
[0040] The background can be the background of the terminal device's operating system display interface, or the background of various applications deployed on the terminal device. The background can include one or more background colors; similarly, the target text can include one or more text colors.
[0041] As an example, a user frequently uses an e-book application to read e-novels and sets their favorite image as the background on the reading page. The background image is a comic book illustration in various colors, while the text of the e-novel is dark green.
[0042] In some optional implementations of this embodiment, when the background is an image, the execution entity can extract the background color of the image as the background using an image subject color extraction algorithm. Specifically, the execution entity can use color quantization algorithms, clustering algorithms, and color modeling methods to extract the background color from the background image.
[0043] For cases where the background is set based on the application's background settings, the aforementioned execution entity can obtain the background color based on the background's attribute information. For example, the background color can be obtained through the red, green, and blue color values used in the application's background settings.
[0044] In some optional implementations of this embodiment, for the case where the background color is a gradient, the execution entity can obtain the background color in the following way: in response to the determination that the background color represented by the background attribute information is a gradient, and the gradient color is a color within a preset angle range threshold on a preset gradient color ring, the color corresponding to the preset angle within the preset angle range threshold is determined as the background color.
[0045] The gradient can be a gradient of colors within the same color family or a gradient of colors within different color families. For the cases where the gradient is within the same color family or a gradient of colors within different color families, the aforementioned execution entity can set different preset angle range thresholds according to the actual situation. For example, if the gradient is within the same color family, the preset angle threshold can be set to 30°; if the gradient is within different color families, the preset angle threshold can be set to 60°.
[0046] The preset angle can be any angle within a preset angle range threshold, such as the middle angle within the preset angle range threshold.
[0047] Step 202: Calculate the brightness contrast between the text color and the background color.
[0048] In this embodiment, the execution entity can calculate the brightness contrast between the text color and the background color obtained in step 201.
[0049] As an example, the aforementioned execution entity can calculate the brightness contrast between text color and background color using a contrast calculation model. The contrast calculation model represents the correspondence between text color, background color, and brightness contrast.
[0050] In some optional implementations of this embodiment, the execution entity can perform step 202 as follows: First, calculate the brightness of the text color and background color using the following formula: L = R × 0.2126 + G × 0.7152 + B × 0.0722, where L represents brightness, R represents the color value in the red channel, G represents the color value in the green channel, and B represents the color value in the blue channel; then, calculate the brightness contrast of the text color and background color using the following formula: C = (L1 + 0.05) / (L2 + 0.05), where L1 represents the brightness of the text color, L2 represents the brightness of the background color, and C represents the brightness contrast between the text color and the background color. Through this implementation, the execution entity can quickly and accurately obtain the brightness contrast between the text color and the background color through simple calculations.
[0051] Step 203: In response to the brightness contrast being less than a preset contrast threshold, the text color is adjusted based on the text color so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold.
[0052] In this embodiment, in response to the brightness contrast obtained in step 202 being less than a preset contrast threshold, the execution entity adjusts the text color based on the text color so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold.
[0053] The preset contrast threshold can be set according to people's visual habits. When the brightness contrast is less than the preset contrast threshold, it means that the text color is not significantly different from the background color, making it difficult for users to clearly see the target text.
[0054] As an example, the aforementioned implementing entities can refer to the WCAG (Web Content Accessibility Guidelines) 2.0 standard to set the preset contrast threshold. Specifically, for large text with a font size greater than 14 points and bold, or a font size greater than 18 points, the preset contrast threshold can be set to 3 or 4.5. For regular text with a font size less than 18 points, or a font size less than 14 points and bold, the preset contrast threshold can be set to 4.5 or 7.
[0055] Based on text color, adjusting the text color is used to represent the adjusted text color after retaining at least some of its color features. For example, if the text color is dark red and the background color is black, the text color and background color are highly similar, making it difficult for users to clearly see the target text. The aforementioned execution entity can retain the red feature based on the dark red text color and adjust the dark red to a bright red.
[0056] It should be noted that this embodiment can adjust the text color of all target text or adjust the color of some target text.
[0057] When the brightness contrast between the target text color and the background color in the display interface is less than a preset contrast threshold, the text color of all target text can be adjusted. The adjusted target text colors can be the same or different. For example, the background colors of the target text may include multiple colors, each corresponding to a different area. The brightness contrast between the background color in each area and the text color of some of the target text within that area is less than the preset contrast threshold. The execution entity adjusts the text color for the target text in different areas based on the text color corresponding to that area, so that the brightness contrast between the adjusted text color and the background color in that area is greater than or equal to the preset contrast threshold. Since the background colors in different areas are different, the adjusted text colors in each area may also be different.
[0058] If the brightness contrast between the text color of a portion of the target text in the display interface and the background color is less than a preset contrast threshold, then only the text color of that portion of the target text can be adjusted.
[0059] See also Figure 3 , Figure 3 This is a schematic diagram illustrating an application scenario of the method for adjusting text color according to this embodiment. Figure 3 In this application scenario, a user reads an e-book using an e-book application on a smartphone 301. The background color of the e-book application is light green, and the text color of the e-book content (i.e., the target text) is dark yellow. First, the smartphone 301 acquires the background color and the text color of the target text within the background. Then, it calculates the brightness contrast between the text color and the background color. Finally, in response to a brightness contrast less than a preset contrast threshold, the text color is adjusted so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold; the adjusted color is bright yellow.
[0060] The method provided by the above embodiments of this disclosure obtains the background color of the background and the text color of the target text in the background; calculates the brightness contrast between the text color and the background color; and adjusts the text color based on the text color in response to the brightness contrast being less than a preset contrast threshold, so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold, thereby supporting the adaptation of diverse text colors and enriching the diversity of text display.
[0061] Continue to refer to Figure 4The illustration shows a schematic flow 400 of another embodiment of the method for adjusting text color according to this application, including the following steps:
[0062] Step 401: Obtain the background color of the background and the text color of the target text within the background.
[0063] In this embodiment, step 401 and Figure 2 Step 201 in the corresponding embodiment is basically the same, and will not be repeated here.
[0064] Step 402: Calculate the brightness contrast between the text color and the background color.
[0065] In this embodiment, step 402 and Figure 2 Step 202 in the corresponding embodiment is basically the same, and will not be repeated here.
[0066] Step 403: In response to the brightness contrast being less than the preset contrast threshold, the text color of the target text is adjusted based on the text color, with the inverted color of the background color as the color adjustment direction, so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold.
[0067] In this embodiment, the execution subject of the method for adjusting text color responds to the brightness contrast being less than a preset contrast threshold. Based on the text color, the text color of the target text is adjusted with the inverted color of the background color as the color adjustment direction. This can quickly adjust the text color so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold.
[0068] As can be seen from this embodiment, with Figure 2 Compared to the corresponding embodiments, the process 400 of the method for adjusting text color in this embodiment specifically describes adjusting the text color of the target text based on the text color and using the inverted color of the background color as the color adjustment direction. This allows the brightness contrast between the adjusted text color and the background color to be greater than or equal to a preset contrast threshold as quickly as possible, improving the efficiency of text color adjustment.
[0069] Continue to refer to Figure 5 As an implementation of the methods shown in the above figures, this disclosure provides an embodiment of a device for adjusting text color, which is similar to... Figure 2 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.
[0070] like Figure 5As shown, the apparatus for adjusting text color includes: an acquisition unit 501 configured to acquire the background color of a background and the text color of target text in the background; a calculation unit 502 configured to calculate the brightness contrast between the text color and the background color; and an adjustment unit 503 configured to adjust the text color based on the text color in response to the brightness contrast being less than a preset contrast threshold, so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold.
[0071] In some embodiments, the acquisition unit 501 is further configured to: extract the background color of the image as the background according to the image subject color extraction algorithm; and / or acquire the background color based on the background attribute information.
[0072] In some embodiments, the acquisition unit 501 is further configured to: in response to the determination that the background color represented by the attribute information of the background is a gradient color, and the gradient color is a color within a preset angle range threshold on a preset gradient color wheel, determine the color corresponding to the preset angle within the preset angle range threshold as the background color.
[0073] In some embodiments, the adjustment unit 503 is further configured to: in response to a brightness contrast ratio less than a preset contrast threshold, adjust the text color of the target text based on the text color and with the inverted color of the background color as the color adjustment direction, so that the brightness contrast ratio between the adjusted text color and the background color is greater than or equal to the preset contrast threshold.
[0074] In some embodiments, the calculation unit 502 is further configured to: calculate the brightness of the text color and the background color respectively using the following formula: L=R×0.2126+G×0.7152+B×0.0722, where L represents brightness, R represents the color value in the red channel, G represents the color value in the green channel, and B represents the color value in the blue channel; and calculate the brightness contrast of the text color and the background color using the following formula: C=(L1+0.05) / (L2+0.05), where L1 represents the brightness of the text color, L2 represents the brightness of the background color, and C represents the brightness contrast between the text color and the background color.
[0075] In this embodiment, the acquisition unit in the device for adjusting text color acquires the background color of the background and the text color of the target text in the background; the calculation unit calculates the brightness contrast between the text color and the background color; and the adjustment unit adjusts the text color based on the text color in response to the brightness contrast being less than a preset contrast threshold, so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold, thereby supporting the adaptation of diverse text colors and enriching the diversity of text display.
[0076] The following is for reference. Figure 6 It illustrates a device suitable for implementing embodiments of this application (e.g., Figure 1 The diagram shows the structure of the computer system 600 of the devices 101, 102, 103, and 105. Figure 6 The device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0077] like Figure 6 As shown, the computer system 600 includes a processor (e.g., CPU, Central Processing Unit) 601, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 602 or programs loaded from storage section 608 into random access memory (RAM) 603. The RAM 603 also stores various programs and data required for the operation of the system 600. The processor 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0078] The following components are connected to I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 610 as needed so that computer programs read from it can be installed into storage section 608 as needed.
[0079] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by processor 601, it performs the functions defined above in the methods of this application.
[0080] It should be noted that the computer-readable medium of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0081] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof. Programming languages include object-oriented programming languages—such as Java, Smalltalk, and C++—as well as conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the client computer, partially on the client computer, as a standalone software package, partially on the client computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the client computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0082] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0083] The units described in the embodiments of this application can be implemented in software or hardware. The described units can also be housed in a processor; for example, they can be described as: a processor including an acquisition unit, a calculation unit, and an adjustment unit. The names of these units do not necessarily limit the unit itself; for example, the adjustment unit can also be described as "a unit that, in response to a brightness contrast ratio less than a preset contrast threshold, adjusts the text color based on the text color so that the brightness contrast ratio between the adjusted text color and the background color is greater than or equal to a preset contrast threshold."
[0084] In another aspect, this application also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs that, when executed by the device, cause the computer device to: acquire the background color of a background and the text color of target text within the background; calculate the brightness contrast between the text color and the background color; and, in response to a brightness contrast less than a preset contrast threshold, adjust the text color based on the text color so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold.
[0085] The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described inventive concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this application.
Claims
1. A method for adjusting text color, comprising: For each region in the background that has a different color, obtain the background color of each region in the background and the text color of the target text in each region of the background; Calculate the brightness contrast between the text color and the background color; In response to the brightness contrast being less than a preset contrast threshold, the text color is adjusted while retaining at least some of the color features of the text color, so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold. The step of obtaining the background color of each region in the background includes: In response to determining that the background color represented by the attribute information of each region in the background is a gradient of colors in the same color family, and that the gradient color is a color within a first preset angle range threshold on a preset gradient color wheel, the color corresponding to the first preset angle in the first preset angle range threshold is determined as the background color. In response to determining that the background color represented by the attribute information of each region in the background is a gradient of different color systems, and that the gradient color is a color within a second preset angle range threshold on a preset gradient color wheel, the color corresponding to the second preset angle within the second preset angle range threshold is determined as the background color.
2. The method according to claim 1, wherein, Getting the background color also includes: The background color is extracted based on the image subject color extraction algorithm, using the image as the background.
3. The method according to claim 1, wherein, The step of adjusting the text color based on the text color, so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold, in response to the brightness contrast being less than a preset contrast threshold, includes: In response to the brightness contrast being less than a preset contrast threshold, the text color of the target text is adjusted based on the text color, with the inverted color of the background color as the color adjustment direction, so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold.
4. A device for adjusting text color, comprising: The acquisition unit is configured to acquire the background color of each region in the background and the text color of the target text in each region of the background for each region with a different background color; The calculation unit is configured to calculate the brightness contrast between the text color and the background color; The adjustment unit is configured to adjust the text color in response to the brightness contrast being less than a preset contrast threshold, while retaining at least some of the color features of the text color, so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold. The acquisition unit is further configured to: In response to determining that the background color represented by the attribute information of each region in the background is a gradient of colors in the same color family, and that the gradient color is a color within a first preset angle range threshold on a preset gradient color wheel, the color corresponding to the first preset angle in the first preset angle range threshold is determined as the background color. In response to determining that the background color represented by the attribute information of each region in the background is a gradient of different color systems, and that the gradient color is a color within a second preset angle range threshold on a preset gradient color wheel, the color corresponding to the second preset angle within the second preset angle range threshold is determined as the background color.
5. The apparatus according to claim 4, wherein, The acquisition unit is further configured to: The background color is extracted based on the image subject color extraction algorithm, using the image as the background.
6. The apparatus according to claim 4, wherein, The adjustment unit is further configured to: In response to the brightness contrast being less than a preset contrast threshold, the text color of the target text is adjusted based on the text color, with the inverted color of the background color as the color adjustment direction, so that the brightness contrast between the adjusted text color and the background color is greater than or equal to the preset contrast threshold.
7. A computer-readable medium having a computer program stored thereon, wherein, When the program is executed by the processor, it implements the method as described in any one of claims 1-3.
8. An electronic device, comprising: One or more processors; Storage device, on which one or more programs are stored, When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-3.