CN114089994A - Method and device for adjusting text color - Google Patents

Method and device for adjusting text color Download PDF

Info

Publication number
CN114089994A
CN114089994A CN202010668562.9A CN202010668562A CN114089994A CN 114089994 A CN114089994 A CN 114089994A CN 202010668562 A CN202010668562 A CN 202010668562A CN 114089994 A CN114089994 A CN 114089994A
Authority
CN
China
Prior art keywords
color
background
text
preset
contrast
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010668562.9A
Other languages
Chinese (zh)
Inventor
高明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202010668562.9A priority Critical patent/CN114089994A/en
Publication of CN114089994A publication Critical patent/CN114089994A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Facsimile Image Signal Circuits (AREA)

Abstract

The embodiment of the application discloses a method and a device for adjusting text color. One embodiment of the method comprises: acquiring a background color of a background and a text color of a target text in the background; calculating the brightness contrast of the text color and the background color; and responding to the fact that the brightness contrast is smaller than the preset contrast threshold, on the basis of the text color, adjusting the text color to enable the brightness contrast of the adjusted text color and the background color to be larger than or equal to the preset contrast threshold, so that the adaptation of multiple text colors can be supported, and the diversity of text display is enriched.

Description

Method and device for adjusting text color
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a method and a device for adjusting text color.
Background
In the development process of the application program, the colors of the text are generally black and white, but in the application program application process of a user, the application program changes the skin and changes the theme into a trend, and in the diversified display effect, developers abandon the previous monochrome base map more and replace the monochrome base map with a multicolor picture base map. Similarly, developers also use multiple text color values and background color values in more scenes to highlight the hierarchical sense and the hierarchical structure of the content. Therefore, single text color (black, white) adaptation cannot meet the increasing demands of users at present.
Disclosure of Invention
The embodiment of the application provides a method and a device for adjusting text color.
In a first aspect, an embodiment of the present application provides a method for adjusting text color, including: acquiring a background color of a background and a text color of a target text in the background; calculating the brightness contrast of the text color and the background color; and responding to the brightness contrast ratio smaller than the preset contrast threshold value, and on the basis of the text color, adjusting the text color so that the brightness contrast ratio of the adjusted text color and the background color is larger than or equal to the preset contrast threshold value.
In some embodiments, the obtaining the background color of the background includes: extracting a background color with the image as a background according to an image body color extraction algorithm; and/or obtaining the background color based on the attribute information of the background.
In some embodiments, the obtaining the background color based on the attribute information of the background includes: and in response to the fact 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 value on a preset gradient color ring, determining a color corresponding to a preset angle in the preset angle range threshold value as the background color.
In some embodiments, the adjusting the text color based on the text color in response to the brightness contrast being less than the preset contrast threshold to make the brightness contrast of the adjusted text color to the background color greater than or equal to the preset contrast threshold includes: and responding to the fact that the brightness contrast is smaller than the preset contrast threshold, on the basis of the text color, adjusting the text color of the target text by taking the reverse color of the background color as a color adjustment direction, so that the brightness contrast of the adjusted text color and the background color is larger than or equal to the preset contrast threshold.
In some embodiments, the calculating the luminance contrast of the text color and the background color includes:
the lightness of the text color and the background color are calculated by the following formulas, respectively: l ═ rx0.2126 + gx 0.7152+ bx0.0722, where L characterizes the luminance, R characterizes the color value in the red channel, G characterizes the color value in the green channel, and B characterizes the color value in the blue channel;
the luminance contrast of the text color and the background color is calculated by the following formula: c ═ L1+0.05)/(L2+0.05), where L1 denotes the lightness of the text color, L2 denotes the lightness of the background color, and C denotes the contrast in lightness of the text color to the background color.
In a second aspect, an embodiment of the present application provides an apparatus for adjusting text color, including: an acquisition unit configured to acquire a background color of a background and a text color of a target text in the background; a calculation unit configured to calculate a luminance contrast of a text color and a background color; and the adjusting unit is configured to respond to the brightness contrast ratio being less than the preset contrast threshold value, and on the basis of the text color, adjust the text color so that the brightness contrast ratio of the adjusted text color and the background color is greater than or equal to the preset contrast threshold value.
In some embodiments, the obtaining unit is further configured to: extracting a background color with the image as a background according to an image body color extraction algorithm; and/or obtaining the background color based on the attribute information of the background.
In some embodiments, the obtaining unit is further configured to: and in response to the fact 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 value on a preset gradient color ring, determining a color corresponding to a preset angle in the preset angle range threshold value as the background color.
In some embodiments, the adjustment unit is further configured to: and responding to the fact that the brightness contrast is smaller than the preset contrast threshold, on the basis of the text color, adjusting the text color of the target text by taking the reverse color of the background color as a color adjustment direction, so that the brightness contrast of the adjusted text color and the background color is larger than or equal to the preset contrast threshold.
In some embodiments, the computing unit is further configured to:
the lightness of the text color and the background color are calculated by the following formulas, respectively: l ═ rx0.2126 + gx 0.7152+ bx0.0722, where L characterizes the luminance, R characterizes the color value in the red channel, G characterizes the color value in the green channel, and B characterizes the color value in the blue channel;
the luminance contrast of the text color and the background color is calculated by the following formula: c ═ L1+0.05)/(L2+0.05), where L1 denotes the lightness of the text color, L2 denotes the lightness of the background color, and C denotes the contrast in lightness of the text color to the background color.
In a third aspect, the present application provides a computer-readable medium, on which a computer program is stored, where the program, when executed by a processor, implements the method as described in any implementation manner of the first aspect.
In a fourth aspect, an embodiment of the present application provides an electronic device, including: one or more processors; a storage device having one or more programs stored thereon, which when executed by one or more processors, cause the one or more processors to implement a method as described in any implementation of the first aspect.
According to the method and the device for adjusting the text color, the background color of the background and the text color of the target text in the background are obtained; calculating the brightness contrast of the text color and the background color; and responding to the fact that the brightness contrast is smaller than the preset contrast threshold, on the basis of the text color, adjusting the text color to enable the brightness contrast of the adjusted text color and the background color to be larger than or equal to the preset contrast threshold, so that the adaptation of multiple text colors can be supported, and the diversity of text display is enriched.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of a method for adjusting text color according to the present application;
FIG. 3 is a schematic diagram of an application scenario of the method for adjusting text color according to the present embodiment;
FIG. 4 is a flow diagram of yet another embodiment of a method for adjusting text color according to the present application;
FIG. 5 is a block diagram of one embodiment of an apparatus for adjusting color of text according to the present application;
FIG. 6 is a block diagram of a computer system suitable for use in implementing embodiments of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 illustrates an exemplary architecture 100 to which the method and apparatus for adjusting text color of the present application may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The terminal devices 101, 102, 103 may be hardware devices or software that support network connections for data interaction and data processing. When the terminal devices 101, 102, and 103 are hardware, they may be various electronic devices supporting network connection, information interaction, display, processing, and the like, including but not limited to smart phones, tablet computers, e-book readers, laptop portable computers, desktop computers, and the like. When the terminal apparatuses 101, 102, 103 are software, they can be installed in the electronic apparatuses listed above. It may be implemented, for example, as multiple software or software modules to provide distributed services, or as a single software or software module. And is not particularly limited herein.
The server 105 may be a server providing various services, such as a background processing server adjusting the text color based on the background color and text color sent by the terminal devices 101, 102, 103. The background processing server can determine the brightness contrast of the background color and the text color, and adjust the text color according to the brightness contrast so that the user can clearly view the target text displayed in the background. Optionally, the background processing server may further feed back the adjustment information to the terminal device, so that the terminal device performs color adjustment. As an example, the server 105 may be a cloud server.
The server may be hardware or software. When the server is hardware, it may be implemented as a distributed server cluster formed by multiple servers, or may be implemented as a single server. When the server is software, it may be implemented as multiple pieces of software or software modules (e.g., software or software modules used to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
It should be further noted that the method for adjusting text color provided by the embodiments of the present disclosure may be executed by a server, may also be executed by a terminal device, and may also be executed by the server and the terminal device in cooperation with each other. Accordingly, each part (for example, each unit, sub-unit, module, and sub-module) included in the information processing apparatus may be entirely provided in the server, may be entirely provided in the terminal device, and may be provided in the server and the terminal device, respectively.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation. When the electronic device on which the method for adjusting the color of text is operated does not require data transmission with other electronic devices, the system architecture may include only the electronic device (e.g., a server or a terminal device) on which the method for adjusting the color of text is operated.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method for adjusting text color is shown, comprising the steps of:
in step 201, a background color of a background and a text color of a target text in the background are obtained.
In this embodiment, an executing subject (for example, the terminal device or the server in fig. 1) of the method for adjusting the text color may obtain a background color of the background and a text color of the target text in the background.
The background may be a background in a display interface of an operating system of the terminal device, or may be a background of various application programs deployed in the terminal device. The background may be a background comprising one or more background colors, and likewise, the target text may be text comprising one or more text colors.
As an example, a user often uses an e-book type application to read electronic novels and sets favorite pictures as backgrounds in the reading page. The background picture is a cartoon picture and comprises a plurality of colors, and the color of the text corresponding to the electronic novel is dark green.
In some optional implementations of the embodiment, for a case where the background is an image, the execution subject may extract a background color with the image as the background through an image subject color extraction algorithm. Specifically, the executing agent may extract the background color in the background image by using a color quantization algorithm, a clustering algorithm, and a color modeling method.
The execution body may acquire the background color based on the attribute information of the background, for a case where the background is a background set based on the background setting function of the application. For example, the background color may be obtained by the red, green, and blue tristimulus values at the time of application background setting.
In some optional implementations of this embodiment, for a case that the background color is a gradient color, the executing entity may obtain the background color by: and in response to the fact 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 value on a preset gradient color ring, determining a color corresponding to a preset angle in the preset angle range threshold value as the background color.
The gradient color may be a gradient color of the same color system color or a gradient color of different color systems color. For the situations that the gradient color is the gradient color of the same color system and the gradient color of different color systems, the execution main body can set different preset angle range thresholds according to the actual situation. As an example, if the gradient color is a gradient color of the same color family, the preset angle threshold may be set to 30 °; if the gradient color is a gradient color of different color systems, the preset angle threshold may be set to 60 °.
The preset angle may be any angle in the preset angle range threshold, for example, may be a middle angle in the preset angle range threshold.
Step 202, calculating the brightness contrast of the text color and the background color.
In this embodiment, the executing entity may calculate the brightness contrast between the text color and the background color obtained in step 201.
As an example, the execution subject described above may calculate the luminance contrast of the text color and the background color by the contrast calculation model. The contrast calculation model represents the corresponding relation among the text color, the background color and the brightness contrast.
In some optional implementations of this embodiment, the executing main body may execute step 202 by: first, the lightness of the text color and the background color are calculated by the following formulas, respectively: l ═ rx0.2126 + gx 0.7152+ bx0.0722, where L characterizes the luminance, R characterizes the color value in the red channel, G characterizes the color value in the green channel, and B characterizes the color value in the blue channel; then, the luminance contrast of the text color and the background color is calculated by the following formula: c ═ L1+0.05)/(L2+0.05), where L1 denotes the lightness of the text color, L2 denotes the lightness of the background color, and C denotes the contrast in lightness of the text color to the background color. Through the implementation mode, the execution main body can quickly and accurately obtain the brightness contrast of the text color and the background color through simple operation.
Step 203, in response to the brightness contrast being less than the preset contrast threshold, on the basis of the text color, adjusting 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 this embodiment, in response to that the brightness contrast obtained in step 202 is smaller than the preset contrast threshold, the executing entity adjusts the text color based on the text color, so that the brightness contrast between the text color and the background color after the adjustment is greater than or equal to the preset contrast threshold.
Wherein, the preset contrast threshold can be specifically set according to the visual habits of people. When the brightness contrast is less than the preset contrast threshold, it indicates that the text color is not clearly distinguished from the background color, so that the user cannot clearly view the target text.
As an example, the execution subject may set the preset contrast threshold with reference to WCAG (Web Content Accessibility guides) 2.0 standard. Specifically, the preset contrast threshold may be set to 3 or 4.5 for large text having a font size greater than 14 pounds and bolded, or a font size greater than 18 pounds. The preset contrast threshold may be set to 4.5 or 7 for regular text with a font size less than 18 pounds, or a font size less than 14 pounds and bolded.
Based on the text color, the text color is adjusted to represent the text color after the adjustment by keeping at least partial color characteristics of the text color. For example, the text color is dark red, and the background color is black, in which case the similarity between the text color and the background color is high, and the user cannot clearly view the target text. The execution subject can keep the red characteristic and adjust the dark red to the bright red on the basis of the text color of the dark red.
It should be noted that, in this embodiment, the color of the text of all the target texts may be adjusted, or the color of part of the target texts may be adjusted.
When the brightness contrast of the text color of the target text in the display interface and the background color of the background is smaller than the preset contrast threshold, the text colors of all the target texts can be adjusted, and the colors of the adjusted target texts can be the same or different. As an example, the background color of the background of the target text includes a plurality of colors, the colors respectively correspond to different regions, the luminance contrast between the background color in each region and the text color of the partial target text in each region is less than the preset contrast threshold, and the execution subject adjusts the text color for the target text in the different regions based on the text color corresponding to the region, so that the luminance contrast between the text color and the background color in the region after the adjustment is greater than or equal to the preset contrast threshold. Since the background color in each region is different, the text color in each region after adjustment may also be different.
When the brightness contrast ratio of the text color of a part of target text in the display interface to the background color of the background is smaller than the preset contrast threshold, only the text color of the part of target text can be adjusted.
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the method for adjusting text color according to the present embodiment. In the application scenario of fig. 3, a user reads an e-book through an e-book application in the smartphone 301. The background color of the background 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. Firstly, the smart phone 301 obtains a background color of a background and a text color of a target text in the background; then, the luminance contrast of the text color to the background color is calculated. And finally, responding to the fact that the brightness contrast is smaller than the preset contrast threshold, on the basis of the text color, adjusting the text color to enable the brightness contrast of the adjusted text color and the background color to be larger than or equal to the preset contrast threshold, wherein the adjusted color is bright yellow.
In the method provided by the above embodiment of the present disclosure, a background color of a background and a text color of a target text in the background are obtained; calculating the brightness contrast of the text color and the background color; and responding to the fact that the brightness contrast is smaller than the preset contrast threshold, on the basis of the text color, adjusting the text color to enable the brightness contrast of the adjusted text color and the background color to be larger than or equal to the preset contrast threshold, so that the adaptation of multiple text colors can be supported, and the diversity of text display is enriched.
With continuing reference to FIG. 4, a schematic flow chart 400 illustrating another embodiment of a method for adjusting text color in accordance with the present application is shown that includes the steps of:
step 401, obtaining a background color of a background and a text color of a target text in the background.
In this embodiment, step 401 is substantially the same as step 201 in the corresponding embodiment of fig. 2, and is not described here again.
Step 402, calculating the brightness contrast of the text color and the background color.
In this embodiment, step 402 is substantially the same as step 202 in the corresponding embodiment of fig. 2, and is not described here again.
And 403, in response to that the brightness contrast is smaller than the preset contrast threshold, on the basis of the text color, adjusting the text color of the target text by taking the reverse 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.
In this embodiment, the main executing body of the method for adjusting the text color adjusts the text color of the target text in the color adjustment direction by using the reverse color of the background color on the basis of the text color in response to the brightness contrast being smaller than the preset contrast threshold, so that the text color can be quickly adjusted to make the brightness contrast between the adjusted text color and the background color be greater than or equal to the preset contrast threshold.
As can be seen from this embodiment, compared with the embodiment corresponding to fig. 2, the flow 400 of the method for adjusting text color in this embodiment specifically illustrates that, on the basis of text color, the text color of the color adjustment target text is adjusted by using the reverse color of the background color as the color adjustment direction. Therefore, the brightness contrast ratio of the adjusted text color and the background color is greater than or equal to the preset contrast threshold value as soon as possible, and the efficiency of text color adjustment is improved.
With continuing reference to fig. 5, as an implementation of the method shown in the above figures, the present disclosure provides an embodiment of an apparatus for adjusting text color, which corresponds to the embodiment of the method shown in fig. 2, and which is particularly applicable to various electronic devices.
As shown in fig. 5, the apparatus for adjusting text color includes: an obtaining unit 501 configured to obtain a background color of a background and a text color of a target text in the background; a calculating unit 502 configured to calculate a luminance contrast of a text color and a background color; an adjusting unit 503 configured to adjust the text color on the basis of the text color in response to the brightness contrast being less than the preset contrast threshold, such that the brightness contrast of the adjusted text color to the background color is greater than or equal to the preset contrast threshold.
In some embodiments, the obtaining unit 501 is further configured to: extracting a background color with the image as a background according to an image body color extraction algorithm; and/or obtaining the background color based on the attribute information of the background.
In some embodiments, the obtaining unit 501 is further configured to: and in response to the fact 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 value on a preset gradient color ring, determining a color corresponding to a preset angle in the preset angle range threshold value as the background color.
In some embodiments, the adjusting unit 503 is further configured to: and responding to the fact that the brightness contrast is smaller than the preset contrast threshold, on the basis of the text color, adjusting the text color of the target text by taking the reverse color of the background color as a color adjustment direction, so that the brightness contrast of the adjusted text color and the background color is larger than or equal to the preset contrast threshold.
In some embodiments, the computing unit 502 is further configured to: the lightness of the text color and the background color are calculated by the following formulas, respectively: l ═ rx0.2126 + gx 0.7152+ bx0.0722, where L characterizes the luminance, R characterizes the color value in the red channel, G characterizes the color value in the green channel, and B characterizes the color value in the blue channel; the luminance contrast of the text color and the background color is calculated by the following formula: c ═ L1+0.05)/(L2+0.05), where L1 denotes the lightness of the text color, L2 denotes the lightness of the background color, and C denotes the contrast in lightness of the text color to the background color.
In this embodiment, an obtaining unit in the apparatus for adjusting text color obtains a background color of a background and a text color of a target text in the background; the calculating unit calculates the brightness contrast of the text color and the background color; the adjusting unit responds to the fact that the brightness contrast is smaller than the preset contrast threshold, on the basis of the text color, the text color is adjusted, so that the brightness contrast of the adjusted text color and the background color is larger than or equal to the preset contrast threshold, adaptation of multiple text colors can be supported, and the diversity of text display is enriched.
Referring now to FIG. 6, shown is a block diagram of a computer system 600 suitable for use in implementing devices of embodiments of the present application (e.g., devices 101, 102, 103, 105 shown in FIG. 1). The apparatus shown in fig. 6 is only an example, and should not bring any limitation to the function and use range of the embodiments of the present application.
As shown in fig. 6, the computer system 600 includes a processor (e.g., CPU, central processing unit) 601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data necessary for the operation of the system 600 are also stored. The processor 601, the ROM602, and the RAM603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program, when executed by the processor 601, performs the above-described functions defined in the method of the present application.
It should be noted that the computer readable medium of the present application can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the client computer, partly on the client computer, as a stand-alone software package, partly on the client computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the client computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present application may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes an acquisition unit, a calculation unit, and an adjustment unit. Where the names of the cells do not in some cases constitute a limitation on the cells themselves, for example, an adjustment cell may also be described as a "cell that adjusts the text color based on the text color such that the brightness contrast of the adjusted text color to the background color is greater than or equal to a preset contrast threshold in response to the brightness contrast being less than the preset contrast threshold".
As another aspect, the present application also provides a computer-readable medium, which may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by the apparatus, cause the computer device to: acquiring a background color of a background and a text color of a target text in the background; calculating the brightness contrast of the text color and the background color; and responding to the brightness contrast ratio smaller than the preset contrast threshold value, and on the basis of the text color, adjusting the text color so that the brightness contrast ratio of the adjusted text color and the background color is larger than or equal to the preset contrast threshold value.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the invention. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (10)

