A method and system for automatic perspective correction and region extraction of handwritten Chinese characters
By combining YOLO detection and an improved Harris corner detection method with a multi-level region extraction algorithm, the problems of blurring and feature extraction caused by shooting angle and lighting conditions in handwritten Chinese character image processing are solved, achieving efficient and accurate Chinese character region extraction.
Patent Information
- Application Number
- CN202511029609.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-25
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2045-07-25
AI Technical Summary
Existing handwritten Chinese character image processing technologies suffer from problems such as blurred image acquisition, difficulty in feature extraction, and low processing efficiency due to factors such as shooting angle, lighting conditions, and writing style, which increases the difficulty of Chinese character extraction.
Perspective correction is performed using the YOLO detection method, combined with an improved Harris corner detection and multi-level region extraction algorithm. Through image size and color processing, high-precision Chinese character region extraction is achieved.
It improves the accuracy and efficiency of Chinese character region extraction, with a perspective correction error of less than 1%, fast processing speed, adaptability to various shooting conditions, success rate of over 95%, and suitability for mobile device applications.
Smart Images

Figure CN120526430B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the fields of computer vision and image processing technology, and in particular to a method and system for automatic perspective correction and region extraction of handwritten Chinese characters. Background Technology
[0002] In recent years, with the widespread adoption of mobile devices and the increasing demand for office automation, handwritten text image processing technology has developed rapidly. Traditional text recognition technology mainly targets printed text, but the processing difficulty of handwritten text, especially Chinese characters with rich stroke features, increases significantly. Currently, there are various handwritten text processing solutions on the market, including methods based on traditional image processing and methods based on deep learning. However, these solutions still have many problems in practical applications. These problems mainly include blurred image acquisition, difficulty in feature extraction, and low processing efficiency due to factors such as shooting angle, lighting conditions, writing style, and stroke complexity, which greatly increases the difficulty of extracting printed text such as Chinese characters.
[0003] Therefore, there is an urgent need for a Chinese character image processing design scheme that can effectively ensure the accuracy and efficiency of Chinese character extraction and processing. Summary of the Invention
[0004] This disclosure provides a method and system for automatic perspective correction and region extraction of handwritten Chinese characters. Through overall detection of the calligraphy model, perspective correction, and internal structure analysis, high-precision Chinese character region extraction is achieved.
[0005] According to a first aspect of this disclosure, a method for automatic perspective correction and region extraction of handwritten Chinese characters is provided, comprising the following steps:
[0006] We collected handwritten Chinese character calligraphy templates and images of them. After processing the images by adjusting their size and color, we obtained an image dataset.
[0007] The YOLO detection method is used to process the image to obtain the bounding box of the calligraphy template, and perspective transformation correction is performed on the bounding box.
[0008] An improved Harris method was used to detect corner points on the pre-corrected calligraphy copybook and extract the corner point image features.
[0009] Accurate region extraction and optimization are performed based on the corner image features obtained after detection to complete the region extraction.
[0010] In addition to the aspects and any possible implementations described above, a further implementation is provided in which the image resizing process is as follows:
[0011] Input the original image of the Chinese character calligraphy template, and calculate the original height and width of the original image;
[0012] Set the target size and calculate the aspect ratio factor by combining the height and width of the original image. Use the smaller aspect ratio factor as the scaling factor.
[0013] Based on the scaling factor, the original image is scaled using an improved bilinear interpolation method to obtain a scaled image;
[0014] A fixed value is calculated based on minimizing boundary effects, and this fixed value is used to fill the scaled image.
[0015] In addition to the aspects and any possible implementations described above, a further implementation is provided, wherein the specific process of color processing is as follows:
[0016] Based on the characteristics of human visual perception, the grayscale value of the original image is calculated;
[0017] The average brightness value is calculated based on the original image, and the γ value is calculated using the image histogram adaptive method.
[0018] Based on the γ value, the image pixel values are corrected using an adaptive gamma correction mechanism, and the corrected pixel values are used to obtain the corrected image.
[0019] An improved two-dimensional Gaussian kernel function is used to smooth the corrected image.
[0020] In addition to the aspects and any possible implementations described above, a further implementation is provided, wherein the improved two-dimensional Gaussian kernel function is specifically:
[0021] ;
[0022] Where G(x,y) represents the two-dimensional Gaussian kernel function value at point (x,y), and σ is the standard deviation of the Gaussian function.
[0023] In addition to the aspects and any possible implementations described above, a further implementation is provided, wherein the process of using the YOLO detection method to process the processed image, obtaining the bounding box of the calligraphy template, and performing perspective transformation correction on the bounding box is as follows:
[0024] A robust estimation method based on RANSAC is adopted and the homography matrix is calculated based on the projection relationship of corresponding point pairs.
[0025] Based on the homography matrix, the geometric constraints of the bounding box are optimized using parallelism constraints, orthogonality constraints, area ratio constraints, and projective invariant constraints.
[0026] The Levenberg-Marquardt method is used for refinement iteration, and the boundary is processed by reprojection to complete the perspective transformation correction.
[0027] In addition to the aspects and any possible implementations described above, a further implementation is provided, wherein the process of using the improved Harris method to perform corner detection on the pre-corrected calligraphy template and extracting the corner image features is as follows:
[0028] The image of the pre-corrected calligraphy template is filtered using a difference operator, and the value of each pixel in the image is calculated. , as well as ,in, I x for x Gradient of direction, I y for y Gradient of direction;
[0029] right , as well as Gaussian smoothing is applied to remove image noise;
[0030] Calculate the response function of each corresponding point in the original image, enhance the response function by introducing a direction weighting factor, and then suppress the local nonmaximum value of the enhanced response function.
[0031] A threshold is set based on the RANSAC method. If the enhanced response function is greater than the threshold and is a local maximum in the neighborhood, then the point is extracted as a corner point.
[0032] A multi-level corner optimization method is used to optimize the extracted corner points, resulting in optimized corner point features.
[0033] In addition to the aspects and any possible implementations described above, a further implementation is provided, wherein the process of performing precise region extraction and optimization based on the corner image features obtained after detection, and completing the region extraction process, is as follows:
[0034] A region growing method with multi-feature fusion was constructed, and multi-scale feature extraction was performed to complete image segmentation;
[0035] Multi-scale feature extraction is performed on the segmented image features, and the segmented image is obtained by constructing a semantic segmentation network based on the U-Net structure.
[0036] Hierarchical local analysis is performed on the segmented image to obtain extraction results, and the extraction results are optimized to complete the region extraction.
[0037] In addition to the aspects and any possible implementations described above, a further implementation is provided in which the process of optimizing the extraction result is as follows:
[0038] Based on the region merging criteria, the extracted results are merged and segmented to obtain the processed results.
[0039] Construct an activity contour energy function, and perform boundary smoothing on the processed result based on the function;
[0040] The optimization process is completed by constructing regional feature vectors and filtering out noisy regions.
[0041] According to a second aspect of this disclosure, an automatic perspective correction and region extraction system for handwritten Chinese characters is provided, comprising: an image acquisition and preprocessing module, a perspective transformation correction module, a corner detection module, and a region extraction module;
[0042] The image acquisition and preprocessing module is used to collect handwritten Chinese character templates and acquire images of the templates. After processing the images for size and color, an image dataset is obtained.
[0043] The perspective transformation correction module is used to process the processed image using the YOLO detection method, obtain the bounding box of the calligraphy template, and perform perspective transformation correction on the bounding box;
[0044] The corner detection module is used to perform corner detection on the pre-corrected calligraphy template using an improved Harris method, and extract the corner image features of the image.
[0045] The region extraction module is used to perform accurate region extraction and optimization based on the corner image features obtained after detection, thereby completing the region extraction.
[0046] Compared with the prior art, the present invention has the following technical effects:
[0047] (1) The present invention adopts a YOLO-based character copybook detection technology: an improved YOLOv8 model structure, specifically optimized for character copybook features, an innovative data augmentation strategy to improve detection robustness, and an optimized loss function design to improve positioning accuracy;
[0048] (2) The present invention adopts an accurate perspective transformation method: by estimating the homography matrix based on RANSAC, combined with geometric constraints, and introducing projective invariant constraints, the geometric consistency of the transformation is ensured, and a boundary condition processing mechanism is designed to improve the correction effect;
[0049] (3) The present invention adopts an improved Harris corner detection algorithm: by introducing a direction weighting factor, the sensitivity to Chinese character stroke features is improved; combined with the design of a direction-adaptive suppression window, it can handle multi-directional features; and by adopting a saliency scoring mechanism, the detection accuracy is improved.
[0050] It should be understood that the description in the Summary of the Invention is not intended to limit the key or essential features of the embodiments of this disclosure, nor is it intended to restrict the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0051] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. The drawings are provided for a better understanding of the invention and are not intended to limit the scope of this disclosure. In the drawings, the same or similar reference numerals denote the same or similar elements, wherein:
[0052] Figure 1 A schematic flowchart of an automatic perspective correction and region extraction method for handwritten Chinese characters according to an embodiment of the present disclosure is shown.
[0053] Figure 2 A schematic diagram of an automatic perspective correction and region extraction system for handwritten Chinese characters according to an embodiment of the present disclosure is shown. Detailed Implementation
[0054] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0055] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0056] Reference Figure 1 As shown, this embodiment provides a method for automatic perspective correction and region extraction of handwritten Chinese characters, including the following steps:
[0057] S101. Collect handwritten Chinese character templates and acquire images of the templates. After processing the images for size and color, obtain an image dataset.
[0058] In this embodiment, after acquiring the image of the Chinese character calligraphy model, an intelligent size adjustment method is used to adjust the image size. The specific process is as follows:
[0059] First, analyze the original size of the input image. Combined with the target size of 640×640 pixels, calculate the aspect ratio factor and select the smaller aspect ratio factor as the scaling factor.
[0060] Scaling factor The calculation formula is:
[0061] (1);
[0062] Where W_target and H_target are the target width and height, respectively, and W_original and H_original are the original image width and height, respectively.
[0063] Secondly, image scaling is performed using a bilinear interpolation algorithm. An improved bilinear interpolation algorithm is employed during the scaling process. For the target pixel (x, y), the formula for calculating its pixel value f(x, y) is:
[0064] (2);
[0065] Where f(x, y) represents the interpolation result at the target position (x, y), f(x_i, y_j) represents the values of the four surrounding neighboring pixels, i,j ∈ {0,1} represents taking the adjacent 2×2 pixel region, and w(i, j) is the weight coefficient, calculated as follows:
[0066] (3);
[0067] Traditional bilinear interpolation is based on linear weighting of distances, while in this implementation, an improved weighting calculation method as shown in formula (3) is adopted. This calculation method considers the relative distances in both the x and y directions, making the interpolation results smoother and more accurate.
[0068] Finally, a fixed value is used for filling: for the area that needs to be filled, a fixed value (114,114,114) is used for filling. This value is the optimal solution obtained by minimizing the boundary effect.
[0069] Meanwhile, in this embodiment, the specific process of the color space conversion method is as follows:
[0070] First, based on the characteristics of human visual perception, an optimized weighting coefficient Y, i.e., the grayscale value, was designed. The formula for calculating the grayscale value Y is:
[0071] (4);
[0072] R, G, and B represent the red, green, and blue component values of the pixel, respectively.
[0073] Equation 4 shows the optimized weighting system, which is designed based on the characteristics of human eye perception. The weighting system in this embodiment reflects the sensitivity of the human eye to different colors. Specifically, it is most sensitive to green (0.587), followed by red (0.299), and least sensitive to blue (0.114). The sum of these coefficients equals 1, ensuring the correct calculation of the brightness value.
[0074] Secondly, an adaptive gamma correction mechanism is introduced, and the formula for calculating the pixel value I' of the corrected output image is:
[0075] (5);
[0076] in, γ is a scaling factor used to adjust the overall brightness, where I is the pixel value of the input image and γ is the correction coefficient, adaptively calculated by analyzing the image histogram.
[0077] (6);
[0078] Where L_mean is the average brightness value of the image.
[0079] Finally, an improved two-dimensional Gaussian kernel function G(x,y) is used for image smoothing:
[0080] (7);
[0081] Here, G(x,y) represents the two-dimensional Gaussian kernel function value at point (x,y), and σ is the standard deviation of the Gaussian function, which determines the width of the Gaussian kernel. A larger value of σ results in a wider Gaussian kernel and a more pronounced smoothing effect; a smaller value of σ results in a narrower Gaussian kernel and a weaker smoothing effect. In practical applications, the value of σ is usually adaptively adjusted according to the noise level of the image.
[0082] (8);
[0083] in, The scaling factor is denoted by _noise_level, which is obtained through local variance estimation. Equation 8 indicates that the standard deviation of the Gaussian kernel adaptively adjusts according to the noise level of the image.
[0084] This embodiment also improves upon the traditional binarization method, specifically as follows:
[0085] First, an inter-class variance weighting mechanism is introduced, and the formula for calculating the optimal threshold t* is:
[0086] (9);
[0087] in, and The weights for the foreground and background are respectively. and These are the average gray values for the foreground and background, respectively.
[0088] Secondly, for each pixel (x, y) in the image, the formula for calculating its local threshold T(x, y) is:
[0089] (10);
[0090] Where m(x,y) is the local mean and s(x,y) is the local standard deviation. The global standard deviation is... To adjust the parameters.
[0091] S102. The YOLO detection method is used to process the processed image to obtain the bounding box of the calligraphy template, and perspective transformation correction is performed on the bounding box.
[0092] This invention employs an innovative matrix calculation method:
[0093] First, robust estimation based on RANSAC: the homography matrix H is calculated based on the projection relationship of corresponding point pairs:
[0094] (11);
[0095] Where x and x' are the homogeneous coordinates of the corresponding points.
[0096] H is calculated using the improved RANSAC algorithm, and the consistency score Q is calculated as follows:
[0097] (12);
[0098] Where d is the reprojection error and δ is the scale parameter.
[0099] Secondly, geometric constraint optimization: multiple geometric constraints are introduced:
[0100] Parallelism constraint: Orthogonality constraint: Area ratio constraints: (13);
[0101] Where l1 and l2 represent two straight lines in the original image, and l1' and l2' represent the corresponding straight lines in the transformed image, H T It is the transpose of the homography matrix, where A represents the area in the original image, A' represents the area after transformation, and det(H) represents the determinant of the homography matrix H.
[0102] Finally, the iterative refinement strategy: based on the Levenberg-Marquardt algorithm, the objective function is optimized as follows:
[0103] (14);
[0104] Where w_i is the weight coefficient, R(H) is the regularization term, and λ is the balance parameter. This represents the squared Euclidean distance between corresponding points before and after the transformation.
[0105] Meanwhile, this invention designs a parameter optimization mechanism:
[0106] First, geometric invariance is preserved: based on constraints of projective invariants.
[0107] Alternating constant ratio: ; Collinearity preservation: (15);
[0108] Where A, B, C, D represent four collinear points in the original image, A', B', C', D' represent the cross ratio of the four points after the transformation remains unchanged under the projection transformation, det([x1x2x3]) = 0, x1, x2, x3 represent the homogeneous coordinates of the three points, and when det=0, it means that the three points x1, x2, x3 are collinear.
[0109] Secondly, distortion compensation mechanism: radial distortion model:
[0110] (16);
[0111] (17);
[0112] Tangential distortion model:
[0113] (18);
[0114] (19);
[0115] Where (x, y) are the ideal coordinates, and (x_d, y_d) are the actual coordinates. k1 and k2 are radial distortion coefficients, and p1 and p2 are tangential distortion coefficients.
[0116] Finally, boundary condition handling: an interpolation algorithm with directional derivative constraints is used.
[0117] (20);
[0118] Where n is the direction of the boundary normal vector. Let be the image intensity. Equation 20 indicates that the normal derivative of the image intensity is zero at the boundary, meaning a smooth transition at the boundary.
[0119] Finally, this invention employs a high-quality reprojection method:
[0120] First, improved bilinear interpolation: adaptive weight calculation based on directional derivative:
[0121] (twenty one);
[0122] in, For image gradient, This is the interpolation direction vector.
[0123] Secondly, edge pixel processing: interpolation weight adjustment for edge regions:
[0124] (twenty two);
[0125] Where edge(i,j) is the edge strength. This is the enhancement coefficient.
[0126] S103. The improved Harris method is used to detect corner points on the pre-corrected calligraphy copybook and extract the corner point image features.
[0127] The specific process is as follows: the image of the pre-corrected calligraphy template is filtered using a difference operator, and the value of each pixel in the image is calculated. , as well as , among which, I x Let I be the gradient in the x-direction. y The gradient is in the y-direction;
[0128] right , as well as Gaussian smoothing is applied to remove image noise;
[0129] Calculate the response function of each corresponding point in the original image, enhance the response function by introducing a direction weighting factor, and then suppress the local nonmaximum value of the enhanced response function.
[0130] A threshold is set based on the RANSAC method. If the enhanced response function is greater than the threshold and is a local maximum in the neighborhood, then the point is extracted as a corner point.
[0131] A multi-level corner optimization method is used to optimize the extracted corner points, resulting in optimized corner point features.
[0132] Specifically, this invention makes comprehensive improvements to the traditional Harris algorithm:
[0133] First, in scale space, the formula for calculating the Harris response function R(x,y,σ) is:
[0134] (twenty three);
[0135] Where M is the Harris matrix:
[0136] ;
[0137] Where I_x and I_y are the image gradients in the x and y directions, respectively, and G_σ is the Gaussian kernel function. It is an empirical constant (usually taken as 0.04-0.06).
[0138] Secondly, a direction weighting factor w(θ) is introduced:
[0139] (twenty four);
[0140] Where θ is the gradient direction of the current pixel, and θ_dominant is the local principal direction. These are the weighting coefficients.
[0141] The enhanced Harris response function is:
[0142] (25);
[0143] Finally, based on the RANSAC concept, the formula for calculating the threshold T is:
[0144] (26);
[0145] Where μ_R and σ_R are the mean and standard deviation of the response value, respectively. This was determined through a consistency check.
[0146] This invention employs a multi-level corner optimization method:
[0147] First, an orientation-adaptive suppression window W(x,y,θ) was designed:
[0148] (27);
[0149] Where r is the window radius, Let (u, v) be the local gradient direction, and (u, v) be the coordinates of any point within the window. Control the horizontal window size. Control the window size in the vertical direction, |ux|≤r· Represents a constraint in the horizontal direction, |vy|≤r· This indicates a constraint in the vertical direction.
[0150] Secondly, the saliency-based screening mechanism: the formula for calculating the saliency score S of the corner is:
[0151] (28);
[0152] in, Here, C represents the Harris response value, D represents the local contrast, and D represents the spatial distribution score. , , These are the weighting coefficients.
[0153] Finally, based on the Delaunay triangulation, a spatial distribution uniformity measure E is defined:
[0154] (29);
[0155] Where A_i is the area of the triangle, and A_mean is the average area. The number of triangles.
[0156] S104. Based on the corner image features obtained after detection, perform accurate region extraction and optimization to complete the region extraction.
[0157] This invention designs a precise area positioning method:
[0158] First, improved connected component analysis: region growth criterion:
[0159] (30);
[0160] Where T(p,q) is the adaptive threshold, I(p) is the gray value of seed point p, and I(q) is the gray value of candidate point q.
[0161] (31);
[0162] Where σ_local is the local standard deviation. is a scaling factor used to adjust the sensitivity of the threshold, and c is a constant offset used to provide the base threshold.
[0163] Secondly, hierarchical region growth: growth criteria based on multi-feature fusion.
[0164] (32);
[0165] Where D_intensity represents grayscale difference, D_gradient represents gradient difference, D_texture represents texture difference, and D(p,q) is the overall difference measure. Weights for grayscale differences For gradient difference weights, This represents the texture difference weight.
[0166] Finally, adaptive segmentation threshold: local contrast adaptive mechanism:
[0167] (33);
[0168] Where μ_local is the local mean, reflecting the average brightness level of the region; σ_local is the local standard deviation, reflecting the degree of variation in the region; and T(x,y) is the adaptive threshold. These are local coefficients.
[0169] This invention employs advanced layout analysis technology:
[0170] First, multi-scale feature extraction: feature pyramid construction:
[0171] (34);
[0172] Where P_l is the pooling operation, l is the pyramid level, and F_I is the feature value of different levels.
[0173] Secondly, semantic segmentation networks: loss function based on U-Net architecture:
[0174] (35);
[0175] Where L_ce is the cross-entropy loss, L_dice is the Dice coefficient loss, L_boundary is the boundary loss, and λ1 and λ2 are the weight coefficients of the loss function, used to balance the contributions of different loss terms.
[0176] Finally, hierarchical layout analysis: similarity measurement of document structure tree construction:
[0177] (36);
[0178] Where sim_spatial represents spatial similarity and sim_semantic represents semantic similarity. , These are the weighting coefficients, and + = 1.
[0179] This invention optimizes the extraction results through the following steps:
[0180] First, region merging and partitioning: Region merging criteria:
[0181] ,if (37);
[0182] in, A metric for distance between regions. For the region and The merge operation, where T_merge is the merge threshold. , This refers to the regions to be merged.
[0183] (38);
[0184] Where D_color is the color feature distance, D_texture is the texture feature distance, and D_shap is the shape feature distance. , , These are the weight coefficients for each feature, and + + = 1.
[0185] Secondly, boundary smoothing: Active contour energy function:
[0186] (39)
[0187] Where E_internal is the internal energy, E_external is the external energy, E_constraint is the constraint energy, and α, β, γ are the weighting coefficients of the energy terms.
[0188] Finally, noise region filtering: construction of the region feature vector f:
[0189] (40);
[0190] Where f_size is the region size feature, f_shape is the region shape feature, f_texture is the region texture feature, and f_location is the region location feature.
[0191] Criteria for determining noisy areas:
[0192] ,if (41);
[0193] Among them, is_noise( ) is used to determine the region Whether it is noise or not, T_noise is the noise threshold, and score(f) is the scoring function based on multi-feature fusion.
[0194] like Figure 2 As shown, this embodiment also provides an automatic perspective correction and region extraction system for handwritten Chinese characters, including: an image acquisition and preprocessing module 1, a perspective transformation correction module 2, a corner detection module 3, and a region extraction module 4;
[0195] Image acquisition and preprocessing module 1 is used to collect handwritten Chinese character templates and acquire images of the Chinese character templates. After processing the images for size and color, an image dataset is obtained.
[0196] The perspective transformation correction module 2 is used to process the processed image using the YOLO detection method, obtain the bounding box of the calligraphy template, and perform perspective transformation correction on the bounding box;
[0197] The corner detection module 3 is used to perform corner detection on the pre-corrected calligraphy template using the improved Harris method, and extract the corner image features of the image.
[0198] The region extraction module 4 is used to perform accurate region extraction and optimization based on the corner image features obtained after detection, thus completing the region extraction.
[0199] This invention employs a multi-layered optimization strategy for computational efficiency. In terms of parallel computing, it fully utilizes the parallel processing capabilities of modern computing hardware to implement a multi-layered parallel computing framework. At the CPU level, it adopts the OpenMP parallel computing framework, using the `#pragma omp parallel` instruction to achieve multi-threaded parallel execution of image processing tasks. For computationally intensive tasks, such as corner detection and feature extraction, thread pool technology is used to achieve dynamic task scheduling and load balancing.
[0200] Furthermore, this invention supports GPU-accelerated computing, implementing GPU parallelization of key algorithms based on the CUDA framework. Through optimized kernel function design, it fully leverages the SIMD (Single Instruction, Multiple Data) characteristics of the GPU, significantly improving the processing efficiency of large-scale data. In actual tests, the GPU-accelerated version achieves a 3-5 times performance improvement compared to the CPU version when processing large images.
[0201] In terms of algorithm optimization, this invention employs a series of optimization strategies to improve computational efficiency while ensuring accuracy. For computationally intensive operations, such as corner response function calculation, a fast approximation algorithm based on Taylor expansion is used. By finding a balance between accuracy and efficiency, a significant reduction in computational load is achieved while maintaining acceptable accuracy loss (error controlled within 1%).
[0202] This invention designs and implements a high-efficiency memory pool management system to optimize frequent memory allocation and deallocation operations. The memory pool employs a hierarchical design, including a large object pool and a small object pool, each handling memory requests of different sizes. For temporary buffer allocations common in image processing, a recycling strategy is used, significantly reducing memory fragmentation and allocation overhead.
[0203] In terms of cache optimization, a multi-level caching optimization strategy was implemented, taking into account the characteristics of modern computer architectures. By analyzing the program's data access patterns, the memory layout of data structures was optimized, improving cache hit rate. Techniques such as data alignment, prefetching mechanisms, locality optimization, and cache block partitioning were employed to effectively improve system performance.
[0204] This invention implements a complete exception handling framework to ensure stable system operation under various abnormal conditions. The exception handling mechanism includes comprehensive validity checks on input data, status monitoring and anomaly detection of key steps, multi-level error recovery strategies, and a hierarchical logging system.
[0205] In terms of adaptive optimization, the system can dynamically adjust parameters according to input characteristics and operating environment, realize a task scheduling strategy based on performance feedback, and establish a complete performance indicator monitoring and analysis system.
[0206] In specific applications, this invention can be applied to the following scenarios:
[0207] 1. Document Scanning Application: In office document digitization scenarios, this system can effectively handle the scanning needs of various paper documents. The system can automatically correct perspective distortion in documents, accurately extract text areas, and optimize the output results to ensure the quality of digitized documents.
[0208] In document recognition applications, the system can accurately locate the position of the ID card, precisely extract the document border, reasonably segment the text area, and improve the recognition effect through image enhancement technology.
[0209] 2. Educational Applications: In homework grading scenarios, the system can automatically correct test paper images, accurately extract answer areas, identify teacher annotation areas, and support statistical analysis of grades. This greatly improves teachers' work efficiency.
[0210] For processing classroom notes, the system can capture the content on the blackboard, correct the distortion of the projected content, extract key note areas, and improve the readability of the content through image enhancement technology.
[0211] 3. Mobile Application Scenarios: In mobile scanning applications, the system provides real-time preview and correction functions, supports fast image capture, can automatically perform cropping and optimization, and complete image processing locally, providing a good user experience.
[0212] In terms of document management, the system supports batch processing of documents, provides an intelligent classification and storage mechanism, supports content-based retrieval, and can synchronize with cloud services to ensure data security.
[0213] Therefore, this invention offers several advantages: high correction accuracy (average error of perspective transformation is less than 1%, significantly improving image correction accuracy); fast processing speed (real-time processing is possible on mainstream hardware platforms with an average processing time of less than 100ms); strong robustness (adapting to various shooting conditions and document types with a success rate exceeding 95%); high degree of automation (no manual intervention required, fully automated processing); and low resource consumption (small memory footprint (<500MB), suitable for mobile device applications).
[0214] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this disclosure is not limited to the described order of actions, because according to this disclosure, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this disclosure.
[0215] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0216] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A method for automatic perspective correction and region extraction of handwritten Chinese characters, characterized in that, Includes the following steps: We collected handwritten Chinese character templates and acquired images of them. After processing the images for size and color, we obtained an image dataset. We then used the YOLO detection method to process the images, obtained the bounding boxes of the templates, and performed perspective transformation correction on the bounding boxes. An improved Harris method was used to detect corner points on the pre-corrected calligraphy copybook and extract the corner point image features. The process of using the improved Harris method to detect corner points in the pre-corrected calligraphy template and extracting corner point image features is as follows: The image of the pre-corrected calligraphy template is filtered using a difference operator, and the value of each pixel in the image is calculated. , as well as ,in, I x Let be the gradient in the x-direction. I y The gradient is in the y-direction; right , as well as Gaussian smoothing is applied to remove image noise; Calculate the response function of each corresponding point in the original image, enhance the response function by introducing a direction weighting factor, and then suppress the local nonmaximum value of the enhanced response function. A threshold is set based on the RANSAC method. If the enhanced response function is greater than the threshold and is a local maximum in the neighborhood, then the corresponding point is extracted as a corner point. A multi-level corner optimization method is used to optimize the extracted corner points, resulting in optimized corner point features; Accurate region extraction and optimization are performed based on the corner image features obtained after detection to complete the region extraction.
2. The method for automatic perspective correction and region extraction of handwritten Chinese characters according to claim 1, characterized in that, The process of resizing the image is as follows: Input the original image of the Chinese character calligraphy template, and calculate the original height and width of the original image; Set the target size and calculate the aspect ratio factor by combining the height and width of the original image. Use the smaller aspect ratio factor as the scaling factor. Based on the scaling factor, the original image is scaled using an improved bilinear interpolation method to obtain a scaled image; A fixed value is calculated based on minimizing boundary effects, and this fixed value is used to fill the scaled image.
3. The method for automatic perspective correction and region extraction of handwritten Chinese characters according to claim 2, characterized in that, The specific process of color processing is as follows: Based on the characteristics of human visual perception, the grayscale value of the original image is calculated; The average brightness value is calculated based on the original image, and the γ value is calculated using the image histogram adaptive method. Based on the γ value, the image pixel values are corrected using an adaptive gamma correction mechanism, and the corrected pixel values are used to obtain the corrected image. An improved two-dimensional Gaussian kernel function is used to smooth the corrected image.
4. The method for automatic perspective correction and region extraction of handwritten Chinese characters according to claim 3, characterized in that, The improved two-dimensional Gaussian kernel function is specifically as follows: ; Where G(x,y) represents the two-dimensional Gaussian kernel function value at point (x,y), and σ is the standard deviation of the Gaussian function.
5. The method for automatic perspective correction and region extraction of handwritten Chinese characters according to claim 1, characterized in that, The process of using the YOLO detection method to process the processed image, obtaining the bounding box of the calligraphy template, and then performing perspective transformation correction on the bounding box is as follows: A robust estimation method based on RANSAC is adopted and the homography matrix is calculated based on the projection relationship of corresponding point pairs. Based on the homography matrix, the geometric constraints of the bounding box are optimized using parallelism constraints, orthogonality constraints, area ratio constraints, and projective invariant constraints. The Levenberg-Marquardt method is used for refinement iteration, and the boundary is processed by reprojection to complete the perspective transformation correction.
6. The method for automatic perspective correction and region extraction of handwritten Chinese characters according to claim 1, characterized in that, The process of performing precise region extraction and optimization based on the corner point image features obtained after detection, and completing the region extraction process, is as follows: A region growing method with multi-feature fusion was constructed, and multi-scale feature extraction was performed to complete image segmentation; Multi-scale feature extraction is performed on the segmented image features, and the segmented image is obtained by constructing a semantic segmentation network based on the U-Net structure. Hierarchical local analysis is performed on the segmented image to obtain extraction results, and the extraction results are optimized to complete the region extraction.
7. The method for automatic perspective correction and region extraction of handwritten Chinese characters according to claim 6, characterized in that, The process of optimizing the extraction results is as follows: Based on the region merging criteria, the extracted results are merged and segmented to obtain the processed results. Construct an activity contour energy function, and perform boundary smoothing on the processed result based on the function; The optimization process is completed by constructing regional feature vectors and filtering out noisy regions.
8. A system for automatic perspective correction and region extraction of handwritten Chinese characters, used to implement the method for automatic perspective correction and region extraction of handwritten Chinese characters as described in any one of claims 1-7, characterized in that, include: Image acquisition and preprocessing module (1), perspective transformation correction module (2), corner detection module (3), and region extraction module (4); The image acquisition and preprocessing module (1) is used to collect handwritten Chinese character templates and acquire images of Chinese character templates. After processing the size and color of the images, an image dataset is obtained. The perspective transformation correction module (2) is used to process the processed image using the YOLO detection method, obtain the bounding box of the calligraphy template, and perform perspective transformation correction on the bounding box; The corner detection module (3) is used to perform corner detection on the pre-corrected calligraphy copybook using the improved Harris method, and extract the corner image features of the image. The region extraction module (4) is used to perform accurate region extraction and optimization based on the corner image features obtained after detection, and to complete the region extraction.
Citation Information
Patent Citations
Table recognition overprinting method, computer equipment and computer readable storage medium
CN112183038A