Character image recognition method and related device

By performing pixel-level analysis on remote desktop images and calculating scores for contrast, color uniqueness, and directional features, text regions can be accurately identified, solving the problem of reduced text clarity in remote desktop environments and improving user experience and efficiency.

CN121938006APending Publication Date: 2026-04-28HUNAN KYLIN XINAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUNAN KYLIN XINAN TECH CO LTD
Filing Date
2025-12-29
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

In remote desktop application scenarios, when the network environment is unstable or bandwidth is limited, existing technologies struggle to maintain text clarity while ensuring smooth transmission, resulting in blurred character edges and broken strokes, which affects user experience and work efficiency.

Method used

By performing pixel-level analysis on image regions, the contrast score, color uniqueness ratio, and row and column direction feature score are calculated. These feature scores are then combined to determine whether the image region contains text, thus achieving accurate recognition of text regions.

Benefits of technology

In bandwidth-constrained remote desktop environments, it can maintain text clarity, improve user experience and work efficiency, and achieve a synergistic balance between bandwidth optimization and text fidelity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121938006A_ABST
    Figure CN121938006A_ABST
Patent Text Reader

Abstract

The invention provides a character image recognition method and a related device, and relates to the technical field of image processing. By performing pixel-level analysis on the image area and integrating the contrast score, the color uniqueness ratio and the rank directivity feature score, accurate recognition of the text area is realized, and the problem that text and non-text contents cannot be effectively distinguished in the prior art is solved. The method has the advantages that the character content in the image area is accurately recognized, the character area and the non-character area are effectively distinguished, and the character readability and the user experience in the remote desktop scene are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a method and related apparatus for recognizing text images. Background Technology

[0002] In remote desktop applications, when the network environment is unstable or bandwidth is limited, existing protocols typically employ strategies to reduce image quality to ensure overall transmission smoothness. These strategies include lossy compression or resolution reduction to decrease data volume. However, such processing significantly negatively impacts text content areas, causing blurred character edges, broken strokes, or decreased contrast. This severely hinders users in operations that rely on text clarity, such as document editing and spreadsheet viewing. Especially in critical scenarios like office automation and remote education, the lack of text readability directly affects work efficiency and user experience. While existing technologies attempt to mitigate the problem through global image enhancement or fixed-area processing, they lack the ability to accurately locate text regions and cannot efficiently distinguish between text and non-text content in dynamically changing image streams. Consequently, achieving a synergistic balance between bandwidth optimization and text fidelity is difficult. Therefore, existing technologies urgently need improvement to address these issues. Summary of the Invention

[0003] This application provides a method and related apparatus for recognizing text images, which has the ability to accurately locate text regions, thereby maintaining text clarity in a bandwidth-limited remote desktop environment and improving user experience and work efficiency.

[0004] Firstly, the text image recognition method provided in this application adopts the following technical solution: Perform pixel-level analysis on the input image region; Calculate the contrast score of the image region, which is based on the sum of the absolute differences in the RGB components of all adjacent pixel pairs within the image region; Calculate the color uniqueness ratio of the image region, which is based on the number of different color values ​​in the image region as counted by a hash table; The RGB image of the image region is converted into a grayscale image, and the row and column directional feature score is calculated. The row and column directional feature score is based on the ratio of the variance of the sum of grayscale values ​​in each row to the variance of the sum of grayscale values ​​in each column, and the row-to-column ratio is set based on the number of different values ​​of the sum of grayscale values ​​in each row and the number of different values ​​of the sum of grayscale values ​​in each column. The region score is obtained by combining the contrast score, color uniqueness ratio, and row and column directionality feature score. Based on the region score value meeting a preset threshold, it is determined whether the image region contains text.

[0005] Optionally, the step of calculating the contrast score includes: Traverse all adjacent pixel pairs within the image region and calculate the absolute difference of each pixel pair in the R, G, and B components; The contrast score is obtained by summing the absolute differences of all adjacent pixel pairs.

[0006] Optionally, the step of calculating the color uniqueness ratio includes: Use a hash table to count the number of different color values ​​appearing within the image region; The color uniqueness ratio is calculated as the ratio of the number of different color values ​​to the total number of pixels in the image region.

[0007] Optionally, the step of calculating the row and column directional feature score includes: After converting the RGB image to a grayscale image, calculate the variance of the sum of grayscale values ​​in each row and the variance of the sum of grayscale values ​​in each column; The variance ratio is calculated as a first directional feature; The number of different values ​​for the total grayscale value of a row and the number of different values ​​for the total grayscale value of a column are counted, and the row-to-column ratio is calculated as a second directional feature. The first directional feature and the second directional feature are combined to obtain the row and column directional feature score.

[0008] Optionally, the step of comprehensively calculating the regional score includes: The region score is obtained by weighted summation or multiplication of the contrast score, color uniqueness ratio, and row and column directionality feature score.

[0009] Optionally, the step of determining whether the image region contains text includes: When the score of a region exceeds a single threshold, it is determined that the region contains text. Alternatively, when the number of regions in an image whose area scores exceed a threshold reaches a preset requirement, the entire image is determined to be a text graphic.

[0010] Optionally, the method is applied to a remote desktop protocol to identify text regions in a remote desktop image for image quality optimization.

