A handwriting erasing method based on sentence-level connected domain generation and region-aware description feature extraction
By using sentence-level connected component generation and region-aware descriptive feature extraction, the efficiency and accuracy issues of handwritten and printed text segmentation and erasure on edge devices are solved, achieving efficient and low-power document digitization processing, suitable for edge deployment of multilingual documents.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHENGDU UNIV
- Filing Date
- 2026-05-14
- Publication Date
- 2026-06-12
AI Technical Summary
Existing technologies struggle to achieve high-precision segmentation and efficient erasure of handwritten and printed text on resource-constrained edge devices, especially in scenarios with interwoven strokes and complex backgrounds. Existing methods cannot effectively capture the spatial statistical distribution differences between handwritten and printed text, making it difficult to balance segmentation accuracy and computational efficiency.
We employ a method of sentence-level connected component generation and region-aware descriptive feature extraction. By segmenting sentence-level connected components and extracting region-aware handwritten descriptor features, we construct a lightweight classification model. Using a random forest decision system, we explicitly model the spatial statistical distribution differences between handwritten and printed characters, thereby achieving accurate erasure of handwritten characters.
While maintaining high accuracy, it significantly reduces computational complexity and resource requirements, improves processing speed and efficiency on edge devices, effectively addresses perspective distortion and scanning noise, is suitable for multilingual document processing, and ensures the stability of printed text layout.
Smart Images