1. A method for adjusting text color, comprising:
acquiring a background color of a background and a text color of a target text in the background;
calculating the brightness contrast of the text color and the background color;
in response to the brightness contrast being less than a preset contrast threshold, adjusting the text color based on the text color such that the brightness contrast of the adjusted text color to the background color is greater than or equal to the preset contrast threshold.
2. The method of claim 1, wherein the obtaining a background color of the background comprises:
extracting the background color with the image as the background according to an image body color extraction algorithm; and/or
And acquiring the background color based on the attribute information of the background.
3. The method of claim 2, wherein the obtaining the background color based on the attribute information of the background comprises:
and in response to determining 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 ring, determining a color corresponding to a preset angle in the preset angle range threshold as the background color.
4. The method of claim 1, wherein said adjusting the text color based on the text color in response to the brightness contrast being less than a preset contrast threshold such that the brightness contrast of the adjusted text color to the background color is greater than or equal to the preset contrast threshold comprises:
and responding to the brightness contrast ratio smaller than a preset contrast threshold value, on the basis of the text color, adjusting the text color of the target text by taking the reverse color of the background color as a color adjustment direction, so that the brightness contrast ratio of the adjusted text color and the background color is larger than or equal to the preset contrast threshold value.
5. An apparatus for adjusting text color, comprising:
an acquisition unit configured to acquire a background color of a background and a text color of a target text in the background;
a calculation unit configured to calculate a luminance contrast of the text color and the background color;
an adjusting unit configured to adjust the text color on the basis of the text color in response to the brightness contrast being less than a preset contrast threshold, such that the brightness contrast of the adjusted text color to the background color is greater than or equal to the preset contrast threshold.
6. The apparatus of claim 5, wherein the obtaining unit is further configured to:
extracting the background color with the image as the background according to an image body color extraction algorithm; and/or acquiring the background color based on the attribute information of the background.
7. The apparatus of claim 6, wherein the obtaining unit is further configured to:
and in response to determining 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 ring, determining a color corresponding to a preset angle in the preset angle range threshold as the background color.
8. The apparatus of claim 5, wherein the adjustment unit is further configured to:
and responding to the brightness contrast ratio smaller than a preset contrast threshold value, on the basis of the text color, adjusting the text color of the target text by taking the reverse color of the background color as a color adjustment direction, so that the brightness contrast ratio of the adjusted text color and the background color is larger than or equal to the preset contrast threshold value.
9. A computer-readable medium, on which a computer program is stored, wherein the program, when executed by a processor, implements the method of any one of claims 1-4.
10. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-4.
CN202010668562.9A 2020-07-13 2020-07-13 Method and device for adjusting text color Pending CN114089994A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010668562.9A CN114089994A (en) 2020-07-13 2020-07-13 Method and device for adjusting text color

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010668562.9A CN114089994A (en) 2020-07-13 2020-07-13 Method and device for adjusting text color