[0011] Secondly, this application provides a text image recognition system, comprising: The data acquisition module is used to perform pixel-level analysis on the input image region; The first calculation module is used to calculate the contrast score of the image region, the contrast score being based on the sum of the absolute differences of all adjacent pixel pairs in the RGB components within the image region; The second calculation module is used to calculate the color uniqueness ratio of the image region, which is based on the number of different color values ​​in the image region as counted by a hash table. The third calculation module is used to convert the RGB image of the image region into a grayscale image and calculate the row and column directional feature score. The row and column directional feature score is based on the ratio of the variance of the sum of grayscale values ​​in each row to the variance of the sum of grayscale values ​​in each column, and the row-to-column ratio is set based on the number of different values ​​of the sum of grayscale values ​​in the rows and the number of different values ​​of the sum of grayscale values ​​in the columns. The data generation module is used to combine the contrast score, color uniqueness ratio and row and column directionality feature score to obtain the region score. The judgment module is used to determine whether the image region contains text based on the region score value meeting a preset threshold.

[0012] Thirdly, this application provides a computer device, the device comprising: a memory and a processor, wherein the processor, when executing computer instructions stored in the memory, performs the method described above.

[0013] Fourthly, this application provides a computer-readable storage medium including instructions that, when executed on a computer, cause the computer to perform the method described above.

[0014] In summary, this application achieves accurate recognition of text regions by performing pixel-level analysis on image regions and combining contrast scores, color uniqueness ratios, and row and column directional feature scores. This solves the problem in existing technologies that cannot effectively distinguish between text and non-text content, and has the advantages of accurately recognizing text content in image regions, effectively distinguishing between text and non-text regions, and improving text readability and user experience in remote desktop scenarios. Attached Figure Description

[0015] Figure 1 This is a schematic diagram of the computer device structure of the hardware operating environment involved in the embodiments of this application; Figure 2 This is a flowchart illustrating the first embodiment of the text image recognition method of this application; Figure 3 This is a structural block diagram of the first embodiment of the text and image recognition system of this application. Detailed Implementation

[0016] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0017] Reference Figure 1 , Figure 1 This is a schematic diagram of the computer device structure of the hardware operating environment involved in the embodiments of this application.

[0018] like Figure 1 As shown, the computer device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wireless-Fidelity (Wi-Fi) interface). The memory 1005 may be high-speed random access memory (RAM) or stable non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.

[0019] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0020] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a network communication module, a user interface module, and a text and image recognition program.

[0021] exist Figure 1 In the computer device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in this application can be set in the computer device, and the computer device calls the text image recognition program stored in the memory 1005 through the processor 1001 and executes the text image recognition method provided in the embodiment of this application.

[0022] This application provides a method for recognizing text images, referring to... Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the text image recognition method of this application.

[0023] In this embodiment, the text image recognition method includes the following steps: Step S10: Perform pixel-level analysis on the input image region.

[0024] Step S20: Calculate the contrast score of the image region, which is based on the sum of the absolute differences in the RGB components of all adjacent pixel pairs within the image region.

[0025] Step S30: Calculate the color uniqueness ratio of the image region, which is based on the number of different color values ​​in the image region as counted by a hash table.

[0026] Step S40: Convert the RGB image of the image region into a grayscale image, and calculate the row and column directional feature score. The row and column directional feature score is based on the ratio of the variance of the sum of grayscale values ​​in each row to the variance of the sum of grayscale values ​​in each column, and the row-to-column ratio is set based on the number of different values ​​of the sum of grayscale values ​​in the rows and the number of different values ​​of the sum of grayscale values ​​in the columns.

[0027] Step S50: Combine the contrast score, color uniqueness ratio, and row and column directionality feature score to obtain the region score.

[0028] Step S60: Based on the fact that the region score value meets the preset threshold, determine whether the image region contains text.

[0029] It should be noted that in remote desktop applications, existing protocols often reduce data volume by lowering image quality to ensure smooth transmission. However, this results in a significant decrease in the clarity of text content areas, with blurred character edges, broken strokes, or reduced contrast, severely impacting the user experience and efficiency in document editing, spreadsheet viewing, and other operations. Current technologies lack the ability to accurately locate text areas, making it difficult to efficiently distinguish between text and non-text content in dynamic image streams, and failing to achieve a coordinated balance between bandwidth optimization and text fidelity.

[0030] To address this, this embodiment proposes a method for recognizing text images, comprising: performing pixel-level analysis on an input image region; calculating a contrast score for the image region, the contrast score being based on the sum of the absolute differences in the RGB components of all adjacent pixel pairs within the image region; calculating a color uniqueness ratio for the image region, the color uniqueness ratio being based on the number of different color values ​​within the image region as counted by a hash table; converting the RGB image of the image region into a grayscale image, and calculating a row-column directional feature score, the row-column directional feature score being based on the ratio of the variance of the sum of grayscale values ​​in each row to the variance of the sum of grayscale values ​​in each column, and a row-column ratio set based on the number of different values ​​in the sum of grayscale values ​​in each row and column; combining the contrast score, color uniqueness ratio, and row-column directional feature score to obtain a region score; and determining whether the image region contains text based on the region score meeting a preset threshold.

[0031] For ease of understanding, the following explains some key terms in this embodiment: An image region refers to one or more sub-regions to be processed from the input image. These regions can be of a predefined fixed size or can be dynamically divided into arbitrary shapes based on the image content.

[0032] Pixel-level analysis refers to the numerical analysis of each pixel within an image region, either individually or in combination with neighboring pixels. This analysis can involve attributes such as pixel color, brightness, and position.

[0033] A contrast score is a numerical metric used to quantify the degree of difference in color or brightness within an image region. This score reflects the visual distinction between different elements within the image region.

[0034] The color uniqueness ratio is a numerical indicator used to measure the richness of color variety within an image region. This ratio reflects the complexity or uniformity of color distribution within the image region.

[0035] A hash table is a data structure used to store key-value pairs. In this embodiment, a hash table can be used to efficiently count the frequency or quantity of different color values ​​within an image region.

[0036] The row and column directional feature score is a numerical indicator used to evaluate the texture or structural regularity of an image region in the horizontal and vertical directions. This score reflects the potential directionality of text arrangement in the image region.

[0037] A grayscale image is an image in which the color information of each pixel is represented by only one brightness value. Typically, the pixel values ​​of a grayscale image range from 0 (black) to 255 (white).

[0038] The region score is a numerical value used to quantify the probability that an image region contains text, after considering multiple feature indicators. The higher the score, the greater the probability that the image region contains text.

[0039] A preset threshold is a reference value used to compare with a region score when determining whether an image region contains text. When a region score exceeds this threshold, the image region is generally considered to contain text.

[0040] In practical implementation, the text image recognition method of this embodiment can be performed according to the following steps: First, pixel-level analysis is performed on the input image region. This analysis may include a preliminary check of the color value, brightness value, or texture information of each pixel within the image region. For example, the RGB value of each pixel can be simply read, or the average brightness of each pixel can be calculated. Alternatively, the image region can be preprocessed, such as by noise removal or edge detection, to prepare for subsequent feature extraction.

[0041] Next, the contrast score of the image region is calculated. This contrast score is based on the sum of the absolute differences in the RGB components of all adjacent pixel pairs within the image region. For example, some adjacent pixel pairs within the image region can be randomly selected, their absolute differences in the RGB components can be calculated, and these differences can be summed. As another implementation, the sum of the absolute differences in the horizontal or vertical directions of adjacent pixel pairs within the image region can be calculated only.

[0042] Next, the color uniqueness ratio of the image region is calculated. This ratio is based on the number of distinct color values ​​within the image region, as counted by a hash table. For example, a list could be created to store all the distinct color values ​​encountered in the image region, and then the length of that list could be counted. Alternatively, the image region could be color quantized to reduce the number of colors before counting the distinct color values.

[0043] Subsequently, the RGB image of the image region is converted to a grayscale image, and the row and column directional feature scores are calculated. These scores are based on the ratio of the variance of the sum of grayscale values ​​in each row to the variance of the sum of grayscale values ​​in each column, and a row-to-column ratio set based on the number of distinct values ​​in the row and column sums. For example, the RGB image can be converted to grayscale first, and then the sum of grayscale values ​​in each row and column can be calculated separately. Next, the variance of these sums can be calculated, and the row variance can be simply compared with the column variance. Simultaneously, the number of distinct values ​​in the row and column sums can be counted, and their ratios can be calculated. Finally, these calculations are simply summed or averaged to obtain the row and column directional feature scores.

[0044] Then, the region score is obtained by combining the contrast score, color uniqueness ratio, and row / column directionality feature score. For example, a simple arithmetic mean of these three scores can be taken to obtain a comprehensive region score. As an alternative implementation, each score can be assigned a fixed weight based on experience, and then a weighted sum can be performed.

[0045] Finally, based on whether the region's score meets a preset threshold, it is determined whether the image region contains text. For example, a single fixed threshold can be set; when the region's score is higher than this threshold, it is determined that the region contains text. As another implementation method, the judgment threshold can be dynamically adjusted according to the size or position of the image region.

[0046] Using the method described above, this embodiment can accurately identify text regions in remote desktop images. This method effectively distinguishes between text and non-text content by comprehensively analyzing the contrast, color uniqueness, and row / column direction characteristics of image regions. Therefore, in remote desktop protocols, text regions can be transmitted with high fidelity, while non-text regions can be compressed using lossy compression. This ensures clear and readable text while optimizing bandwidth utilization, significantly improving the user experience and efficiency in remote work, education, and other scenarios.

[0047] In text image recognition methods, it is necessary to accurately calculate the contrast score of image regions to effectively distinguish between text and non-text regions. However, in practice, how to systematically and accurately quantify the contrast between adjacent pixels within an image region to ensure the stability and representativeness of the calculation results is a technical detail that needs to be clearly defined.

[0048] In response, this embodiment further proposes a specific method for calculating the contrast score, which includes traversing all adjacent pixel pairs within the image region, calculating the absolute difference of each pixel pair in the R, G, and B components, and summing the absolute differences of all adjacent pixel pairs to obtain the contrast score.

[0049] Specifically, in calculating the contrast score, it is first necessary to traverse all adjacent pixel pairs within the image region and calculate the absolute difference of each pixel pair in the R, G, and B components. This step aims to systematically capture local contrast information within the image region. In image processing, adjacent pixel pairs are the basic units that constitute image texture and edges. By traversing all adjacent pixel pairs within the image region, it is possible to ensure that all potential contrast variations within the region are comprehensively considered. For example, a line-by-line scanning method can be used, considering the pixels to the right and below each pixel as adjacent pixels to form horizontal and vertical pixel pairs. For each pixel pair, the absolute difference in the R, G, and B color components directly reflects the degree of difference in color or brightness between the two pixels, i.e., local contrast. For example, for pixel P1 (R1, G1, B1) and its adjacent pixel P2 (R2, G2, B2), the absolute difference in the R component is |R1-R2|, the absolute difference in the G component is |G1-G2|, and the absolute difference in the B component is |B1-B2|.

[0050] Subsequently, the absolute differences between all adjacent pixel pairs are summed to obtain the contrast score. This step aggregates the previously calculated local contrast information to form a single numerical value that represents the overall contrast level of the entire image region. By summing the absolute differences between all adjacent pixel pairs in the R, G, and B components, the drastic degree of color or brightness change within the image region can be quantified. Text regions typically have clear strokes and backgrounds, exhibiting high local contrast, thus their summation value will be relatively high. This summation operation provides a simple and effective way to comprehensively evaluate the contrast characteristics of an image region, providing crucial information for subsequent text identification.

[0051] The above technical solution clarifies the specific calculation process of the contrast score, which involves systematically traversing all adjacent pixel pairs within an image region and calculating the absolute difference in the R, G, and B components for each pair, then summing these differences. This method provides a precise and quantifiable way to evaluate the local contrast of an image region, ensuring that the contrast score stably and accurately reflects the texture and edge information of the image region. Text regions typically exhibit high contrast; this meticulous calculation effectively captures the significant differences between text strokes and the background, resulting in a contrast score with higher sensitivity and discriminative power for text regions. This significantly improves the accuracy and robustness of text image recognition methods in distinguishing between text and non-text regions.

[0052] To address this, this embodiment proposes a method for recognizing text images. After performing pixel-level analysis on the input image region, a contrast score is calculated for the image region. This contrast score is based on the sum of the absolute differences in the RGB components of all adjacent pixel pairs within the image region. Simultaneously, a color uniqueness ratio is calculated for the image region. This color uniqueness ratio is based on the number of different color values ​​within the image region as counted by a hash table. Furthermore, after converting the RGB image of the image region to a grayscale image, a row-column directional feature score is calculated. This row-column directional feature score is based on the ratio of the variance of the sum of grayscale values ​​in each row to the variance of the sum of grayscale values ​​in each column, and a row-column ratio set based on the number of different values ​​in the sum of grayscale values ​​in each row and column. Finally, by combining the contrast score, color uniqueness ratio, and row-column directional feature score, a region score is obtained. Based on whether the region score meets a preset threshold, it is determined whether the image region contains text. However, in the above methods, simply counting the number of different color values ​​within an image region based on a hash table may not be able to effectively quantify the uniqueness and distribution of color features. Especially when the image regions are of different sizes or there are many types of colors, directly using the number of colors as the basis for judgment may lead to misjudgment or omission of text regions, affecting the accuracy and robustness of recognition.

[0053] To this end, this embodiment further proposes a step for calculating the color uniqueness ratio, including: using a hash table to count the number of different color values ​​appearing in the image region; and calculating the color uniqueness ratio as the ratio of the number of different color values ​​to the total number of pixels in the image region.

[0054] Specifically, when using a hash table to count the number of distinct color values ​​appearing within an image region, this step aims to efficiently obtain information about the diversity of color types within the image region. A hash table is a data structure that stores data by mapping keys to values, offering fast lookup, insertion, and deletion capabilities. In this application, the color value of each pixel in the image region (e.g., an RGB triplet) can serve as the key in the hash table, while the corresponding value simply indicates whether the color has appeared before or records its frequency. By traversing all pixels in the image region and inserting the color value of each pixel into the hash table as the key, the count of distinct color values ​​in the hash table increases if the color value is appearing for the first time. This statistical method avoids redundant calculations and quickly obtains the total number of all unique color values ​​within the image region.

[0055] Based on this, the color uniqueness ratio is calculated as the ratio of the number of different color values ​​to the total number of pixels in the image region. This step aims to normalize the number of different color values ​​to generate a comparable color uniqueness index. The color uniqueness ratio is calculated by dividing the number of different color values ​​in the image region by the total number of pixels in that region. This ratio calculation eliminates the influence of image region size on the color diversity statistics. For example, even if a large region has many different color values, if its total number of pixels is also large, its color uniqueness ratio may be similar to that of a small region, making the comparison of color features between image regions of different sizes fairer and more effective. This ratio reflects the sparsity or richness of color distribution within the image region. Typically, text regions have relatively fewer and more concentrated color types, while background regions may have more diverse or complex color types.

[0056] By employing the aforementioned technical solution, when calculating the color uniqueness ratio of an image region, a hash table is first used to efficiently count the number of different color values ​​appearing within the image region. This avoids redundant calculations and ensures the accuracy and efficiency of color category statistics. Based on this, the ratio of the counted different color values ​​to the total number of pixels in the image region is calculated, resulting in a normalized color uniqueness ratio. This normalization process effectively eliminates the influence of image region size on color feature judgment, making the comparison of color diversity across image regions of different sizes more objective and accurate. For example, text regions typically have relatively uniform colors, resulting in a lower color uniqueness ratio; while complex non-text background regions may have richer colors, leading to a relatively higher color uniqueness ratio. Therefore, by introducing the color uniqueness ratio as an indicator, the color features of image regions can be more accurately quantified, significantly improving the accuracy and robustness of text image recognition methods in distinguishing between text and non-text regions. This effectively avoids misjudgments caused by differences in the absolute value of image region size or the number of color categories, providing a more reliable input for subsequent region score calculations.

[0057] In some of the embodiments described above, it is proposed to use the row and column directional feature scores of the image region to assist in determining whether the image region contains text. However, in practical applications, relying solely on a single or simple row and column directional feature may not be sufficient to capture the unique structured information of the text region, especially when the text layout is complex, the fonts are diverse, or there is a lot of background interference, which may lead to misjudgment or missed judgment, affecting the accuracy of text recognition.

[0058] To address this, this embodiment further proposes specific steps for calculating the row and column directional feature scores. First, the RGB image is converted to a grayscale image. This conversion is typically achieved by weighted averaging of the RGB components; for example, `Gray=0.299` can be used. R+0.587 G+0.114 The formula for B'. Converting an image to grayscale simplifies color information and highlights brightness variations, which is more effective for subsequent analysis of the stroke structure and directional features of text.

[0059] After obtaining the grayscale image, the variance of the sum of grayscale values ​​in each row and the variance of the sum of grayscale values ​​in each column are calculated. Specifically, each row of the grayscale image can be iterated over, and the grayscale values ​​of all pixels in that row can be summed to obtain the row's total grayscale value; similarly, each column can be iterated over, and the grayscale values ​​of all pixels in that column can be summed to obtain the column's total grayscale value. Subsequently, based on these row and column total grayscale value sums, their variances are calculated respectively. Variance reflects the degree of fluctuation of grayscale values ​​in the row or column direction; text areas typically have more significant grayscale changes in a certain direction.

[0060] Next, the variance ratio is calculated as the first directional feature. This variance ratio can be the ratio of the variance of the sum of row gray values ​​to the variance of the sum of column gray values, or its reciprocal, used to quantify the difference in gray-level variation in the horizontal and vertical directions of an image region. For example, for horizontally arranged text, the gray-level variation in the column direction may be more drastic, while the gray-level variation in the row direction may be relatively gradual; in this case, the variance ratio will exhibit a specific numerical range.

[0061] Simultaneously, the number of distinct values ​​for the total grayscale values ​​of rows and columns is counted, and the row-to-column ratio is calculated as a second directional feature. Specifically, a data structure such as a hash set can be used to store all calculated total grayscale values ​​of rows, and the number of elements in the set is counted, which represents the number of distinct values ​​for the total grayscale values ​​of rows. A similar operation is performed on the total grayscale values ​​of columns. The row-to-column ratio can be defined as the ratio of the number of different total grayscale values ​​of rows to the number of different total grayscale values ​​of columns, or it can be normalized in conjunction with the image size. This feature aims to capture the regularity and repetition of grayscale distribution in text regions, because the structured nature of text often results in fewer distinct values ​​for the total grayscale values ​​in a certain direction.

[0062] Finally, the first directional feature and the second directional feature are combined to obtain the row and column directional feature score. The combination can employ various methods such as weighted summation and multiplicative fusion. For example, the score = w1 First directional feature + w2 The second directional feature, where weights w1 and w2 can be optimized based on the specific application scenario and training data, allows for a more comprehensive and robust characterization of the row and column orientation of image regions.

[0063] By converting the RGB image to grayscale using the above technical solution, the variance of the sum of grayscale values ​​in each row and column is calculated, and the variance ratio is used as the first directional feature. This effectively captures the differences in grayscale variations of character strokes in the horizontal and vertical directions, reflecting the structured characteristics of the text. Simultaneously, by statistically analyzing the number of different values ​​for the sum of grayscale values ​​in rows and columns, and calculating the row-to-column ratio as the second directional feature, the regularity and repetition of the grayscale distribution in the text region are further quantified, thereby enhancing the ability to recognize the structural complexity of the text region. Combining these two complementary directional features provides a more comprehensive and robust characterization of the row and column directionality of the image region, effectively distinguishing between text and non-text regions, significantly improving the accuracy and anti-interference ability of text image recognition, and reducing the risk of misjudgment or missed judgment in complex backgrounds.

[0064] In some of the embodiments described above, a region score is obtained by combining the contrast score, color uniqueness ratio, and row / column directionality feature score. However, in practical applications, simply combining these feature values ​​may not fully reflect the differences in importance of each feature for text region recognition, thus affecting the accuracy of the region score and consequently the final text region judgment result.

[0065] In this regard, this embodiment further proposes a step for comprehensively calculating the region score value, which includes: weighted summation or multiplication fusion of the contrast score value, color uniqueness ratio and row and column directionality feature score value to obtain the region score value.

[0066] Specifically, weighted summation is a method that linearly combines multiple numerical features, the core of which lies in assigning a weight coefficient to each feature. These weight coefficients reflect the relative importance of each feature in the overall evaluation. For example, based on experience, statistical analysis, or machine learning models, the contribution of contrast score, color uniqueness ratio, and row / column direction feature score to text region recognition can be determined, and corresponding weights can be set accordingly. By multiplying each feature value by its corresponding weight and then summing all the products, the final region score can be obtained. This method allows the system to flexibly adjust the influence of different features, enabling features that contribute more to text region recognition to play a more dominant role.

[0067] On the other hand, multiplicative fusion is another way to combine multiple feature values. It obtains a comprehensive score by multiplying the individual feature values ​​(which may have been normalized or transformed). Unlike weighted summation, multiplicative fusion emphasizes the synergistic effect between features; that is, the final region score will only be significantly improved when all the features involved in the fusion exhibit high values. Conversely, if any one feature value is low, even if the other feature values ​​are high, the final region score will be lowered. This fusion method is particularly suitable for scenarios where all features must meet certain conditions to be identified as text regions, effectively filtering out non-text regions that perform poorly on a certain key feature.

[0068] By employing the aforementioned technical solutions, weighted summation or multiplicative fusion of contrast scores, color uniqueness ratios, and row / column direction feature scores allows for refined processing based on the varying contributions of each feature to text region recognition. The weighted summation method allows for highlighting features more critical to text recognition based on experience or learned weights, thereby improving the region score's ability to distinguish true text regions. The multiplicative fusion method effectively captures the synergistic effects between features; when all features exhibit high values, the region score significantly increases, while a poor performance of any single feature rapidly decreases the region score, helping to more accurately exclude interference from non-text regions. Therefore, this solution can more accurately assess the likelihood of an image region containing text, significantly improving the accuracy and robustness of text image recognition.

[0069] This embodiment proposes a method for recognizing text in images. It performs pixel-level analysis on the input image region, calculating contrast scores, color uniqueness ratios, and row / column directionality feature scores. These scores are then combined to obtain a region score, which is compared with a preset threshold to determine whether the image region contains text, providing a basic framework for text recognition. However, in practical applications, especially in scenarios requiring more refined judgment of the overall image content, relying solely on the score of a single region may have limitations, making it difficult to comprehensively and accurately reflect the text attributes of the image.

[0070] To address this, this embodiment further proposes a more flexible and comprehensive judgment strategy in the step of determining whether an image region contains text. Specifically, the judgment step includes: determining that the region contains text when the region score exceeds a single threshold; or, determining that the entire image is a text graphic when the number of region score values ​​exceeding the threshold in multiple regions of the image reaches a preset requirement.

[0071] Specifically, determining that a region contains text means that after calculating the region score, it is compared with a pre-set single threshold. If the region score is higher than or equal to the threshold, the image region is considered to have sufficient text features and is thus identified as containing text. This threshold can be set through experimentation, training, or experience, based on the needs of the actual application scenario, to achieve a balance between recognition accuracy and recall. For example, a fixed value can be set, or it can be adaptively adjusted according to the overall characteristics of the image.

[0072] Furthermore, when the number of regions in an image whose region scores exceed a threshold reaches a preset requirement, the entire image is determined to be a text-graphic image, providing a mechanism for evaluating the overall textual attributes of an image. This mechanism not only focuses on the recognition results of individual image regions but also statistically analyzes all regions in the image initially identified as containing text (i.e., whose region scores exceed a certain threshold). When the number of these qualifying text regions reaches or exceeds a preset requirement, such as reaching a certain percentage of the total number of image regions or an absolute number, the nature of the entire image can be inferred to be a text-graphic image. This method is particularly suitable for scenarios requiring the classification of the overall content of an image, such as determining whether a remote desktop screenshot primarily displays text content rather than graphics or video. The preset requirement can be a specific numerical value or a percentage, and its setting depends on the specific application requirements.

[0073] Through the above technical solution, when performing text recognition on image regions, it is possible not only to directly judge based on the score value of a single region, thereby quickly identifying local text regions, but also to further combine the recognition results of multiple regions in the image to comprehensively evaluate the text attributes of the entire image. This dual judgment mechanism makes the text recognition method more flexible and robust when processing complex images. For example, in remote desktop protocols, when it is necessary to determine whether the entire remote desktop image is mainly composed of text, by counting the number of text regions that meet the conditions, the overall text density of the image can be more accurately assessed, avoiding misjudgments caused by interference from a small number of non-text regions. This provides a more reliable basis for subsequent image quality optimization processing, ensuring the accuracy and comprehensiveness of text region recognition in remote desktop images.

[0074] In some of the embodiments described above, a method for recognizing text images was proposed, which can effectively identify whether an image region contains text. However, in practical applications, especially in specific scenarios such as remote desktop protocols, simply recognizing the text region may not be sufficient to meet the user's experience requirements. For example, how to combine the recognition results with subsequent image processing to improve the final display effect is a problem that needs further resolution.

[0075] In response, this embodiment further proposes applying the above method to a remote desktop protocol to identify text regions in remote desktop images for image quality optimization.

[0076] The Remote Desktop Protocol (RDP) is a technology that allows users to connect to a remote computer over a network and use its desktop environment. This protocol typically involves encoding the screen content of the remote computer, transmitting it to a local client, and then decoding and displaying it on the local client. Applying text-image recognition methods to the RDP means that the recognition process can occur during the data stream transmission of the remote desktop session or after the remote desktop client receives the image data. This allows the recognition results to be directly used to guide the data transmission strategy of the remote desktop protocol or the rendering strategy of the client, thereby enabling intelligent processing of remote desktop image content.

[0077] This technical feature aims to accurately locate and distinguish text-containing regions within image data transmitted or displayed via remote desktop protocols. Remote desktop images typically contain various content, such as text, graphics, and video. Text region recognition means that this method can accurately extract text portions from these mixed contents, providing a basis for subsequent differential processing. This recognition process can be performed on the remote desktop server side, for example, before image encoding; or it can be performed on the client side, for example, after image decoding.

[0078] The ultimate goal of identifying text regions is to perform targeted image quality optimization on these regions. Image quality optimization can include various technical means. For example, for identified text regions, lossless compression algorithms or higher encoding bit rates can be used to ensure text clarity and readability. On the client side, specific font rendering techniques can be applied to text regions to make their edges smoother and their display sharper. Furthermore, the color or contrast of the text regions can be adjusted based on their characteristics to make them stand out more against the background, improving visual comfort. Anti-aliasing of text regions can reduce pixelation. Remote desktop protocols can also dynamically adjust transmission strategies based on identified text regions, such as prioritizing the transmission of data in text regions or using more frequent updates for text regions, while using lossy compression or lower encoding quality for non-text regions to save bandwidth.

[0079] By applying the aforementioned text image recognition method to remote desktop protocols and utilizing the identified text regions for image quality optimization, the problem of poor text display quality in remote desktop environments can be effectively solved. Specifically, this solution enables the system to accurately distinguish between text and non-text content in remote desktop images, allowing for targeted high-quality encoding, rendering, or transmission strategies for text regions, such as lossless compression, high-precision font rendering, or priority transmission. This not only significantly improves the clarity and readability of text in remote desktops, optimizing the user's visual experience, but also ensures the display quality of critical information while more efficiently utilizing network bandwidth, thereby improving the efficiency of remote collaboration and office work.

[0080] The following example will provide a more detailed explanation of the above technical solution: In a remote desktop session, user A is connected to a remote server over a network and is editing a document containing a large amount of text on the remote desktop. Due to current network bandwidth fluctuations, the remote desktop protocol needs to optimize the transmitted image data to ensure smoothness while preventing the text content from becoming blurry due to compression.

[0081] When the remote desktop system receives a frame of image data, it first divides the image into multiple independent image regions, for example, dividing the entire screen into several 16x16 pixel blocks. For one of the image regions to be analyzed, the system initiates the text recognition process.

[0082] First, the system performs pixel-level analysis on the image region. Next, it calculates the contrast score for that region. Specifically, the system iterates through all adjacent pixel pairs within the region, calculating the absolute difference in the R, G, and B color components for each pair. For example, for a single pixel and its right-hand neighboring pixels, the system calculates the absolute differences in their R, G, and B values. These absolute differences for all adjacent pixel pairs are then summed to obtain the contrast score for the image region. Text regions typically have higher contrast, such as black text on a white background, resulting in a higher score.

[0083] Simultaneously, the system calculates the color uniqueness ratio of the image region. To achieve this, the system uses a hash table to count the number of different color values ​​appearing within the image region. For example, if a region mainly consists of black text and a white background, the number of different color values ​​recorded in the hash table will be very limited. Subsequently, the system calculates the ratio of the counted different color values ​​to the total number of pixels in the image region to obtain the color uniqueness ratio. Text regions typically have a relatively uniform color, contrasting sharply with the background color, thus their color uniqueness ratio will be relatively low.

[0084] Next, the system converts the RGB image of the image region into a grayscale image. Based on this grayscale image, the system calculates the row and column directional feature scores. The specific steps include: calculating the variance of the sum of grayscale values ​​in each row and the variance of the sum of grayscale values ​​in each column of the grayscale image, and using the ratio of these two variances as the first directional feature. For example, the sum of grayscale values ​​in a line of text will differ significantly between lines with text and lines without text, resulting in a larger variance. Simultaneously, the system counts the number of different values ​​for the sum of grayscale values ​​in each row and column, and sets a row-to-column ratio as the second directional feature based on these counts. For example, lines of text often have similar patterns of total grayscale values. Finally, the system combines the first and second directional features to obtain the row and column directional feature scores. Text content typically exhibits a regular horizontal or vertical arrangement, such as text lines or character strokes; these feature scores effectively reflect this structure.

[0085] After obtaining the contrast score, color uniqueness ratio, and row / column directionality feature score, the system performs a weighted sum or multiplication fusion of these scores to obtain a comprehensive region score for the image area. This fusion of multi-dimensional features can more comprehensively and accurately assess the likelihood of an image area containing text, avoiding the limitations of single-feature judgment. For example, a high-contrast area may just be a simple graphic, but after combining a low color uniqueness ratio and a high row / column directionality feature score, its confidence as a text area will be significantly improved.

[0086] Finally, the system compares the calculated region score with a preset threshold. If the region score exceeds the preset threshold, the system determines that the image region contains text. Furthermore, to improve the robustness of the determination, the system can be configured to only determine that the entire image is a text image when the number of regions in the image whose region scores exceed the threshold reaches a preset requirement.

[0087] Through the above process, the remote desktop protocol can accurately identify text regions in image frames. Unlike existing technologies that uniformly compress the entire image, leading to a decrease in text clarity, this method can differentiate the processing of identified text regions. For example, it can use higher-quality encoding or lossless compression for text regions, while employing a more aggressive lossy compression strategy for non-text regions. In this way, under limited bandwidth conditions, it ensures the overall smoothness of the remote desktop while significantly improving the readability of text content, solving the problem of blurry text in scenarios such as remote work and document viewing, thereby enhancing user experience and work efficiency.

[0088] The above description is merely an embodiment of this practice and is not intended to limit the scope of protection of this embodiment. For those skilled in the art, this embodiment can have various modifications and variations. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this embodiment should be included within the scope of protection of this embodiment.

[0089] Furthermore, embodiments of this application also propose a computer-readable storage medium storing a program for recognizing text images. When the program for recognizing text images is executed by a processor, it implements the steps of the text image recognition method described above.

[0090] Reference Figure 3 , Figure 3 This is a structural block diagram of the first embodiment of the text and image recognition system of this application.