Figure CN122200698A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of text segmentation, and specifically relates to a method for erasing handwritten characters. Background Technology
[0002] Driven by the digital transformation of education, office work, and finance, the demand for the reuse and digitization of paper documents has exploded. Handwritten and Printed Text Segmentation (HPTS), a core component of the document recognition chain, directly determines the success or failure of downstream applications. Research shows that accurate separation of handwritten content can improve the accuracy of Optical Character Recognition (OCR) by more than 20%. Furthermore, high-quality segmentation results are the physical foundation for ensuring system security and privacy in signature verification and document retrieval. However, existing HPTS solutions often struggle to balance segmentation accuracy and computational efficiency in practical applications, especially on resource-constrained edge devices. In real-world applications, simply segmenting handwritten and printed text is insufficient to meet the needs of document cleanup and reuse. How to effectively remove handwritten text after accurately identifying it has become a pressing technical problem.
[0003] Early attempts at this technology were largely based on traditional machine learning approaches. Representative solutions included the Gray-Level Co-occurrence Matrix (GLCM) proposed by Haralick (1973), the Local Binary Pattern (LBP) proposed by Ojala (2002), and the Gabor filter by Daugman (1985). These methods extract global texture statistical features and then use SVM (Support Vector Machine) or random forest classifiers to perform discrimination. While they offer advantages such as lightweight design and fast feature extraction, the computational costs of statistical measures (such as the mean μ and variance) are significant. Most of these methods rely on "global statistics," severely neglecting the physical spatial location information of pixels. This makes it difficult for them to capture the subtle visual differences between handwritten and printed characters in real-world scenes with interwoven strokes and complex backgrounds, resulting in segmentation accuracy far below industrial-grade standards.
[0004] To overcome accuracy bottlenecks, deep learning approaches, exemplified by the Fully Convolutional Network (FCN) structure proposed by Long et al. in their 2015 conference paper "Fully Convolutional Networks for Semantic Segmentation" at the International Conference on Computer Vision and Pattern Recognition (CVPR), and the U-Net network structure proposed by Ronneberger et al. in their 2015 conference paper "U-Net: Convolutional Networks for Biomedical Image Segmentation" at the International Conference on Computational Medical Image and Computer-Assisted Intervention (MICCAI), have gradually become mainstream. These approaches model HPTS as a pixel-level semantic segmentation task, utilizing multi-layer convolutional neural networks to automatically learn high-dimensional features, significantly improving robustness against complex document backgrounds. However, the performance improvements of deep learning approaches come at the cost of enormous computational overhead; their parameter count often reaches millions or even tens of millions, resulting in computational complexity as high as... This strong reliance on high-performance computing resources such as GPUs makes the model face serious memory and power consumption challenges when deployed on mobile or embedded edge devices, greatly reducing its practicality.
[0005] Comprehensive analysis reveals that the current solutions are stuck in a stalemate between "high precision and low overhead" because they fail to fully utilize the physical characteristics of document imaging. A deeper analysis from the perspectives of imaging structure and writing mechanism reveals that printed text, formed by mechanical plate making or laser toner fixing, exhibits highly regular stroke thickness, grayscale distribution, and structural repeatability. In contrast, handwritten text, formed by human handwriting, is constrained by pen pressure variations, ink diffusion, and paper fiber absorption, resulting in a significantly non-uniform spatial intensity distribution. Therefore, the fundamental difference between the two is not merely a difference in geometric contours, but rather a difference in the stability of spatial statistical distribution. This mechanistic discovery provides crucial theoretical guidance for constructing a lightweight segmentation scheme that combines high effectiveness and high efficiency.
[0006] The main drawback of existing technical solutions lies in their failure to establish a feature representation system that matches the physical imaging mechanism. First, there is a serious logical mismatch in the definition of the discriminative unit. Existing pixel-level or page-level modeling often ignores the structural hierarchy of document content, leading to a disconnect between local details and macroscopic semantics; while simple character-level modeling, due to its limited receptive field, cannot reflect the regular differences in connectivity and stroke distribution of the sentence as a whole. In fact, the sentence level is the smallest stable statistical unit capable of carrying the randomness of handwritten characters and the regularity of printed characters. The neglect of this level by existing methods directly weakens the discriminative power of features.
[0007] Secondly, existing solutions generally lack explicit modeling of spatial distribution structures. Traditional texture statistical methods (such as GLCM or LBP) essentially still rely on calculating the global mean and variance. This "pooling" of statistics obliterates the spatial arrangement features of pixels. In real imaging mechanisms, the ink pressure and diffusion randomness of handwritten text cause drastic fluctuations in spatial statistics, while printed text exhibits extremely high spatial stability. Due to the lack of "spatial partitioning modeling," existing technologies cannot effectively characterize this difference in stability, resulting in classification criteria remaining at a superficial level of visual morphology.
[0008] Furthermore, there is an irreconcilable contradiction between the computational redundancy introduced by deep learning architectures and the deployment requirements at the edge. Although CNN-based semantic segmentation models perform excellently on experimental datasets, their layer-by-layer convolutional operation results in computationally high complexity. In embedded devices with limited computing resources, such as the RK3576, this high computing power requirement directly translates into high latency, high power consumption, and huge memory footprint, making it difficult to achieve real-time response for edge document processing. Ultimately, existing technologies have failed to explore the structural differences in spatial distribution at the level of the physical mechanisms of scanning imaging, resulting in a loss of engineering feasibility while pursuing accuracy. Summary of the Invention
[0009] To address the aforementioned technical issues, this invention proposes a handwritten character erasure method based on sentence-level connected component generation and region-aware descriptive feature extraction. From a feature engineering perspective, it proposes a logical system with "sentence-level" as the smallest discriminative unit, and explicitly models the spatial statistical distribution differences of text through region-aware handwritten feature extraction.
[0010] The technical solution adopted in this invention is: a handwritten character erasure method based on sentence-level connected component generation and region-aware descriptive feature extraction, comprising:
[0011] S1. Perform sentence-level connected component segmentation on the image to obtain sentence-level minimum discriminant units;
[0012] S2. Region-aware handwritten descriptor feature extraction based on sentence-level minimum discriminant units, wherein the sentence-level minimum discriminant unit is formed by the aggregation of multiple character-level connected components and corresponds to the connected domain range in the original image;
[0013] S3. Construct a classification model;
[0014] S4. Construct a training dataset based on the region-aware handwritten descriptor features extracted from the known image in steps S1 and S2, and then train the classification model constructed in step S3 based on the training dataset.
[0015] S5. Input the region-aware handwritten descriptor features of the image to be classified extracted in steps S1 and S2 into the classification model trained in step S4 to obtain the classification result.
[0016] S6. Based on the classification results of each sentence-level minimum discriminant unit obtained in step S5, the sentence-level minimum discriminant unit classified as handwritten is mapped to the original image coordinate system, and a corresponding pixel-level binary mask is constructed based on its connected component range. The mask value of 1 indicates that all pixels within the connected component range covered by the entire sentence-level minimum discriminant unit that is judged as handwritten text are included, and the mask value of 0 indicates that other pixels are excluded from the connected component range corresponding to the handwritten text.
[0017] Binary masks are used to constrain and filter the original image. For sentence-level minimum discriminant units that are identified as handwritten text, if there is no interweaving of strokes or boundary adhesion between handwritten and printed text in the corresponding region, the pixels within the connected component range corresponding to the sentence-level minimum discriminant unit are removed as a whole. If there is interweaving of strokes or boundary adhesion, within the connected component range corresponding to the sentence-level minimum discriminant unit, only the pixels corresponding to the mask value of 1 are removed, while the spatial adjacency relationship and connectivity structure of the printed text determined by the sentence-level connected component segmentation are preserved, thereby realizing the erasure of handwritten text.
[0018] The beneficial effects of this invention are as follows: First, this invention overcomes the limitation of traditional methods that easily lead to oversegmentation when processing complex structures (such as Chinese character radicals and broken strokes) at the character level. By introducing a minimal discriminant unit (SCC) system with sentence-level connected components as the core, and utilizing a disjoint-set data structure and adaptive threshold aggregation mechanism, it achieves accurate transformation of physically discrete components into semantically consistent units, thereby improving the structural robustness of complex text from the underlying logic. Second, this invention explicitly models the physical differences between the inherent variability of handwritten text and the mechanical uniformity of printed text through region-aware handwritten descriptors. Compared to traditional GLCM or LBP operators, this scheme utilizes three concentric ring partitioning strategies—linear, quadratic law, and logarithmic polar coordinates—combined with the sum of mean and squared deviations (SSD) statistics of multiple color channels, which can capture the nonlinear characteristics of the spatial distribution of handwritten strokes and color penetration gradients, achieving a quasi-deep learning level in feature representation depth. Third, this invention achieves a qualitative leap in computational efficiency and resource consumption. The core framework abandons the heavyweight Fully Convolutional Network (FCN) and instead adopts a lightweight random forest decision system. Experiments show that on the MAD-HPTS dataset, this scheme maintains a high accuracy of 96.9% while improving inference speed by more than 8 times compared to traditional deep learning models, significantly reducing the algorithm's dependence on high-performance hardware. Finally, this invention has strong environmental adaptability and multilingual universality. In edge-side embedded device deployment tests such as RK3576, the runtime is reduced by approximately 45% compared to traditional schemes. By training on a multilingual dataset containing 100,000 samples, this scheme not only effectively addresses perspective distortion and scanning noise but also provides a high-performance, low-power standardized solution for cross-language document digitization in resource-constrained environments. Furthermore, after obtaining the classification results of handwritten and printed text, this invention constrains the original image using a region mask generated by sentence-level connected components, removing only the regions identified as handwritten text. Compared to existing erasure methods based on pixel-level or coarse-grained segmentation, this invention can effectively avoid accidental deletion of printed text in scenarios with interwoven strokes and complex backgrounds, while reducing handwriting residue, improving erasure integrity, and maintaining the stability of the original document's layout structure. Attached Figure Description
[0019] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation
[0020] To facilitate understanding of the technical content of this invention by those skilled in the art, the following technical terms will be explained first:
[0021] SCC (Sentence-level Connected Component): Sentence-level connected component refers to a semantically coherent sentence-level text region segmented from a document image, which serves as the smallest discriminative unit in this method.
[0022] RHD (Region-aware Handwriting Descriptor): This refers to dividing the sentence-level connected domain (SCC) into concentric ring regions, extracting statistical features (including mean, sum of squared deviations (SSD), area, and aspect ratio) from each sub-region, and then concatenating these features to construct a feature vector. This feature extraction corresponds to the RHD module and is the core feature representation method for distinguishing handwritten and printed text.
[0023] CCC (Character Connected Component): A character-level connected component refers to a set of connected pixels of a single character or character component in a binary image, formed according to neighborhood connectivity rules.
[0024] SCCS (Sentence-level Connected Component Segmentation): The sentence-level connected component segmentation algorithm refers to the complete process of starting from the character-level connected component (CCC), going through neighborhood identification, character aggregation, and overlapping sentence segmentation, and finally obtaining the sentence-level connected component, which is the sentence-level minimum discriminant unit (SCC) in this embodiment.
[0025] SSD (Sum of Squared Differences): The sum of squared deviations refers to the cumulative squared difference between each pixel value in a region and the mean value of that region. It is used to characterize the uniformity and variability of pixel values within a region.
[0026] The following is in conjunction with the appendix Figure 1 The content of this invention will be further explained.
[0027] Figure 1 The process is illustrated from sentence-level connected component generation, region-aware feature extraction, classification decision-making, and handwritten character erasure based on the classification results. In the handwritten character erasure process, selective removal of handwritten regions preserves the structure of printed text even when handwritten strokes are intertwined or adhered to printed text, thereby improving erasure accuracy and maintaining the stability of the document layout structure.
[0028] This invention discloses a lightweight segmentation framework for handwritten and printed text that balances accuracy and efficiency. Addressing the challenge of resource-constrained edge devices being unable to run heavy-duty deep learning models, this solution, from a feature engineering perspective, proposes a logical system using the "sentence-level" as the smallest discriminative unit. Specifically, it uses sentence-level connected components (SCCs) as the smallest analysis and decision-making object, and explicitly models the spatial statistical distribution differences of the text using region-aware handwriting descriptors (RHDs). Figure 1 As shown, the core process of this invention is strictly divided into three stages: a sentence-level connected component generation method based on SCCS (Sentence-level Connected Component Segmentation), and region-aware handwriting feature extraction and classification decision based on RHD (Region-aware Handwriting Descriptor).
[0029] Step 1: Sentence-level Connectivity Segmentation (SCCS) phase;
[0030] The system first addresses the oversegmentation problem of traditional methods when processing complex characters such as Chinese characters by raising the level of the discrimination unit.
[0031] 1. Character Localization: The system preprocesses the original image, including smoothing filtering to remove high-frequency noise, followed by binarization using the Otsu adaptive thresholding method, and morphological erosion and dilation operations to connect broken strokes. Connected components (CCs) are extracted from the image based on connected component analysis, and initial character-level connected components are constructed using the Union-Find algorithm. The initial character-level connected components are then precisely processed using three quantification indicators: area (≥10 pixels), spatial density (component area / boundary box area ≥ 0.02), and aspect ratio (range [1 / 35, 35]) to remove scanning noise and non-textual interference. Connected components meeting these criteria are retained as the final character-level connected components (CCCs). Those skilled in the art should understand that connected component analysis constructs a connected structure based on the spatial adjacency of pixels and the consistency of grayscale values; this connected structure refers to the connected components in this embodiment.
[0032] Furthermore, to address the issue of the dot of the English letter "i" and components of Chinese characters being physically split into multiple independent connected components (CCs), the system searches for connected components (CCs) within a distance of 2 pixels and merges them.
[0033] 2. Sentence Construction:
[0034] The system defines the same set of candidate lines of text. Where N(ch) represents the candidate set of the same text line neighborhood of the current character-level connected component ch; ch is the current character-level connected component (CCC) to be processed. Let C be the candidate neighborhood character-level connected components (CCC); C is the complete set of all character-level connected components in the image; C\{ch} is the set of remaining character-level connected components after excluding the current character-level connected component ch; and These are components ch and The ordinate of the center of the circumscribed rectangle; This is a vertical tolerance threshold used to determine whether two components belong to the same text line. The vertical tolerance threshold... (i.e., the vertical axis offset threshold) is calculated by the following formula:
[0035]
[0036] in, and These are components ch and The height of the circumscribed rectangle; The minimum height of the two components is used to match the tolerance threshold with the scale of the smaller component; the denominator 3 is an empirical scaling factor, and 1 / 3 of the minimum height is taken as the allowable vertical offset to ensure the clustering accuracy of components in the same text line.
[0037] For each initial set of line-level components, the horizontal distance distribution between adjacent components is statistically analyzed. The horizontal distance with the highest frequency between adjacent components is used as an adaptive spacing threshold. Based on this adaptive spacing threshold, character-level connected components within the same text line are horizontally clustered. Components with a spacing smaller than the adaptive spacing threshold are aggregated into sentence-level regions, thus achieving the aggregation from characters to sentences. Specifically, the candidate set of components within the same text line is used to determine the line affiliation (vertical clustering), while the adaptive horizontal threshold is used to further determine the sentence affiliation (horizontal clustering). Together, they complete the full construction from character-level connected components to sentence-level regions.
[0038] For scenarios where bounding boxes overlap but there is no pixel adhesion, a breadth-first search (BFS) is used to find the shortest background path in the background region between components. For scenarios where pixels are truly adhered, a vertical stroke histogram projection is used to cut at local minima, ultimately generating a sentence-level minimum discriminant unit (SCC). The specific triggering logic is as follows: if the bounding boxes of two candidate components overlap but their pixels do not intersect, it is determined to be a layout overlap, triggering a lossless separation by finding the shortest path to the background pixels using BFS; if the two components are pixel-level adhered, it is determined to be physically adhered, triggering segmentation using local minima from the vertical projection; if the two components have neither overlapping bounding boxes nor pixel-level adherence, they are normal independent components, and no segmentation operation is performed, directly retaining them as complete character-level connected components. All segmented sub-components and directly retained independent components undergo character aggregation based on the same text line determination rule and an adaptive horizontal distance threshold, ultimately generating a sentence-level minimum discriminant unit (SCC).
[0039] Step 2: Region-Aware Handwritten Descriptor (RHD) Feature Extraction Stage;
[0040] The system utilizes the physical difference between the inherent variability of handwritten characters and the structural uniformity of printed characters to perform feature modeling, explicitly capturing spatial variability.
[0041] 1. Region Division: Define n+1 strictly increasing radial threshold sequences. Where W and H are the width and height of the sentence-level smallest discriminant unit (SCC) region, respectively. The maximum radius, that is It is the Euclidean distance from the geometric center point cp to the farthest pixel. ; This represents the i-th "radius threshold". This sequence divides the image into n concentric regions. The pixel set of each region is ,in This represents the i-th annular region; Let p be the Euclidean distance from the center cp. This design aims to preserve coarse location information from the center and utilize horizontal and vertical symmetry to ensure that the statistics reflect the overall distribution of the content. The system provides the following three selectable partitioning strategies:
[0042] 1) Linear Partitioning: This method performs equidistant sampling of the stroke distribution, dividing the image into n concentric rings of equal width, resulting in the lowest computational cost. In the ablation experiments, by adjusting the number of partitions, n=10 was ultimately selected as the optimal configuration, achieving an accuracy of 96.9% on the MAD-HPTS dataset. In the partitioning strategy comparison experiment (n=3), linear partitioning also achieved the highest accuracy of 96.1%.
[0043] 2) Square-law Partitioning: Radial thresholds are generated using an inverse quadratic series, making the thresholds closer to the center denser (fine-grained sampling) and the thresholds closer to the boundary sparser, emphasizing details in the central region and better capturing central stroke and gradient information.
[0044] 3) Log-polar partitioning: Used to enhance the capture of microscopic color penetration gradients in the central area.
[0045] 2. Feature Calculation and Assembly: For each annular region Based on the RGB three color channels, the following statistical features are extracted:
[0046] Mean: Reflects the overall brightness of a region, defined as: Where R is the annular region, The total number of pixels within the annular region R. Let p be the pixel value in the c-th color channel. .
[0047] Sum of squared deviations ( ): Characterizes the homogeneity and variability within a region, defined as: Due to uneven pressure, handwritten text has a significantly higher SSD than industrial-grade printed text.
[0048] Area: The size of the measurement area, defined as: .
[0049] Aspect ratio: describes the geometry of a region, defined as follows: , where w R h R These represent the width and height of region R, respectively.
[0050] Finally, by concatenating the four types of features of each region and color channel mentioned above, a region-aware handwritten descriptor feature vector is constructed. : ,in This indicates feature stitching of all concentric annular regions R; This indicates that feature stitching is performed on all color channels c.
[0051] Step 3: Classification and Decision-Making Stage;
[0052] The system utilizes extracted high-dimensional feature vectors for attribute mapping, significantly reducing computational overhead while maintaining near-deep learning-level accuracy. The classification results are then mapped to corresponding sentence-level minimum discriminant units (MDUs), generating region labels for handwritten and printed text. A region mask is then constructed for handwritten character erasure. This region mask is a pixel-level binary mask built based on the spatial location of the sentence-level MDU in the original image and its connected component range. Pixels within the connected component range covered by the entire sentence-level MDU identified as handwritten text are labeled as mask 1, and pixels in other regions are labeled as mask 0. In practical applications, handwritten and printed text often exhibit interwoven strokes, partial overlap, or boundary adhesion. Existing pixel-level mask-based erasure methods typically directly delete the corresponding regions, easily leading to accidental deletion of printed text or handwritten residue. Based on the sentence-level minimum discriminant unit division and region-aware feature modeling of the present invention, the handwritten region can be located more accurately in the above complex scenarios. Only within the connected domain corresponding to the sentence-level minimum discriminant unit, only the pixels corresponding to the mask value of 1 are removed. At the same time, the structural continuity of the printed text is maintained based on the structural constraints of the sentence-level connected domain, thereby improving the erasure accuracy and maintaining the stability of the document layout structure.
[0053] The phrase "maintaining the structural continuity of printed text based on the structural constraints of sentence-level connected components" should be understood as follows: using the range of connected components corresponding to the smallest discriminant unit at the sentence level as the processing boundary, only pixels determined to be handwritten text are deleted within this range, while pixels determined to be printed text are retained, and the spatial adjacency relationship and connected structure determined during the original sentence-level connected component segmentation are maintained. For example, when handwritten strokes and printed characters overlap or adhere at the pixel level and form an overall connected region, the pixel-level binary mask is used to remove only the pixels belonging to the handwritten strokes, without deleting the entire connected region, thereby preventing the printed characters from being mistakenly deleted or truncated, and ensuring that the printed text maintains a continuous arrangement structure among the character-level connected components.
[0054] 1. Model Training: This invention is trained using a self-constructed MAD-HPTS dataset, which contains 107,830 high-quality labeled samples. Its construction process is deeply coupled with the core algorithm of this invention: firstly, the SCCS algorithm is used to automatically segment the original scanned document. In this embodiment, the original scanned document consists of 200 A4 sheets, with content from news articles, contracts, and other sources, including:
[0055] Multiple languages: Chinese characters, Arabic numerals, English, Japanese;
[0056] Multiple writing styles: handwriting (using two different black fountain pens), printed text;
[0057] Multiple scanning devices: Two different devices based on the STM32 microcontroller;
[0058] Next, independent sentence-level connected component (SCC) units are extracted; then, baseline annotation of handwritten or printed attributes is performed on each SCC unit; finally, RHD feature modeling is performed on the annotated SCC units to generate the corresponding region-aware handwritten descriptor feature vector. It is a high-dimensional feature vector extracted from each SCC, which is formed by splicing the channel-level statistical features (mean, sum of squared deviations) and region-level shape features (area, aspect ratio) of all concentric ring regions R, thus forming a training sample pair with a one-to-one correspondence between "feature-label".
[0059] The system uses a Random Forest ensemble model with 20 decision trees as the classification vehicle. During the training phase, the algorithm uses bootstrap sampling to sample with replacement from the original training set, constructing an independent sub-training set for each decision tree to improve the model's generalization ability and noise resistance. During the node splitting process of the decision trees, the system automatically selects the most discriminative feature dimension from the high-dimensional RHD descriptors as the splitting threshold by calculating Gini Impurity or Information Gain, until a complete nonlinear mapping decision forest is constructed.
[0060] 2. Performance Evaluation and Application: On the MAD-HPTS dataset, the framework achieved an accuracy of 96.9%, only 1.4% lower than FCN (98.3%), but the inference time was significantly reduced from 67.5s to 8.7s, representing a speed improvement of over 8 times. Meanwhile, on the PHD-AS dataset containing perspective distortion, the accuracy reached 83.8% with a runtime of only 0.4s. In RK3576 edge device deployment tests, the runtime was reduced by approximately 45% compared to traditional solutions, validating its superior robustness and real-time performance in resource-constrained environments.
[0061] 3. Input the RHD features extracted from the image to be classified into the trained classification model to classify and segment handwritten and printed text. Based on the classification results, selectively remove the handwritten regions. In cases where handwritten strokes and printed text are intertwined or adhered, the structure of the printed text is preserved, thereby achieving handwritten erasure.
[0062] In summary, this invention utilizes the MAD-HPTS multilingual dataset to introduce a high-quality labeled dataset containing Chinese, English, Japanese, and numbers during model training and evaluation, validating the effectiveness and generalization ability of the proposed RHD region-aware handwritten feature extraction method. Furthermore, RHD region-aware handwritten feature extraction replaces heavy convolutional computation. It should be noted that the RHD region-aware handwritten feature extraction method is not dependent on a specific dataset; it can be applied to any document image. Region-aware feature vectors are extracted through steps one and two and used for subsequent classification model training and inference. This invention not only achieves efficient cross-language (Chinese, English, Japanese, Arabic) adaptation but also provides a high-performance, low-power standardized solution for edge-side document digitization processing by explicitly modeling spatial variability.
[0063] The technical solution of this invention is not limited to the specific embodiments described above. Without departing from the technical concept of this invention, the following alternative solutions can also be adopted: In addition to linear equidistant circular partitioning, the region division strategy can also employ square-law partitioning, log-polar partitioning, or sampling of local regions of interest based on stroke width transformation (SWT) to enhance the perception of non-uniform text. For region-aware handwriting feature extraction, in addition to the RHD proposed in this solution, Gabor filters, Local Binary Patterns (LBP), or Gray-Level Co-occurrence Matrix (GLCM) can also be introduced as alternative feature extraction schemes (replacing RHD). After replacement, the differences between handwritten and printed text can still be modeled to a certain extent, but due to the lack of explicit characterization of spatial distribution information, its ability to express "intrinsic variability" is weaker than the RHD proposed in this invention. Besides being alternative solutions, the above feature methods can also be combined with the region division strategy of this invention, that is, extracting Gabor, LBP, or GLCM features separately in different spatial sub-regions and concatenating them to construct a composite feature extraction with spatial awareness capabilities, thereby further improving classification performance. The smallest discriminant unit is not limited to sentence-level connected components; it can also be extended upwards to paragraph-level or downwards to character-level connected components. In addition to random forests, classification models can employ SVM, XGBoost, or lightweight fully connected neural networks to achieve feature decisions of the same dimension. Furthermore, besides the mean and squared difference, statistical metrics such as information entropy, skewness, or kurtosis can be introduced to further enhance robustness against complex background noise.
[0064] Those skilled in the art will recognize that the embodiments described herein are for the purpose of helping to understand the principles of the invention, and should be understood that the scope of protection of the invention is not limited to such specific statements and embodiments. Various modifications and variations can be made to the invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the invention should be included within the scope of the claims of the invention.
Claims
1. A handwritten character erasure method based on sentence-level connected component generation and region-aware descriptive feature extraction, characterized in that, include: S1. Perform sentence-level connected component segmentation on the image to obtain sentence-level minimum discriminant units; S2. Region-aware handwritten descriptor feature extraction based on sentence-level minimum discriminant units, wherein the sentence-level minimum discriminant unit is formed by the aggregation of multiple character-level connected components and corresponds to the connected domain range in the original image; S3. Construct a classification model; S4. Construct a training dataset based on the region-aware handwritten descriptor features extracted from the known image in steps S1 and S2, and then train the classification model constructed in step S3 based on the training dataset. S5. Input the region-aware handwritten descriptor features of the image to be classified extracted in steps S1 and S2 into the classification model trained in step S4 to obtain the classification result. S6. Based on the classification results of each sentence-level minimum discriminant unit obtained in step S5, the sentence-level minimum discriminant unit classified as handwritten is mapped to the original image coordinate system, and a corresponding pixel-level binary mask is constructed based on its connected component range. The mask value of 1 indicates that all pixels within the connected component range covered by the entire sentence-level minimum discriminant unit that is judged as handwritten text are included, and the mask value of 0 indicates that other pixels are excluded from the connected component range corresponding to the handwritten text. The original image is constrained and filtered based on a binary mask. For the sentence-level minimum discrimination unit that is determined to be handwritten text, if there is no interweaving of strokes or boundary adhesion between handwritten and printed text in its corresponding region, the pixels in the connected region corresponding to the sentence-level minimum discrimination unit are removed as a whole. If there are interwoven strokes or overlapping boundaries, then within the connected domain corresponding to the sentence-level minimum discrimination unit: only the pixels corresponding to the mask value of 1 are removed, while the spatial adjacency relationship and connected structure of the printed text determined by the sentence-level connected domain segmentation are preserved, thereby realizing the erasure of handwritten characters.
2. The handwritten character erasure method based on sentence-level connected component generation and region-aware descriptive feature extraction according to claim 1, characterized in that, Step S1 specifically includes the following sub-steps: S11. The image is smoothed and filtered to remove high-frequency noise, then binarized, and then morphological erosion and dilation operations are performed to connect broken strokes. Next, connected components in the image are extracted based on connected component analysis, and finally the initial character-level connected components are constructed using the disjoint-set data structure algorithm. S12. Based on the character-level connectivity component, construct a candidate set of lines of the same text according to the following formula; ; Where N(ch) represents the candidate set of the same text line neighborhood of the current character-level connected component ch; ch is the current character-level connected component to be processed; Let C be the candidate neighborhood character-level connected components; C is the complete set of all character-level connected components in the image; C\{ch} is the set of remaining character-level connected components after excluding the current character-level connected component ch; and These are components ch and The ordinate of the center of the circumscribed rectangle; This is the vertical tolerance threshold; S13. Generate sentence-level minimum discriminant units based on the candidate set of the same text line: Use the horizontal distance with the highest frequency between adjacent character-level components as an adaptive horizontal threshold. Based on this adaptive threshold, perform horizontal clustering of character-level connected components of the same text line in the candidate set of the same text line neighborhood. Aggregate character-level connected components with a spacing smaller than the adaptive threshold into sentence-level minimum discriminant units.
3. The handwritten character erasure method based on sentence-level connected component generation and region-aware descriptive feature extraction according to claim 2, characterized in that, Step S11 also includes filtering the initial character-level connected components from three dimensions: area, spatial density, and aspect ratio, to obtain the final character-level connected components.
4. The handwritten character erasure method based on sentence-level connected component generation and region-aware descriptive feature extraction according to claim 3, characterized in that, Step S11 also includes searching for and merging character-level connected components with a distance of less than 2 pixels.
5. A handwritten character erasure method based on sentence-level connected component generation and region-aware descriptive feature extraction according to claim 3 or 4, characterized in that, Step S12 includes further processing of the initial character-level connected components: If the bounding boxes of two character-level connected components overlap but their pixels do not intersect, they are considered to have layout overlap, triggering a lossless separation by finding the shortest path to the background pixels using breadth-first search. If the two character-level connected components are pixel-level connected, they are considered to have physical connection, triggering a segmentation using the local minima of the vertical projection. If the two components have neither overlapping bounding boxes nor pixel-level connection, they are normal independent components, and no segmentation operation is performed; they are directly retained as complete character-level connected components.
6. The handwritten character erasure method based on sentence-level connected component generation and region-aware descriptive feature extraction according to claim 5, characterized in that, Step S2 includes the following sub-steps: S21. Divide the current sentence-level smallest discriminative unit into regions; S22. Calculate the feature values of each region of the current sentence-level minimum discrimination unit; S23. Based on the feature values of each region of the current sentence-level minimum discrimination unit, construct region-aware handwritten descriptor features.
7. The handwritten character erasure method based on sentence-level connected component generation and region-aware descriptive feature extraction according to claim 6, characterized in that, The region division method used in step S21 is one of the following: concentric ring partitioning, linear partitioning, square law partitioning, or logarithmic polar coordinate partitioning.
8. The handwritten character erasure method based on sentence-level connected component generation and region-aware descriptive feature extraction according to claim 7, characterized in that, The feature values of step S22 include: mean, sum of squared deviations, area and aspect ratio.
9. A handwritten character erasure method based on sentence-level connected component generation and region-aware descriptive feature extraction according to claim 8, characterized in that, The classification model used in step S3 is the random forest model.
10. A handwritten character erasure method based on sentence-level connected component generation and region-aware descriptive feature extraction according to claim 9, characterized in that, Step S4: Each region-aware handwritten feature in the training dataset includes a label, which indicates whether it is handwritten or printed.