A method and system for superpixel segmentation of text images

Through multiple iterative superpixel segmentation methods, the problem of inaccurate superpixel area division of text images is solved, the accuracy and efficiency of text image processing are improved, and the accuracy of OCR recognition is enhanced.

CN120107291BActive Publication Date: 2025-07-25ZHONGZHI HOUDE (BEIJING) INFORMATION TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510585981.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-08
Publication Date
2025-07-25
Estimated Expiration
2045-05-08

AI Technical Summary

Technical Problem

In the prior art, when dealing with low-resolution scanned documents, handwritten text or complex background interference, the text image superpixel area division is inaccurate, resulting in a decrease in OCR recognition accuracy, and traditional methods are difficult to adapt to text images with poor page quality or complex background.

Method used

Multiple iterative superpixel segmentation method is used to obtain image data to perform initial superpixel segmentation, judge according to the color synchronization rate and perform re-segment, improving segmentation accuracy and efficiency.

Benefits of technology

It improves the accuracy and data processing efficiency of superpixel segmentation of text images, reduces the amount of data computing, and enhances the accuracy of subsequent OCR recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120107291B_ABST
    Figure CN120107291B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for superpixel segmentation of text images, including: acquiring a first image and reading first image data therefrom; performing superpixel segmentation on the first image according to the first image data to obtain a second image and second image data; and performing superpixel segmentation on the second image again according to the first image data and the second image data to obtain a third image. By performing superpixel segmentation again on some or all of the superpixels with unreasonable segmentation on the basis of superpixel segmentation, the present invention improves the accuracy of superpixel segmentation on the basis of saving data operation amount and improving data processing efficiency, thereby assisting in improving the recognition accuracy of text images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of image data processing and superpixel segmentation applications, and particularly relates to a method and system for superpixel segmentation of text images. Background Art

[0002] With the accelerated development of the digitalization process, text image processing technology plays an increasingly important role in fields such as document digitization, optical character recognition (OCR), and image content retrieval. Text images have unique characteristic attributes: containing a large number of high-contrast edge structures, repetitive character forms, and regular layout arrangements. And in practical applications, the actual situation of text pages varies widely. For example, there are often wrinkles, stains, etc. Directly applying traditional methods will cause the segmentation of text edges to become blurred. Especially when processing low-resolution scanned documents, handwritten texts, or complex background interferences (such as stains, noise, decorative patterns), problems such as superpixel regions crossing character boundaries and being unable to accurately divide character and non-character regions are likely to occur, seriously reducing the recognition accuracy of subsequent OCR engines and the extraction of effective font parts in the original text.

[0003] Existing technologies have tried to improve text segmentation effects through binarization preprocessing or edge detection, but these methods have two defects: First, global threshold processing is difficult to adapt to text images with poor document page quality or complex backgrounds, resulting in inaccurate region division; Second, edge detection based on traditional operators is sensitive to noise and is prone to generating pseudo-edge interferences in low-quality text images, affecting the division and recognition of effective regions.

[0004] With the popularization of applications such as mobile terminal document scanning, historical archive digitization, and paper document digitization, the industry's demand for high-precision and high-efficiency text image preprocessing technology is becoming increasingly urgent. Especially when dealing with complex scenarios such as mixed text / picture layout, poor page paper quality, stains, and complex backgrounds, traditional region segmentation methods have significant deficiencies in excluding background interferences and segmenting interference regions. Therefore, there is an urgent need for a superpixel segmentation method specifically designed for text image features to improve region segmentation efficiency while ensuring segmentation accuracy, providing a reliable technical basis for subsequent intelligent document processing. Summary of the Invention

[0005] In view of the above problems, the present invention provides a method and system for superpixel segmentation of text images to solve the above technical problems.

[0006] The present application provides the following technical solutions:

[0007] In a first aspect, the present invention provides a method for superpixel segmentation of text images, the method comprising:

[0008] Obtain a first image and read first image data therefrom;

[0009] The first image is the acquired text image; the first image data is the pixel feature data of the first image.

[0010] Specifically, the first image is the original image actually acquired or the non - original image after conventional processing; conventional processing refers to basic image processing such as denoising and stitching.

[0011] According to the first image data, perform super - pixel segmentation on the first image to obtain a second image and second image data.

[0012] The second image data is the segmentation result of the image obtained after super - pixel segmentation of the first image; the segmentation result includes multiple super - pixels and their pixel feature data.

[0013] The pixel feature data includes at least the color information of all pixel points and super - pixels in the image.

[0014] The super - pixel segmentation is to perform multiple iterative segmentations on the image according to the preset super - pixel clustering center points through a super - pixel segmentation algorithm until the iteration converges.

[0015] According to the first image data and the second image data, perform re - super - pixel segmentation on the second image to obtain a third image.

[0016] The re - super - pixel segmentation is to perform re - super - pixel segmentation on some or all of the super - pixels with unreasonable segmentation according to the segmentation result of the second image data.

[0017] Specifically, since the third image is obtained through re - super - pixel segmentation, it can reduce the difficulty of subsequent image recognition, improve the recognition accuracy, and speed up the recognition speed.

[0018] The present invention extracts the first image data including the color information of all pixel points from the original first image, then uses the principle of super - pixel segmentation to perform multiple iterative segmentations to obtain a second image, and then according to the segmentation result, performs re - super - pixel segmentation on some or all of the super - pixels with unreasonable segmentation to obtain a third image, providing more accurate and effective image data for subsequent use of the image. By performing re - super - pixel segmentation on some or all of the super - pixels with unreasonable segmentation on the basis of super - pixel segmentation, the present invention improves the accuracy of super - pixel segmentation, thereby improving the pre - processing accuracy of the image. At the same time, only performing re - super - pixel segmentation on the unreasonable super - pixels not only saves the data calculation amount but also improves the data processing efficiency.

[0019] Further, the color information is the color information in the RGB color mode.

[0020] Further, when performing superpixel segmentation on the first image, the method for determining the initial number of superpixels includes:

[0021] Obtain the total number of pixels N of the first image;