Publications (1)

Publication Number Publication Date
CN114089994A true CN114089994A (en) 2022-02-25

Family

ID=80294819

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010668562.9A Pending CN114089994A (en) 2020-07-13 2020-07-13 Method and device for adjusting text color

Country Status (1)

Country Link
CN (1) CN114089994A (en)

Similar Documents

Publication Publication Date Title
US10719923B2 (en) Method and apparatus for processing image
CN110865862B (en) Page background setting method and device and electronic equipment
US20200410213A1 (en) Method and apparatus for processing mouth image
US20220414971A1 (en) Method of processing information, method of rendering image, and electronic device
CN110211030B (en) Image generation method and device
CN112839223B (en) Image compression method, image compression device, storage medium and electronic equipment
CN109102484B (en) Method and apparatus for processing image
US20230410380A1 (en) Method and apparatus for generating page
CN114494298A (en) Object segmentation method, device, equipment and storage medium
CN112181568A (en) Locally adapting screen method and apparatus
CN110263301B (en) Method and device for determining color of text
CN113742025A (en) Page generation method, device, equipment and storage medium
CN110288625B (en) Method and apparatus for processing image
CN113923474B (en) Video frame processing method, device, electronic equipment and storage medium
CN112348910A (en) Method, device, equipment and computer readable medium for acquiring image
CN110097520B (en) Image processing method and device
CN114089994A (en) Method and device for adjusting text color
CN112215237B (en) Image processing method and device, electronic equipment and computer readable storage medium
US10945034B2 (en) Video fractal cross correlated action bubble transition
CN113989404A (en) Picture processing method, device, equipment, storage medium and program product
WO2020011066A1 (en) Terminal display method and device, terminal and readable medium
CN113409199A (en) Image processing method, image processing device, electronic equipment and computer readable medium
CN111583163A (en) AR-based face image processing method, device, equipment and storage medium
CN109062645A (en) The method and apparatus of processing information for terminal
CN111798399B (en) Image processing method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination