Text detection method and device, storage medium and computer program product
By calculating and displaying the contrast results of text characters in real time, the problem of lack of real-time contrast analysis function in the prior art is solved, simplifying the text optimization process and improving text readability.
Patent Information
- Application Number
- CN202510181985.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2025-05-23
AI Technical Summary
The existing text editing software lacks real-time character contrast analysis function, which leads to users frequently using external tools when adjusting text visual effects, which is time-consuming and labor-intensive, especially for readers with vision impairment.
Provide a text detection method, by obtaining the current RGB value of the target character and the RGB value of the background pixel, calculating the relative brightness, and generating the current contrast result, which is displayed to the user in real time.
Real-time detection of character contrast can be achieved without external tools, simplifying the text optimization process and improving the readability of text, especially for readers with vision impairment, which helps improve the reading experience.
Smart Images

Figure CN120031855A_ABST
Abstract
Claims
1. A text detection method, characterized in that: The method includes: Obtain the current RGB value of the target character in the current page and the RGB value of the background pixel where the target character is located; Calculating the relative brightness of the target character according to the current RGB value of the target character, and calculating the relative brightness of the background pixel according to the RGB value of the background pixel; A current contrast result corresponding to the target character is generated according to the relative brightness of the target character and the relative brightness of the background pixels for display.
2. The method according to claim 1, characterized in that: The generating a current contrast result corresponding to the target character according to the relative brightness of the target character and the relative brightness of the background pixels for display includes: Determine a smaller value and a larger value of a relative brightness of the target character and a relative brightness of the background pixels; The sum of the smaller value and the preset offset value is used as the denominator, and the sum of the larger value and the preset offset value is used as the numerator; The ratio between the numerator and the denominator is calculated, and the ratio is used as the current contrast result for display.
3. The method according to claim 1, characterized in that: Also includes: The character style of the target character is compared with a preset style standard to obtain a style detection result corresponding to the target character for display, wherein the preset style standard includes a network accessibility standard and / or a custom style standard.
4. The method according to claim 1, characterized in that Also includes: Generating a recommended color range for the target character for display, wherein all recommended colors included in the recommended color range meet a preset contrast standard, wherein the preset contrast standard includes a network accessibility standard and / or a custom contrast standard; In response to a selection operation of any recommended color in the recommended color range, the color of the target character is adjusted to the selected recommended color.
5. The method according to claim 4, characterized in that The generating a recommended color range for the target character comprises: Convert the current RGB value of the target character to the current HSL value; Determining a recommended range of brightness values that meets the preset contrast standard; The recommended color range is generated by rendering based on all recommended brightness values included in the recommended brightness value range and the saturation value and the hue value in the current HSL value.
6. The method according to claim 5, characterized in that The determining of the recommended brightness value range that meets the preset contrast standard includes: Determine a maximum brightness value and a minimum brightness value that meet the preset contrast standard, and use the maximum brightness value as an upper limit of the range, and use the minimum brightness value as a lower limit of the range, so as to determine a first brightness value range; Determine a second brightness value range based on the brightness value in the current HSL value, wherein an upper limit of the second brightness value range is a sum of the brightness value in the current HSL value and a preset brightness value adjustment amplitude, and a lower limit of the second brightness value range is a difference between the brightness value in the current HSL value and the preset brightness value adjustment amplitude; An intersection of the first brightness value range, the second brightness value range and the third brightness value range is determined to use the intersection as the recommended brightness value range, wherein the third brightness value range is greater than or equal to a first preset threshold and less than or equal to a second preset threshold.
7. A text detection device, characterized in that: The device includes: An acquisition module, used to acquire the current RGB value of the target character in the current page and the RGB value of the background pixel at the position of the target character; A calculation module, used for calculating the relative brightness of the target character according to the current RGB value of the target character, and calculating the relative brightness of the background pixel according to the RGB value of the background pixel; A generating module is used to generate a current contrast result corresponding to the target character according to the relative brightness of the target character and the relative brightness of the background pixels for display.
8. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor implements the method according to any one of claims 1 to 6 by running the executable instructions.
9. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the instruction is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
10. A computer program product, characterized in that The method comprises a computer program / instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 6.