[0022] Set the initial distance between superpixel clustering center points to S pixels;

[0023] Calculate the initial number of superpixels K, , where K is an integer;

[0024] The initial number of superpixels is the total number of all superpixels formed after the first superpixel segmentation of the first image;

[0025] A superpixel is a small area composed of multiple adjacent pixels with similar features.

[0026] Further, after determining the initial number of superpixels, perform pre-segmentation on the first image. The specific method is as follows:

[0027] Segment the first image into K square superpixels with a side length of S; if there are rectangular superpixels with a side length less than S due to pixel size reasons, such rectangular superpixels are still treated as one superpixel.

[0028] Specifically, the pre-segmentation is the first image segmentation in the superpixel segmentation process. After multiple iterative segmentations, the superpixel regions will change continuously.

[0029] Further, according to the first image data and the second image data, performing re-superpixel segmentation on the second image to obtain a third image includes:

[0030] Obtain the distribution color information of each superpixel in the first image data;

[0031] Obtain the reference color information of each superpixel in the second image data;

[0032] Determine the color synchronization rate of each superpixel according to the reference color information and the distribution color information;

[0033] Judge whether each superpixel needs to be re-superpixel segmented according to the relationship between the color synchronization rate of each superpixel and the corresponding threshold;

[0034] After performing re-superpixel segmentation on each superpixel that needs to be re-superpixel segmented, obtain a third image;

[0035] The reference color information is the color information of the current clustering center of each superpixel in the second image data, and at least includes the red, green, and blue brightness values in the RGB color mode of the clustering center;

[0036] The distribution color information is the color information of all pixel points included in each superpixel in the first image data, and at least includes the red, green, and blue brightness values in the RGB color mode of the pixel points.

[0037] The color synchronization rate is the degree of deviation between the colors of all pixel points included in the superpixel and the color of the current clustering center.

[0038] Specifically, since in the image after superpixel segmentation, the colors of all pixel points in the superpixel will be uniformly marked as the color of the clustering center, therefore, the color synchronization rate can accurately quantify the consistency between the colors of all pixel points in the superpixel and the color of the clustering center, and the color synchronization rate reflects whether the color of the clustering center can represent the colors of all pixel points.

[0039] The present invention determines the color synchronization rate of each superpixel through the relationship between the reference color information and the distribution color information of each superpixel, and then determines whether each superpixel needs to be re-segmented according to the relationship between the color synchronization rate of each superpixel and the corresponding threshold. In this way, by quantifying the degree of deviation between the colors of all pixel points included in each superpixel and the color of the current clustering center, not only can the rationality of each superpixel be accurately judged, but also accurate data can be provided for subsequent re-superpixel segmentation.

[0040] Further, determining whether re-superpixel segmentation is required according to the relationship between the color synchronization rate of each superpixel and the corresponding threshold includes:

[0041] When the color synchronization rate of the superpixel is less than the preset color synchronization rate threshold, it is determined that the superpixel does not need to be re-segmented, and it is marked as the first superpixel;

[0042] When the color synchronization rate of the superpixel is greater than or equal to the preset color synchronization rate threshold, it is determined that the superpixel needs to be re-segmented; and it is marked as the second superpixel;

[0043] Further, the color synchronization rate is specifically as follows:

[0044] ;

[0045] is the color synchronization rate of the th superpixel;

[0046] is the total number of pixel points included in the

[0047] is the Among all the pixels included in a superpixel, the red brightness value of the

[0048] -th pixel in the RGB color mode; Among all the pixels included in a superpixel, the green brightness value of the

[0049] -th pixel in the RGB color mode; Among all the pixels included in a superpixel, the blue brightness value of the

[0050] -th pixel in the RGB color mode; The red brightness value of the clustering center of the

[0051] -th superpixel in the RGB color mode; The green brightness value of the clustering center of the

[0052] -th superpixel in the RGB color mode; The blue brightness value of the clustering center of the

[0053] Specifically, All are color information extracted from the first image data, representing the color information of the pixel points without superpixel segmentation; All are color information of the clustering centers of the superpixels extracted from the second image data, representing the color information of the clustering centers of the superpixels after superpixel segmentation.

[0054] The present invention divides each superpixel into a first superpixel and a second superpixel according to the relationship between the color synchronization rate and a preset color synchronization rate threshold, which can not only accurately identify the superpixels that need to be re-segmented by superpixel, but also reduce the data processing amount of subsequent re-segmentation by superpixel and improve the data processing efficiency of subsequent re-segmentation by superpixel.

[0055] Further, after performing re-segmentation by superpixel on each superpixel that needs to be re-segmented by superpixel, a third image is obtained, including:

[0056] Obtain the ratios of the first pixel point and the second pixel point in the second superpixel in their respective superpixels, as well as the first distances between each first pixel point and its clustering center and the first distances between each second pixel point and its clustering center, and determine the re-segmentation rate of the second superpixel;

[0057] Determine the specific number of segments when the second superpixel is to be re-segmented into superpixels according to the re-segmentation rate of the second superpixel;

[0058] Re-segment the second superpixel into superpixels according to the number of segments to obtain a third image;

[0059] The first distance is the color distance between a pixel point in a superpixel and its clustering center, indicating the degree of color difference between the pixel point in the superpixel and its clustering center;

[0060] The first pixel point is a pixel point in the superpixel whose first distance is less than or equal to the first deviation distance;

[0061] The second pixel point is a pixel point in the superpixel whose first distance is greater than the first deviation distance;

[0062] The first deviation distance is the maximum allowable value of the first distance between a pixel point in a superpixel and its clustering center.

[0063] Further, the method for determining the re-segmentation rate of the superpixel is as follows:

[0064] ;

[0065] Among them, is the re-segmentation rate of the th superpixel;

[0066] The re-segmentation rate is the degree to which a superpixel needs to be re-segmented into superpixels;

[0067] is the first deviation distance;

[0068] The first deviation distance is the maximum allowable value of the first distance between a pixel point in a superpixel and its clustering center;