[0091] like Figure 3 As shown, the text image recognition system proposed in this application includes: Data acquisition module 10 is used to perform pixel-level analysis on the input image region; The first calculation module 20 is used to calculate the contrast score of the image region, the contrast score being based on the sum of the absolute differences of all adjacent pixel pairs in the RGB components within the image region; The second calculation module 30 is used to calculate the color uniqueness ratio of the image region, wherein the color uniqueness ratio is based on the number of different color values ​​in the image region as counted by a hash table. The third calculation module 40 is used to convert the RGB image of the image region into a grayscale image and calculate the row and column directional feature score value. The row and column directional feature score value is based on the ratio of the variance of the sum of grayscale values ​​in each row to the variance of the sum of grayscale values ​​in each column, and the row-column ratio is set based on the number of different values ​​of the sum of grayscale values ​​in the rows and the number of different values ​​of the sum of grayscale values ​​in the columns. The data generation module 50 is used to combine the contrast score, color uniqueness ratio and row and column directional feature score to obtain the region score. The judgment module 60 is used to determine whether the image region contains text based on the region score value meeting a preset threshold.

[0092] It should be understood that the above are merely illustrative examples and do not constitute any limitation on the technical solution of this application. In specific applications, those skilled in the art can make settings as needed, and this application does not impose any restrictions on this.

[0093] This embodiment achieves accurate recognition of text regions by performing pixel-level analysis on image regions and combining contrast scores, color uniqueness ratios, and row and column directional feature scores. It solves the problem in existing technologies that cannot effectively distinguish between text and non-text content, and has the advantages of accurately recognizing text content in image regions, effectively distinguishing between text and non-text regions, and improving text readability and user experience in remote desktop scenarios.

[0094] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of this application. In practical applications, those skilled in the art can select some or all of it to achieve the purpose of this embodiment according to actual needs, and no restrictions are imposed here.

[0095] In addition, for technical details not described in detail in this embodiment, please refer to the text image recognition method provided in any embodiment of this application, which will not be repeated here.

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

[0097] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0098] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory (ROM) / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of this application. The above are only preferred embodiments of this application and do not limit the patent scope of this application. All equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.

Claims

1. A method for recognizing text images, characterized in that, include: Perform pixel-level analysis on the input image region; Calculate the contrast score of the image region, which is based on the sum of the absolute differences in the RGB components of all adjacent pixel pairs within the image region; Calculate the color uniqueness ratio of the image region, which is based on the number of different color values ​​in the image region as counted by a hash table; The RGB image of the image region is converted into a grayscale image, and the row and column directional feature score is calculated. The row and column directional feature score is based on the ratio of the variance of the sum of grayscale values ​​in each row to the variance of the sum of grayscale values ​​in each column, and the row-to-column ratio is set based on the number of different values ​​of the sum of grayscale values ​​in the rows and the number of different values ​​of the sum of grayscale values ​​in the columns. The region score is obtained by combining the contrast score, color uniqueness ratio, and row and column directionality feature score. Based on the region score value meeting a preset threshold, it is determined whether the image region contains text.

2. The method as described in claim 1, characterized in that, The step of calculating the contrast score includes: Traverse all adjacent pixel pairs within the image region and calculate the absolute difference of each pixel pair in the R, G, and B components; The contrast score is obtained by summing the absolute differences of all adjacent pixel pairs.

3. The method as described in claim 1, characterized in that, The steps for calculating the color uniqueness ratio include: Use a hash table to count the number of different color values ​​appearing within the image region; The color uniqueness ratio is calculated as the ratio of the number of different color values ​​to the total number of pixels in the image region.

4. The method as described in claim 1, characterized in that, The steps for calculating the row and column directional feature scores include: After converting the RGB image to a grayscale image, calculate the variance of the sum of grayscale values ​​in each row and the variance of the sum of grayscale values ​​in each column; The variance ratio is calculated as a first directional feature; The number of different values ​​for the total grayscale value of a row and the number of different values ​​for the total grayscale value of a column are counted, and the row-to-column ratio is calculated as a second directional feature. The first directional feature and the second directional feature are combined to obtain the row and column directional feature score.

5. The method as described in claim 1, characterized in that, The steps for calculating the comprehensive regional score include: The region score is obtained by weighted summation or multiplication of the contrast score, color uniqueness ratio, and row and column directionality feature score.

6. The method as described in claim 1, characterized in that, The step of determining whether the image region contains text includes: When the score of a region exceeds a single threshold, it is determined that the region contains text. Alternatively, when the number of regions in an image whose area scores exceed a threshold reaches a preset requirement, the entire image is determined to be a text graphic.

7. The method as described in claim 1, characterized in that, The method is applied to remote desktop protocols to identify text regions in remote desktop images for image quality optimization.

8. A text image recognition system, characterized in that, include: The data acquisition module is used to perform pixel-level analysis on the input image region; The first calculation module is used to calculate the contrast score of the image region, the contrast score being based on the sum of the absolute differences of all adjacent pixel pairs in the RGB components within the image region; The second calculation module is used to calculate the color uniqueness ratio of the image region, which is based on the number of different color values ​​in the image region as counted by a hash table. The third calculation module is used to convert the RGB image of the image region into a grayscale image and calculate the row and column directional feature score. The row and column directional feature score is based on the ratio of the variance of the sum of grayscale values ​​in each row to the variance of the sum of grayscale values ​​in each column, and the row-to-column ratio is set based on the number of different values ​​of the sum of grayscale values ​​in the rows and the number of different values ​​of the sum of grayscale values ​​in the columns. The data generation module is used to combine the contrast score, color uniqueness ratio and row and column directionality feature score to obtain the region score. The judgment module is used to determine whether the image region contains text based on the region score value meeting a preset threshold.

9. A computer device, characterized in that, The device includes a memory and a processor, wherein the processor, when executing computer instructions stored in the memory, performs the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, Includes instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1 to 7.