[0069] The first distance is the color distance between a pixel point in a superpixel and its clustering center, indicating the degree of color difference between the pixel point in the superpixel and its clustering center;

[0070] Specifically, if the first distance is less than or equal to the first deviation distance, it indicates that the color difference degree between the pixel point in the superpixel and its clustering center is small;

[0071] If the first distance is greater than the first deviation distance, it indicates that the color difference between the pixel points in the superpixel and its clustering center is relatively large;

[0072] is the number of first pixel points in the th superpixel;

[0073] is the number of second pixel points in the th superpixel;

[0074] The first pixel point is the pixel point in the superpixel where the first distance is less than or equal to the first deviation distance;

[0075] The second pixel point is the pixel point in the superpixel where the first distance is greater than the first deviation distance;

[0076] is the first distance of the th first pixel point in the th superpixel, where ;

[0077] is the first distance of the th second pixel point in the th superpixel, where ;

[0078] The method for obtaining the first distance is as follows:

[0079] ;

[0080] Among them, is the first distance of the th pixel point in the th superpixel, where , .

[0081] Furthermore, the method for determining the specific number of segments during the re - superpixel segmentation is as follows:

[0082] If , then ;

[0083] If , then ;

[0084] Among them, is the specific number of segments for the second superpixel during the re - superpixel segmentation;

[0085] is the initial value of the preset number of segments for the re - superpixel segmentation, , and The operation result of taking the square root is an integer.

[0086] Specifically, if the re - segmentation rate of a super - pixel is greater than zero, it means that the super - pixel requires a relatively large number of segmentation times to meet the requirement of color synchronization rate.

[0087] If the re - segmentation rate of a super - pixel is less than or equal to zero, it means that the super - pixel requires a relatively small number of segmentation times to meet the requirement of color synchronization rate.

[0088] Specifically, for the re - super - pixel segmentation, theoretically, the super - pixels after one re - super - pixel segmentation can be subjected to a second re - super - pixel segmentation, or the re - super - pixel segmentation steps can be continuously repeated until all super - pixels meet the color synchronization rate. However, this will increase the data operation amount and reduce the data processing efficiency. Therefore, usually, performing one re - super - pixel segmentation step can achieve a relatively satisfactory accuracy and balance the processing effect and processing efficiency.

[0089] The present invention divides the specific number of segmentation times when performing re - super - pixel segmentation on the second super - pixel into two cases of requiring a relatively large number of segmentation times and a relatively small number of segmentation times according to the re - segmentation rate of each super - pixel, and accurately quantifies the specific number of segmentation times based on the initial value of the number of segmentation times of the preset re - super - pixel segmentation, providing accurate data for the re - super - pixel segmentation.

[0090] In a second aspect, the present application provides a text image super - pixel segmentation system, and the system includes:

[0091] An image data reading module, configured to obtain a first image and read first image data therefrom; the first image data is the pixel feature data of the first image; the pixel feature data at least includes the color information of all pixel points and super - pixels in the image.

[0092] A first - stage super - pixel segmentation module, configured to perform super - pixel segmentation on the first image according to the first image data to obtain a second image and second image data; the second image data is the segmentation result of the image obtained after the first image is subjected to super - pixel segmentation; the segmentation result includes a plurality of super - pixels and their pixel feature data; the super - pixel segmentation is to perform multiple iterative segmentations on the image according to a preset super - pixel clustering center point through a super - pixel segmentation algorithm until the iteration converges.

[0093] A re - super - pixel segmentation module, configured to perform re - super - pixel segmentation on the second image according to the first image data and the second image data to obtain a third image; the re - super - pixel segmentation is to perform re - super - pixel segmentation on some or all of the super - pixels with unreasonable segmentation according to the segmentation result of the second image data.

[0094] The system is used to execute the text image superpixel segmentation method described in the first aspect.

[0095] In a third aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the method described in the first aspect is implemented.

[0096] In a fourth aspect, the present application provides a computer device, including a memory and a processor; the memory is used to store a computer program; the processor is used to implement the method described in the first aspect when executing the computer program.

[0097] In summary, since the present invention can, on the basis of performing superpixel segmentation on the first image using the superpixel segmentation principle, add superpixel segmentation to some or all of the superpixels with unreasonable segmentation, and finally obtain the third image. Therefore, by performing superpixel segmentation on some or all of the superpixels with unreasonable segmentation on the basis of superpixel segmentation, the accuracy of superpixel segmentation is improved, and further the accuracy of image preprocessing is improved, providing a more accurate and effective data basis for the subsequent utilization of image data information. At the same time, only performing superpixel segmentation on the unreasonable superpixels not only saves the data calculation amount, but also improves the data processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0098] For ease of explanation, the present application is described in detail by the following specific embodiments and drawings.

[0099] Figure 1 It is one of the schematic diagrams of the method flow of this solution;

[0100] Figure 2 It is the second schematic diagram of the method flow of this solution;

[0101] Figure 3 It is the schematic diagram for comparing the text image segmentation effects of this solution, where a is the original stain image, b is the effect diagram of the first superpixel segmentation, and c is the effect diagram of the second superpixel segmentation;

[0102] Figure 4 It is the schematic diagram of the system structure of this solution;

[0103] Figure 5 It is the schematic diagram of the computer-readable storage medium of this solution;

[0104] Figure 6 It is the schematic diagram of the computer device of this solution. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0105] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0106] Embodiment 1

[0107] As Figure 1 shown, this embodiment provides a method for superpixel segmentation of text images, and the method includes:

[0108] Obtain a first image and read first image data therefrom;

[0109] The first image is the obtained text image; the first image data is the pixel feature data of the first image.

[0110] Specifically, the first image is an original image actually collected or a non-original image after conventional processing; conventional processing refers to basic image processing such as denoising and stitching.

[0111] For example: the first image is a low-quality text image or a text image with a complex background, stain pollution, etc.

[0112] Specifically, superpixel segmentation has obvious advantages in the image preprocessing and region analysis stages, especially in text detection, segmentation, and enhancement tasks in complex scenes. For example, when the recognition effect of traditional recognition methods is poor for low-quality text images or text images with stain pollution, superpixel segmentation can be used for preprocessing, and then text data recognition and extraction can be performed, which can achieve a better recognition effect. The specific reasons are as follows:

[0113] (1) For low-quality text images, such as old document scans with stains, fading, or local blurring, superpixel segmentation processing can suppress local noise (such as merging the stain area into one superpixel), while retaining the text edges. Subsequently, the superpixels can be binarized or enhanced to improve the OCR accuracy.

[0114] (2)Text images with complex backgrounds, such as scanned documents or natural scene images (e.g., billboards, product packaging), have complex backgrounds with textures, noises, or non-text interference elements (such as patterns, shadows). Traditional methods based on sliding windows or edge detection are inefficient. Direct binarization may result in the inability to extract text regions. If processed through superpixel segmentation, the background interference (such as stains) can be merged into a few large regions by superpixels, while the text regions form independent superpixels due to high contrast, facilitating subsequent filtering. For example, after color clustering of superpixels, regions with gray values close to the text (such as black) can be retained, effectively improving the accuracy and extraction efficiency of subsequent text recognition.

[0115] The above application scenarios all need to be based on the accuracy of pre - superpixel segmentation. The superpixel segmentation method for text images of the present invention divides the image into a first superpixel and a second superpixel, identifies the superpixels that need to be superpixel - segmented again, and then, according to the re - segmentation rate, assigns different segmentation numbers to the superpixels that need to be superpixel - segmented again. Therefore, it can further reduce the data operation volume and improve the data processing efficiency on the basis of improving the accuracy of superpixel segmentation.

[0116] Next, according to the first image data, perform superpixel segmentation on the first image to obtain a second image and second image data;

[0117] The second image data is the segmentation result of the image obtained after the first image is superpixel - segmented; the segmentation result includes multiple superpixels and their pixel feature data;

[0118] The pixel feature data at least includes the color information of all pixel points and superpixels in the image;

[0119] The superpixel segmentation is to perform multiple iterative segmentations on the image according to a preset superpixel clustering center point through a superpixel segmentation algorithm until the iteration converges;

[0120] According to the first image data and the second image data, perform re - superpixel segmentation on the second image to obtain a third image;

[0121] The re - superpixel segmentation is to perform re - superpixel segmentation on some or all of the superpixels with unreasonable segmentation according to the segmentation result of the second image data.

[0122] Specifically, since the third image is obtained through re-superpixel segmentation, it can reduce the difficulty for subsequent image recognition, improve the recognition accuracy, and speed up the recognition speed. For example, if the first image is a stained text image, the obtained third image can be subjected to region division and recognition through a trained neural network, and the obtained recognition result can provide accurate image data for subsequent application fields such as text recognition and text conversion.

[0123] The present invention extracts first image data including color information of all pixel points from the original first image, then uses the superpixel segmentation principle for multiple iterative segmentations to obtain a second image, and then, according to the segmentation result, performs re-superpixel segmentation on some or all of the superpixels with unreasonable segmentation to obtain a third image, providing more accurate and effective image data for subsequent use of the image. For example, if the first image is a low-quality text image or a text image with stain contamination / complex background, the obtained third image can provide more accurate and effective text image data for subsequent text recognition. By performing re-superpixel segmentation on some or all of the superpixels with unreasonable segmentation on the basis of superpixel segmentation, the present invention improves the accuracy of superpixel segmentation, thereby improving the preprocessing accuracy of the image. At the same time, only performing re-superpixel segmentation on the unreasonable superpixels not only saves the data operation amount but also improves the data processing efficiency.

[0124] Further, the color information is color information in the RGB color model.

[0125] Specifically, the RGB color model, also known as the trichromatic model or natural color model, mixes various colors by adjusting the brightness of the three colors of red, green, and blue. There are infinitely many different colors in nature, but the human eye can only distinguish a limited number of different colors. The RGB model can represent more than sixteen million different colors, which, in the view of the human eye, is very close to the colors of nature.

[0126] The RGB color model can be represented by a cube with a unit length. In this model, black is usually located at the origin of the three-dimensional rectangular coordinate system, red, green, and blue are respectively located on the three coordinate axes, and white is located at the corner farthest from the origin. The entire cube is placed in the first quadrant, covering most of the colors that the human eye can distinguish. In addition, cyan and red, magenta and green, and yellow and blue are complementary colors, and they are respectively located at opposite positions on the cube. In the RGB color model, any color can be represented by a point in three-dimensional space. The coordinates of this point are composed of the intensity values of the three components of red, green, and blue, usually represented by integers in the range of 0-255, where 0 represents the minimum intensity (no color) and 255 represents the maximum intensity (the most vivid color). By adjusting the intensity values of these three components, different colors can be obtained.

[0127] The RGB color model is a color standard in the industrial field. It obtains various colors through the changes of the three color channels of red (R), green (G), and blue (B) and their mutual superposition. RGB represents the colors of the three channels of red, green, and blue. This standard almost includes all the colors that the human vision can perceive and is one of the most widely used color systems at present.

[0128] The RGB color model adopted by the present invention is very close to the colors of nature and can provide nearly real color information for subsequent image data processing.

[0129] Further, when performing superpixel segmentation on the first image, the method for determining the initial number of superpixels includes:

[0130] Obtain the total number of pixels N of the first image;

[0131] Set the initial distance between the superpixel clustering center points to S pixels;

[0132] Calculate the initial number of superpixels K, , where K is an integer;

[0133] The initial number of superpixels is the total number of all superpixels formed after the first superpixel segmentation of the first image;

[0134] A superpixel is a small area composed of multiple adjacent pixels with similar features.

[0135] Specifically, the generation process of superpixels usually involves pixel clustering operations. In an image, pixels with similar features are grouped into one class to form a superpixel. Since the pixels within a superpixel have similar features such as color, brightness, and texture, a small number of superpixels can be used to represent the features of the image instead of a large number of pixels, which greatly reduces the complexity of image processing. At the same time, most of these small areas retain the effective information for further image segmentation and generally do not destroy the boundary information of the objects in the image.

[0136] The applications of superpixels are very extensive, including but not limited to computer vision tasks such as image segmentation, object tracking, object recognition, and pose estimation. In these tasks, superpixels can be used as a preprocessing step to provide a more concise and effective image representation for subsequent processing. In addition, superpixels can also be used in fields such as image compression and image denoising to improve the processing efficiency and effect.

[0137] Generally speaking, superpixels are an important image processing technology. It forms higher-level image representation units by clustering pixels with similar features. Each superpixel can be used as an independent processing unit, which provides convenience for subsequent image processing tasks.

[0138] Specifically, the superpixel segmentation algorithm, especially the SLIC (Simple Linear Iterative Clustering) superpixel segmentation algorithm, is a technique widely used in image processing. It simplifies the complexity of the image by dividing the image into superpixel blocks with similar colors and spatial positions. The following are the steps of the SLIC superpixel segmentation algorithm:

[0139] Step 1: Initialize the clustering centers

[0140] First, select the clustering centers: According to the set number of superpixels K, pre-segment the image into K superpixels of the same size, and evenly distribute K clustering centers on the image.

[0141] Second, optimize the positions of the clustering centers: Calculate the gradient values of all pixel points within the n×n neighborhood (usually n = 3) of each clustering center, and move the clustering center to the place with the minimum gradient. This is done to avoid the clustering centers falling on the image edges or noise points, which may affect the subsequent clustering effect.

[0142] Step 2: Assign pixels to the nearest clustering center

[0143] First, search the neighborhood: For each pixel in the image, search for the nearest clustering center within its 2S×2S neighborhood. This range is larger than the expected size S of the superpixel to ensure that each pixel can find a suitable clustering center.

[0144] Second, assign labels: Assign each pixel to the nearest clustering center based on color similarity and spatial proximity; this step is similar to the pixel assignment process in K-means clustering, but the search range of the SLIC algorithm is restricted to the local neighborhood, thus accelerating the convergence of the algorithm.

[0145] Step 3: Iteratively update the positions of the clustering centers

[0146] First, calculate the new clustering centers: For each superpixel, calculate the average or weighted average of the color and spatial information of all pixels inside it as the new position of the clustering center.

[0147] Second, iterative convergence: Repeat Step 2 and Step 3 until the change in the positions of the clustering centers is less than the preset threshold or the maximum number of iterations is reached. During the iteration process, the shapes and boundaries of the superpixels will gradually become clear and stable.

[0148] Through the above steps, the SLIC superpixel segmentation algorithm can divide the image into superpixel blocks with similar features, providing a powerful tool for subsequent image analysis and processing.

[0149] The superpixel segmentation method of this embodiment is based on the SLIC superpixel segmentation algorithm. By dividing the image into a first superpixel and a second superpixel, the superpixels that need to be superpixel segmented again are identified. Then, according to the re-segmentation rate, different segmentation numbers are assigned to the superpixels that need to be superpixel segmented again. This not only preserves the important details and boundary information of the image, but also achieves a good balance between processing speed and segmentation quality.

[0150] Similarly, if the text superpixel segmentation method of the present invention is adopted based on other existing superpixel segmentation algorithms (except SLIC), by dividing the image into a first superpixel and a second superpixel, the superpixels that need to be superpixel segmented again are identified. Then, according to the re-segmentation rate, different segmentation numbers are assigned to the superpixels that need to be superpixel segmented again. Similarly, the effect of both preserving the important details and boundary information of the image and achieving a good balance between processing speed and segmentation quality can be realized. In practice, according to the characteristics of different superpixel segmentation algorithms, based on a suitable superpixel segmentation algorithm, the text superpixel segmentation method of the present invention can be adopted to obtain better results.

[0151] Further, after determining the initial number of superpixels, the first image is pre-segmented. The specific method is as follows:

[0152] The first image is segmented into K square superpixels with side length S; if there are rectangular superpixels with side length less than S due to pixel size reasons, the rectangular superpixels are still treated as one superpixel.

[0153] Specifically, the pre-segmentation is the first image segmentation in the superpixel segmentation process. After multiple iterative segmentations, the superpixel regions will change continuously.

[0154] Further, as Figure 2 shown, the second image is superpixel segmented again according to the first image data and the second image data to obtain a third image, including:

[0155] Obtain the distribution color information of each superpixel in the first image data;

[0156] Obtain the reference color information of each superpixel in the second image data;

[0157] According to the reference color information and the distribution color information, determine the color synchronization rate of each superpixel;

[0158] According to the relationship between the color synchronization rate of each superpixel and the corresponding threshold, determine whether each superpixel needs to be superpixel segmented again;

[0159] After performing superpixel segmentation on each superpixel that needs to be superpixel segmented again, a third image is obtained;

[0160] The reference color information is the color information of the current clustering center of each superpixel in the second image data, and at least includes the red, green, and blue luminance values in the RGB color mode of the clustering center;

[0161] The distributed color information is the color information of all pixel points included in each superpixel in the first image data, and at least includes the red, green, and blue luminance values in the RGB color mode of the pixel points;

[0162] The color synchronization rate is the degree of deviation between the colors of all pixel points included in the superpixel and the color of the current clustering center;

[0163] Specifically, since in the image after superpixel segmentation, the colors of all pixel points in the superpixel will be uniformly marked as the color of the clustering center, therefore, the color synchronization rate can accurately quantify the consistency between the colors of all pixel points in the superpixel and the color of the clustering center, and the color synchronization rate reflects whether the color of the clustering center can represent the colors of all pixel points.

[0164] The present invention determines the color synchronization rate of each superpixel through the relationship between the reference color information and the distributed color information of each superpixel, and then judges whether each superpixel needs to be superpixel segmented again according to the relationship between the color synchronization rate of each superpixel and the corresponding threshold. In this way, by quantifying the degree of deviation between the colors of all pixel points included in each superpixel and the color of the current clustering center, not only can the rationality of each superpixel be accurately judged, but also accurate data can be provided for subsequent superpixel segmentation.

[0165] Further, judging whether superpixel segmentation needs to be performed again according to the relationship between the color synchronization rate of each superpixel and the corresponding threshold includes:

[0166] When the color synchronization rate of the superpixel is less than the preset color synchronization rate threshold, it is determined that the superpixel does not need to be superpixel segmented again, and it is marked as the first superpixel;

[0167] When the color synchronization rate of the superpixel is greater than or equal to the preset color synchronization rate threshold, it is determined that the superpixel needs to be superpixel segmented again; and it is marked as the second superpixel;

[0168] The color synchronization rate is specifically as follows:

[0169] ;

[0170] is the Color synchronization rate of a superpixel;

[0171] is the total number of pixel points included in the

[0172] is the red brightness value of the th pixel point among all the pixel points included in the

[0173] is the green brightness value of the th pixel point among all the pixel points included in the

[0174] is the blue brightness value of the th pixel point among all the pixel points included in the

[0175] is the red brightness value of the clustering center of the

[0176] is the green brightness value of the clustering center of the

[0177] is the blue brightness value of the clustering center of the

[0178] Specifically, are all color information extracted from the first image data, representing the color information of pixel points without superpixel segmentation; are all color information of the clustering centers of superpixels extracted from the second image data, representing the color information of the clustering centers of superpixels after superpixel segmentation.

[0179] According to the relationship between the color synchronization rate and a preset color synchronization rate threshold, the present invention divides each superpixel into a first superpixel and a second superpixel, which can not only accurately identify the superpixels that need to be re - superpixel segmented, but also reduce the data processing amount of subsequent re - superpixel segmentation and improve the data processing efficiency of subsequent re - superpixel segmentation.

[0180] Further, after performing superpixel segmentation on each superpixel that needs to be superpixel segmented again, obtaining a third image, includes:

[0181] Obtain the ratios of the first pixel point and the second pixel point in the second superpixel in their respective superpixels, as well as the first distances between each first pixel point and its clustering center and the first distances between each second pixel point and its clustering center, and determine the re-segmentation rate of the second superpixel;

[0182] According to the re-segmentation rate of the second superpixel, determine the specific number of segments when the second superpixel is superpixel segmented again;

[0183] Perform superpixel segmentation on the second superpixel according to the number of segments to obtain a third image;

[0184] The first distance is the color distance between the pixel point in the superpixel and its clustering center, indicating the degree of color difference between the pixel point in the superpixel and its clustering center;

[0185] The first pixel point is the pixel point in the superpixel whose first distance is less than or equal to the first deviation distance;

[0186] The second pixel point is the pixel point in the superpixel whose first distance is greater than the first deviation distance;

[0187] The first deviation distance is the maximum allowable value of the first distance between the pixel point in the superpixel and its clustering center.

[0188] Further, the method for determining the re-segmentation rate of the superpixel is as follows:

[0189] ;

[0190] Wherein, is the re-segmentation rate of the th superpixel;

[0191] The re-segmentation rate is the degree to which the superpixel needs to be superpixel segmented again;

[0192] is the first deviation distance;

[0193] The first deviation distance is the maximum allowable value of the first distance between the pixel point in the superpixel and its clustering center;

[0194] The first distance is the color distance between the pixel point in the superpixel and its clustering center, indicating the degree of color difference between the pixel point in the superpixel and its clustering center;

[0195] Specifically, if the first distance is less than or equal to the first deviation distance, it indicates that the color difference degree between the pixel points in the superpixel and its clustering center is small;

[0196] If the first distance is greater than the first deviation distance, it indicates that the color difference degree between the pixel points in the superpixel and its clustering center is large;

[0197] is the number of the first pixel points in the th superpixel;

[0198] is the number of the second pixel points in the th superpixel;

[0199] The first pixel point is the pixel point in the superpixel where the first distance is less than or equal to the first deviation distance;

[0200] The second pixel point is the pixel point in the superpixel where the first distance is greater than the first deviation distance;

[0201] is the first distance of the th first pixel point in the th superpixel, where ;

[0202] is the first distance of the th second pixel point in the th superpixel, where ;

[0203] The method for obtaining the first distance is as follows:

[0204] ;

[0205] Among them, is the first distance of the th pixel point in the th superpixel, where , .

[0206] The present invention determines the re-segmentation rate of a superpixel based on the ratios of the first pixel points and the second pixel points in their respective superpixels, as well as the first distances between each first pixel point and its clustering center and the first distances between each second pixel point and its clustering center. According to the re-segmentation rate of the superpixel, the specific number of segments for re-superpixel segmentation is further determined. The present invention accurately quantifies the number of segments required for each superpixel that needs to be re-superpixel segmented through the segmentation rate of the superpixel, and then provides a clear selection direction for determining the number of segments in the next step based on the quantified value of the segmentation rate of the superpixel. This not only improves the accuracy of the number of segments during re-superpixel segmentation but also speeds up the execution efficiency of re-superpixel segmentation.

[0207] Further, the method for determining the specific number of segments during re-superpixel segmentation is as follows:

[0208] If then ;

[0209] If then ;

[0210] Wherein, is the specific number of segments for the second superpixel to perform re-superpixel segmentation;

[0211] is the initial value of the number of segments for preset re-superpixel segmentation, and The result of taking the square root twice is an integer.

[0212] Specifically, if the re-segmentation rate of a superpixel is greater than zero, it means that the superpixel requires a larger number of segments to meet the requirement of color synchronization rate;

[0213] If the re-segmentation rate of a superpixel is less than or equal to zero, it means that the superpixel requires a smaller number of segments to meet the requirement of color synchronization rate.

[0214] Specifically, for the re-superpixel segmentation, theoretically, the superpixel after one re-superpixel segmentation can be subjected to a second re-superpixel segmentation, or the re-superpixel segmentation step can be continuously repeated until all superpixels meet the color synchronization rate. However, this will increase the data operation amount and reduce the data processing efficiency. Therefore, usually, performing one re-superpixel segmentation step can achieve a relatively satisfactory accuracy and balance the processing effect and processing efficiency.

[0215] According to the re - segmentation rate of each super - pixel, the specific number of segments when the second super - pixel is re - segmented into super - pixels is divided into two cases: a case where a larger number of segments is required and a case where a smaller number of segments is required. Based on the initial value of the number of segments for the preset re - super - pixel segmentation, the specific number of segments is accurately quantified, providing accurate data for the re - super - pixel segmentation.

[0216] Combined with Figure 3 As shown, in this embodiment, taking an old document image contaminated by a certain stain as an example, the original image is as shown in Figure 3 a in the figure. After extracting the basic data from the original image, the first super - pixel segmentation is performed, and the effect is as shown in Figure 3 b in the figure. It can be seen that since there are more doped pixels in some areas of the image, there will be a relatively large number of remaining noise pixel points after super - pixel segmentation in some areas, which will cause an unnecessary increase in the data volume in the subsequent image processing. On this basis, continuing to apply the re - super - pixel segmentation method of this solution, the effect after re - segmentation is as shown in Figure 3 c in the figure. Most of the noise pixel points have been removed, and the edges of the area are more regular and clear, which is more conducive to the effective area segmentation and extraction of the subsequent image data, as well as the recognition of text information, improving the efficiency of extracting the effective text area.

[0217] Embodiment 2

[0218] As Figure 4 shown, this embodiment provides a super - pixel segmentation system for text images. The system includes:

[0219] An image data reading module, configured to obtain a first image and read first image data therefrom; the first image data is the pixel feature data of the first image; the pixel feature data includes at least the color information of all pixel points and super - pixels in the image.

[0220] A first super - pixel segmentation module, configured to perform super - pixel segmentation on the first image according to the first image data to obtain a second image and second image data; the second image data is the segmentation result of the image obtained after the first image is super - pixel segmented; the segmentation result includes a plurality of super - pixels and their pixel feature data; the super - pixel segmentation is to perform multiple iterative segmentations on the image according to a preset super - pixel clustering center point through a super - pixel segmentation algorithm until the iteration converges.

[0221] A re - super - pixel segmentation module, configured to perform re - super - pixel segmentation on the second image according to the first image data and the second image data to obtain a third image; the re - super - pixel segmentation is to perform re - super - pixel segmentation on some or all of the super - pixels with unreasonable segmentation according to the segmentation result of the second image data.

[0222] The system is used to execute the text image superpixel segmentation method as described in Embodiment 1.

[0223] Embodiment 3

[0224] As Figure 5 As shown, this embodiment provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the method described in Embodiment 1 is implemented.

[0225] Embodiment 4

[0226] As Figure 6 As shown, this embodiment provides a computer device, including a memory and a processor; the memory is used to store a computer program; the processor is used to implement the method as described in Embodiment 1 when executing the computer program.

[0227] In summary, since the present invention can, on the basis of performing superpixel segmentation on the first image using the superpixel segmentation principle, add superpixel segmentation again to some or all of the superpixels with unreasonable segmentation, and finally obtain a third image, providing image data for subsequent text region division, text recognition, etc. Therefore, by performing superpixel segmentation again on some or all of the superpixels with unreasonable segmentation on the basis of superpixel segmentation, the accuracy of superpixel segmentation is improved, and thus the preprocessing accuracy of the image is improved. At the same time, only performing superpixel segmentation again on the unreasonable superpixels not only saves the data operation amount, but also improves the data processing efficiency.

[0228] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the above-described system, medium, device, module, and unit can refer to the corresponding processes in the foregoing method embodiments, and will not be elaborated herein.

[0229] In several embodiments provided by the present application, it should be understood that the disclosed system, device, and method can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division, and there can be other division methods in actual implementation. For example, multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces, and the indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.

[0230] The module or unit described as a separation component may or may not be physically separated. The component shown as a module or unit may or may not be a physical module or unit, that is, it may be located in one place, or it may be distributed to multiple network modules or units. Some or all of the modules or units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0231] In addition, each functional module or unit in various embodiments of the present application can be integrated in a processing module or unit, or each module or unit can exist physically alone, or two or more modules or units can be integrated in one module or unit. The above-mentioned integrated module or unit can be implemented in the form of hardware or in the form of a software functional unit.

[0232] If the integrated system, module, unit, etc. are implemented in the form of a software functional unit and sold or used as an independent product, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.

[0233] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the various embodiments of the present application.

Claims

1. A method for superpixel segmentation of text images, characterized in that, The method includes: Obtain a first image and read first image data therefrom; The first image is an acquired text image; the first image data is pixel feature data of the first image; Perform superpixel segmentation on the first image according to the first image data to obtain a second image and second image data; The second image data is the segmentation result of the image obtained after superpixel segmentation of the first image; the segmentation result includes a plurality of superpixels and their pixel feature data; The pixel feature data includes at least color information of all pixel points and superpixels in the image; Perform secondary superpixel segmentation on the second image according to the first image data and the second image data to obtain a third image, including: Obtain the distributed color information of each superpixel in the first image data; Obtain the reference color information of each superpixel in the second image data; Determine the color synchronization rate of each superpixel according to the reference color information and the distributed color information; Judge whether each superpixel needs to be subjected to secondary superpixel segmentation according to the relationship between the color synchronization rate of each superpixel and the corresponding threshold; Perform secondary superpixel segmentation on each superpixel that needs to be subjected to secondary superpixel segmentation to obtain a third image; The reference color information is the color information of the current clustering center of each superpixel in the second image data, and includes at least the red, green, and blue brightness values in the RGB color mode of the clustering center; The distributed color information is the color information of all pixel points included in each superpixel in the first image data, and includes at least the red, green, and blue brightness values in the RGB color mode of the pixel points; The color synchronization rate is the degree of deviation between the colors of all pixel points included in the superpixel and the color of the current clustering center; The secondary superpixel segmentation is to perform secondary superpixel segmentation on some or all of the superpixels with unreasonable segmentation according to the segmentation result of the second image data.

2. The text image superpixel segmentation method according to claim 1, characterized in that The color information is color information in the RGB color mode.

3. The text image superpixel segmentation method according to claim 1, characterized in that When performing superpixel segmentation on the first image, the method for determining the initial number of superpixels includes: Obtain the total number of pixels N of the first image; Set the initial distance between superpixel clustering center points to S pixels; Calculate the initial number of superpixels K, , where K is an integer; The initial number of superpixels is the total number of all superpixels formed after the first superpixel segmentation of the first image; The superpixel is a small area composed of a plurality of adjacent pixels with similar features.

4. The text image superpixel segmentation method according to claim 3, characterized in that After determining the initial number of superpixels, perform pre-segmentation on the first image. The specific method is: Segment the first image into K square superpixels with a side length of S; if there are rectangular superpixels with a side length less than S due to pixel size reasons, the rectangular superpixels are still processed as one superpixel.

5. The text image superpixel segmentation method according to claim 1, wherein Judging whether secondary superpixel segmentation is required according to the relationship between the color synchronization rate of each superpixel and the corresponding threshold includes: When the color synchronization rate of the superpixel is less than the preset color synchronization rate threshold, it is determined that the superpixel does not need to be subjected to secondary superpixel segmentation and is marked as the first superpixel; When the color synchronization rate of the superpixel is greater than or equal to the preset color synchronization rate threshold, it is determined that the superpixel needs to be superpixel-segmented again; and it is marked as the second superpixel; The color synchronization rate is specifically as follows: ; is the color synchronization rate of the th superpixel; is the total number of pixel points contained in the th superpixel; For the all pixels included in the th superpixel, the red brightness value of the th pixel in the RGB color mode; For the total number of all pixels included in the th superpixel, the green luminance value of the th pixel in the RGB color mode; For the all pixels included in the th superpixel, the blue luminance value of the th pixel in the RGB color mode; is the red brightness value of the clustering center of the th superpixel in the RGB color mode; is the green luminance value of the clustering center of the th superpixel in the RGB color mode; is the blue luminance value of the clustering center of the th superpixel in the RGB color mode.

6. The text image superpixel segmentation method according to claim 5, wherein, After superpixel-segmenting each of the superpixels that need to be superpixel-segmented again, a third image is obtained, including: Obtain the ratios of the first pixel points and the second pixel points in the second superpixel in their respective superpixels, as well as the first distances between each first pixel point and its clustering center and the first distances between each second pixel point and its clustering center, and determine the re-segmentation rate of the second superpixel; According to the re-segmentation rate of the second superpixel, determine the specific number of segments when the second superpixel is superpixel-segmented again; Superpixel-segment the second superpixel according to the number of segments to obtain a third image; The first distance is the color distance between the pixel point in the superpixel and its clustering center, indicating the degree of color difference between the pixel point in the superpixel and its clustering center; The first pixel point is the pixel point in the superpixel whose first distance is less than or equal to the first deviation distance; The second pixel point is the pixel point in the superpixel whose first distance is greater than the first deviation distance; The first deviation distance is the maximum allowable value of the first distance between the pixel point in the superpixel and its clustering center.

7. The text image superpixel segmentation method according to claim 6, wherein The method for determining the re-segmentation rate of the superpixel is as follows: ; Among them, is the re-segmentation rate of the th superpixel; The re-segmentation rate is the degree to which the superpixel needs to be superpixel-segmented again; is the first deviation distance; is the number of the first pixel points in the th superpixel; is the number of the second pixel points in the th superpixel; is the first distance of the th first pixel point in the th superpixel, where ; is the first distance of the -th second pixel point in the -th superpixel, where ; The method for obtaining the first distance is as follows: ; Among them, is the first distance of the -th pixel point in the -th superpixel, where , .

8. The text image superpixel segmentation method according to claim 6, characterized in that The method for determining the specific number of segments during the superpixel re-segmentation is as follows: If , then ; If , then ; Among them, is the specific segmentation quantity when performing re-superpixel segmentation on the second superpixel; is the initial value of the number of segments for the preset re-superpixel segmentation, , and the result of taking the square root is an integer.

9. A text image superpixel segmentation system, characterized in that The system includes: An image data reading module, configured to obtain a first image and read first image data therefrom; the first image is the obtained text image; the first image data is the pixel feature data of the first image; the pixel feature data at least includes the color information of all pixel points and superpixels in the image; A first superpixel segmentation module, configured to perform superpixel segmentation on the first image according to the first image data to obtain a second image and second image data; the second image data is the segmentation result of the image obtained after superpixel segmentation of the first image; the segmentation result includes multiple superpixels and their pixel feature data; the superpixel segmentation is to perform multiple iterative segmentations on the image according to the preset superpixel clustering center points through a superpixel segmentation algorithm until the iteration converges; The re - superpixel segmentation module is used to perform re - superpixel segmentation on the second image according to the first image data and the second image data to obtain a third image, and includes: obtaining the distribution color information of each superpixel in the first image data; obtaining the reference color information of each superpixel in the second image data; determining the color synchronization rate of each superpixel according to the reference color information and the distribution color information; judging whether each superpixel needs to be re - superpixel segmented according to the relationship between the color synchronization rate of each superpixel and the corresponding threshold; after performing re - superpixel segmentation on each superpixel that needs to be re - superpixel segmented, obtaining the third image; the reference color information is the color information of the current cluster center of each superpixel in the second image data, and at least includes the red, green, and blue luminance values in the RGB color mode of the cluster center; the distribution color information is the color information of all pixel points included in each superpixel in the first image data, and at least includes the red, green, and blue luminance values in the RGB color mode of the pixel points; the color synchronization rate is the degree of deviation between the colors of all pixel points included in the superpixel and the color of the current cluster center; the re - superpixel segmentation is to perform re - superpixel segmentation on some or all of the superpixels with unreasonable segmentation according to the segmentation result of the second image data.

Citation Information

Patent Citations

  • Image segmentation method and device

    CN117876387A