A mistake question identification method and system based on image recognition and a printer

By calculating gradients and performing local neighborhood analysis in images of incorrect questions, edge saliency and coherence coefficients are constructed. Combined with adaptive nonmaximum suppression, the problem of distinguishing handwritten strokes from background noise in images of incorrect questions is solved, improving the accuracy and robustness of incorrect question recognition.

CN122200671APending Publication Date: 2026-06-12深圳市通亮智能科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
深圳市通亮智能科技有限公司
Filing Date
2026-03-11
Publication Date
2026-06-12

Smart Images

  • Figure CN122200671A_ABST
    Figure CN122200671A_ABST
Patent Text Reader

Abstract

The present application relates to the field of image processing, in particular to a kind of wrong question identification method, system and printer based on image recognition.The method comprises: calculating the gradient information of image, constructing the edge saliency coefficient of inhibiting background and optimizing edge direction by matching analysis of pairs of pixels;Based on the consistency of direction aggregation, the edge coherence coefficient of reinforced stroke continuity is generated;According to the structural support condition of pixel point on the edge ridge line, adaptive non-maximum suppression is carried out, and high-quality single-pixel width edge map is generated, after morphological processing and character segmentation, wrong question determination is realized by OCR identification and answer comparison.The present application simulates the stroke structure characteristics, realizes the accurate, coherent segmentation of handwritten characters under complex background, significantly improves the accuracy and robustness of wrong question identification system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing. More specifically, this invention relates to a method, system, and printer for identifying incorrect answers based on image recognition. Background Technology

[0002] In image recognition-based error collection systems, accurately segmenting handwritten characters from complex backgrounds is a crucial prerequisite for ensuring the accuracy of Optical Character Recognition (OCR). Currently, mainstream methods rely on classic edge detection algorithms (such as the Canny operator) for character contour extraction. However, these general-purpose algorithms struggle to distinguish between real stroke edges and structural background noise when processing handwritten error images in real-world scenarios.

[0003] Images of incorrect answers often contain regular background textures such as exercise book grids and horizontal lines, and the resulting gradient responses are similar to character edges. Traditional methods, such as the Canny algorithm, rely solely on the magnitude of the gradient in the gradient direction of a single pixel for their non-maximum suppression (NMS) step. This makes it impossible to distinguish mechanistically whether a high gradient response originates from a stroke or the background grid, easily leading to the misidentification and preservation of background textures as character edges, resulting in severe problems of characters and background becoming blurred together.

[0004] Furthermore, it cannot maintain the inherent continuity and consistency of handwritten strokes. Handwritten strokes have characteristics such as uneven ink distribution and width variations, resulting in uneven distribution of gradient magnitudes along the edges. The local extremum judgment of traditional NMS is isolated and rigid. It suppresses pixels with relatively low magnitudes that actually belong to the same continuous stroke, destroying the topological continuity of strokes. This leads to a large number of breaks in the output edge map, fragmenting a complete character and causing great difficulties for subsequent contour closure and character extraction. Summary of the Invention

[0005] To address the problem of fragmented and fused characters caused by the inability to maintain the inherent continuity and consistency of handwritten strokes, this invention proposes an image recognition-based error identification method, system, and printer, aiming to improve the segmentation continuity and accuracy of handwritten fonts.

[0006] To achieve the above objectives, an embodiment of the first aspect of the present invention proposes an image recognition-based method for identifying incorrect questions, the method comprising:

[0007] Obtain images of incorrect questions containing handwritten characters and preprocess them; calculate the gradient magnitude and gradient direction of the incorrect question images.

[0008] Based on the gradient magnitude and gradient direction, pairwise pixel matching analysis is performed on each pixel in its local neighborhood, and after local statistical normalization, an edge saliency coefficient is constructed to characterize the degree of suspicion of the pixel as a stroke boundary, and the optimized edge direction is obtained at the same time.

[0009] Based on the edge saliency coefficient and the optimized edge direction, the directional consistency aggregation intensity of each pixel point along the edge tangent direction within its local window is calculated, and then fused to obtain the edge coherence coefficient characterizing the structural coherence of the edge segment.

[0010] Using the edge coherence coefficient and the optimized edge direction, and based on whether the pixel obtains sufficient directional consistency structural support on the local edge ridge, adaptive non-maximum suppression is performed to generate a single-pixel wide binary edge image.

[0011] The binary edge image is subjected to morphological processing, connected component analysis and contour filling to segment the character region. The text is obtained by optical character recognition and compared with the standard answer to complete the judgment of incorrect questions.

[0012] Preferably, the step of calculating the gradient magnitude and gradient direction of the incorrect question image includes: performing convolution on the grayscale image after illumination equalization preprocessing using gradient operators in the horizontal and vertical directions to obtain gradient components; and calculating the gradient magnitude and gradient direction of each pixel based on the gradient components.

[0013] Preferably, the step of constructing an edge saliency coefficient characterizing the pixel as the suspected boundary of a stroke, and simultaneously obtaining the optimized edge direction, includes: taking any pixel in the incorrect question image as the target pixel; for the target pixel, calculating the pairing cost between each candidate pixel and the target pixel within a fan-shaped search region in the opposite direction of its gradient, wherein the pairing cost is determined by a combination of a direction consistency factor, a relative difference ratio of gradient magnitudes, and a normalized Euclidean distance; selecting the candidate pixel that minimizes the pairing cost as the optimal consistency point; calculating the initial edge suspected degree of the target pixel based on the minimum pairing cost; performing local sliding window standardization on the initial edge suspected degree to obtain the edge saliency coefficient; and reversing the gradient direction of the optimal consistency point as the optimized edge direction of the target pixel.

[0014] Preferably, the step of calculating the directional consistency aggregation intensity of each pixel point within its local window along the edge tangent direction, and then fusing them to obtain an edge coherence coefficient characterizing the structural coherence of the edge segment, includes: for each center pixel point, in the local coordinate system defined by its optimized edge direction, calculating the contribution weight of each neighboring point within the aggregation window to the center point, wherein the contribution weight is obtained by multiplying the directional consistency weight by the anisotropic spatial distribution weight; using the contribution weight to perform a weighted average of the nonnegative edge saliency coefficients of the neighboring points to obtain the directional consistency aggregation intensity; and calculating the geometric mean of the nonnegative edge saliency coefficient of the center pixel point and the directional consistency aggregation intensity as the edge coherence coefficient.

[0015] Preferably, the step of performing adaptive nonmaximum suppression includes: for each pixel to be decided, determining the normal peak value in its optimized edge direction and calculating its normal profile convexity; within the support window centered on the pixel to be decided, counting the number of support points consistent with its edge direction and calculating the average edge coherence coefficient of the support points; setting a minimum length threshold; if the pixel to be decided is a normal peak value and the number of support points reaches the minimum length threshold, it is determined to be an edge point; if the pixel to be decided is not a normal peak value, but its normal profile convexity is positive, and the number of support points reaches the minimum length threshold, and the average edge coherence coefficient is not lower than a preset proportion of the edge coherence coefficient of the pixel to be decided, it is determined to be an edge point; otherwise, the point is suppressed.

[0016] Preferably, when counting the number of support points, the method for determining whether the edge direction of the neighboring point is consistent with that of the pixel to be decided is as follows: calculate the absolute value of the cosine of the angle between the edge directions of the two points. If it is greater than the preset direction consistency threshold, then it is determined to be consistent.

[0017] Preferably, the steps of segmenting the character region, obtaining text through optical character recognition, and comparing it with the standard answer to complete the error judgment include: performing morphological closing operations on the binary edge image to connect microscopic breaks; finding contours in the processed image and filling them to obtain a binary mask of the character stroke region; performing connected component analysis on the binary mask to obtain multiple connected components, retaining candidate character regions based on the area and aspect ratio thresholds of each connected component; inputting the candidate character regions into a pre-trained optical character recognition model to obtain the recognized text, calculating its text similarity with the corresponding standard answer, and determining whether it is an error question based on a preset similarity threshold.

[0018] Preferably, when filtering connected components, the upper limit of the area threshold is set according to the percentage of the total pixels of the image, so as to filter out excessively large non-character regions.

[0019] A second aspect of the present invention provides an image recognition-based error identification system, the system comprising: a processor and a memory, the memory storing computer program instructions, which, when executed by the processor, implement the above-described image recognition-based error identification method.

[0020] A third aspect of the present invention provides a printer that integrates the above-mentioned error recognition system and includes an image acquisition module, a printing module, and a user interface; the image acquisition module is used to acquire error images containing handwritten characters, the error recognition system processes the error images and determines the errors, and the printing module is used to output the determination results, error images, error analysis, or error sets in paper form.

[0021] The beneficial effects of this invention are:

[0022] This invention finds the optimal consistency point in the opposite direction of the gradient for each pixel and obtains the edge saliency coefficient through local statistical normalization. This distinguishes isolated background texture points from real stroke edge points, thereby effectively suppressing the response of regular background noise such as exercise book grids, alleviating the problem of characters sticking to the background, and thus improving the accuracy of incorrect question recognition.

[0023] This invention utilizes optimized edge directions to perform weighted aggregation of pixels with consistent orientations along the edge tangent direction within a local window, generating an edge coherence coefficient. This coefficient characterizes whether a pixel is in a coherent structure with consistent orientation, elevating isolated points to edge segments. This enhances the processing of strokes that are weakly responsive due to light ink, suppresses isolated noise points with chaotic orientations, and obtains complete edges, thereby improving the robustness of error recognition.

[0024] This invention checks not only whether each point to be judged is an extremum in the normal direction, but more importantly, it checks whether there are enough support points in the tangential direction. This dual decision-making mechanism, combining normal extremum judgment and tangential structural support verification, intelligently preserves weak edge points that, while not having the largest amplitude, are supported by strong structures, thus effectively repairing stroke breaks. Simultaneously, it resolutely suppresses isolated noise points with high amplitude but lacking structural support. This ensures single-pixel width, high connectivity, and low noise in the output edges, thereby improving the accuracy and robustness of error recognition. Attached Figure Description

[0025] Figure 1 This is a flowchart of steps S1-S5 in an image recognition-based error identification method according to an embodiment of the present invention. Detailed Implementation

[0026] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments.

[0027] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0028] Reference Figure 1 A method for identifying incorrect questions based on image recognition includes steps S1-S5, as detailed below:

[0029] Step S1: Obtain the wrong question image containing handwritten characters, preprocess it, and calculate the gradient magnitude and gradient direction of the wrong question image.

[0030] The images of incorrect questions captured are greatly affected by environmental interference. The original color images not only have high data dimensionality and contain irrelevant color interference, but also suffer from local contrast imbalance due to uneven lighting. For example, the grayscale of the exercise book background in the shadow area may be close to or even higher than the grayscale of the handwritten strokes in the bright area. This local contrast reversal phenomenon will seriously destroy the image gradient, making all subsequent analyses based on grayscale or gradient unreliable. Therefore, it is necessary to preprocess the collected images of incorrect questions to eliminate the interference of color and lighting.

[0031] Collect images of incorrect questions, and convert the 3D color images of incorrect questions into 1D grayscale images. This method reduces data complexity while retaining key brightness contrast information. Image grayscale conversion is a well-known technique and will not be elaborated further.

[0032] Due to the problem of uneven illumination, a normalization method based on background estimation is used for correction. The image is modeled as the product of illumination and reflection components. Then, the gradient vector field of the corrected image is calculated to obtain the amplitude and direction information of each pixel in the grayscale image, which represents the local change information of the image.

[0033] In the illumination equalization process, a large-scale Gaussian filter is used. right Perform convolution to estimate the background illumination image: .here This represents the convolution operation. It is the Gaussian kernel standard deviation, which is used as a key hyperparameter to control the smoothness of the background.

[0034] In order to effectively cover typical low-frequency illumination variation areas in the image, The empirical value is set to one-twelfth of the pixel size of the shorter side of the image, that is... ,in It is the input image The length of the shorter side, of which one-twelfth is an empirical value, can be adjusted by the implementer according to the specific implementation scenario.

[0035] Through formula Calculate the illumination-normalized image, where x and y represent the horizontal and vertical coordinates of the same pixel in the background illumination image and grayscale image, respectively; where the scale constant C is preset to 255 to standardize the grayscale range of the output image, and ε is a very small constant set to prevent division by zero, preset to 1e-5. By calculating the illumination-normalized image, the illumination component is separated, and the image content represented by the reflection component is enhanced.

[0036] Illumination-normalized image Calculate the gradient field and use the Sobel operator to normalize the illumination image. Perform convolutions in the horizontal and vertical directions respectively to obtain the gradient components. and The Sobel operator is a well-known technique and will not be elaborated further.

[0037] Then, the gradient magnitude of each pixel is calculated. With gradient direction , The range of values ​​is This indicates the direction of the fastest increase in brightness for that pixel. In the illumination-corrected image, this applies to most stroke edge areas. It can roughly indicate the direction of the normal to the edge.

[0038] Step S2: Based on the gradient magnitude and gradient direction, perform pairwise pixel matching analysis and local statistical normalization in the local neighborhood of the pixel to construct the edge saliency coefficient that represents the degree of suspicion of the pixel as a stroke boundary.

[0039] Using gradient magnitude directly for stroke edge detection has significant drawbacks. Background textures such as grid lines on notebook paper can also generate high gradient responses, creating interference noise. Furthermore, the gradient intensity of handwritten stroke edges fluctuates greatly globally due to factors such as uneven writing pressure and ink bleeding, leading to stroke breaks or misidentification of background textures as strokes in the segmentation results.

[0040] Since a real handwritten stroke has a certain width, the gradient directions of its two edges should be roughly opposite and their magnitudes similar. For each pixel in the image, search for an optimal point of agreement in the opposite direction of its gradient.

[0041] By evaluating the cost functions of opposite direction, similar magnitude, and spatial proximity, we can obtain the probability that the current pixel is the boundary of a stroke on one side. That is, in the image corrected by step S1, the gradient direction of most real stroke edge points can approximately point to the normal direction, and thus its opposite direction roughly points to the other side of the stroke.

[0042] Illumination-normalized image Each target pixel in , with its coordinates Centered on, obtain the target pixel. Basic gradient direction Define a sector-shaped search region. The principal axis of this sector is . , indicating the opposite direction, search radius Based on the maximum physical width of common handwritten strokes, the empirical value is... Pixel; sector half-angle Preset To tolerate potential errors in gradient direction estimation, the search radius, sector half-angle, and search area can all be adjusted by the implementer according to the specific implementation scenario.

[0043] For each candidate pixel within the sector search area Calculate the directional consistency factor A, when When, it indicates that the directions are completely opposite. The directional consistency factor is 0. Therefore, the smaller the directional consistency factor value, the better the directional oppositeity. . Candidate pixels gradient direction, For target pixel The gradient direction.

[0044] And when candidate pixels With target pixel The smaller the relative difference in gradient magnitude, the more matched the edge strengths on both sides, indicating that they belong to the same stroke's boundary pixels and are candidate pixels. With target pixel The closer the better; therefore, candidate pixels are calculated. With target pixel Pairing cost score :

[0045]

[0046] In the formula, and These are the target pixels. With candidate pixels gradient magnitude, Candidate pixels With target pixel Euclidean distance between two points Candidate pixels With target pixel The directional consistency factor between two points It is an exponential function to prevent one of the terms from being 0, which would affect the calculation of the pairing cost score. ε is a very small constant set to prevent division by zero, with a default value of 1e-5.

[0047] The smaller the value, the better the direction opposition. In the cost function... middle, As an addend, the smaller its value, the smaller its contribution to the total cost, thus reducing the total cost. This increases the likelihood that the candidate point will become the best consensus point.

[0048] Represents candidate pixels With target pixel The relative difference in gradient magnitude, A smaller value indicates a closer match between the edge strengths on both sides. If the gradient strengths of the candidate point and the target point differ significantly—for example, one is a strong edge and the other is background—this factor will increase, thereby increasing the total cost and decreasing the matching probability. For one The value of .

[0049] Candidate pixels With target pixel The Euclidean distance is such that the greater the distance, the greater the penalty. This ensures that, given similar direction and magnitude conditions, closer points are prioritized. For the maximum width, therefore For one The value of .

[0050] Therefore, among all candidate points, the one that makes The point with the smallest value is taken as the optimal consensus point, and this minimum cost is denoted as... .

[0051] Calculate the initial edge likelihood of the target pixel. The smaller the value, the higher the pairing cost and the lower the probability of becoming a stroke edge, thus filtering out pixels with high edge salience.

[0052] Perform local statistical normalization on the target pixel: Define a sliding window of size L×L centered on the target pixel, and calculate the values ​​of all pixels within the window. mean of values and standard deviation Where L is an odd number, with an empirical value of 21. This size is sufficient to cover local background textures such as a single grid and can be adjusted by the implementer according to the specific implementation scenario.

[0053] Through formula Calculate the edge saliency coefficient of the target pixel so that the edge saliency coefficient value of the target pixel can suppress the uniform background and further enhance the salient edge.

[0054] Simultaneously, the gradient direction corresponding to the optimal consistency point is inverted and used as the edge direction estimate of the stroke after optimization at the current point. , Because of the pairing constraints, compared to the original gradient direction The direction of the normal lines is closer to the actual edge of the stroke.

[0055] Step S3: Based on the edge saliency coefficient, construct the edge coherence coefficient, which characterizes the structural coherence of edge segments, by calculating the directional consistency aggregation intensity within the local window.

[0056] Edge saliency coefficient of target pixel Although it can reflect the local saliency of pixels as edges, its essence is still based on the evaluation of a single point and its small neighborhood. It cannot make a judgment on the continuity of the stroke structure, which makes it easy to mistakenly retain isolated high-response noise points that occasionally appear, while weak connections in real strokes caused by light ink or low contrast are easily suppressed, thus destroying the integrity of real strokes.

[0057] For a continuous stroke, there should be a series of companion points with consistent orientation around the corresponding edge point along the edge tangent direction, where the edge tangent direction refers to the direction perpendicular to the optimized edge direction φ.

[0058] Since the orientation change of the real edge points is gradual within the local neighborhood, an anisotropic spatial aggregation window is constructed to give these peer points a higher weight, thereby aggregating the discrete, high-noise suspected point responses into responses to edge segments.

[0059] The edge saliency coefficient of each pixel is nonnegated to obtain the edge saliency coefficient composed of all edge pixels. The value of the edge saliency coefficient of the target pixel after nonnegation is _____. To avoid interference from negative values ​​in the aggregation, the nonnegation process involves taking the maximum value between the edge saliency coefficient of each pixel and the zero value.

[0060] For the target pixel , with its coordinates Define a dimension as the center point. Local aggregation window Calculate each neighboring point within the calculation window directional uniformity of polymerization strength at the center point ,in, Choose an odd number, with an empirical value of 5, to cover local edge structures. This can be adjusted by the implementer according to the specific implementation scenario.

[0061] Calculate target pixel With neighboring points The formula for calculating the directional consistency weight is as follows: ,in They are respectively and The optimization direction φ and γ are sharpening factors, which are preset to 2 and are used to enhance the influence of neighboring points with consistent orientation.

[0062] Calculate target pixel With neighboring points Spatial distribution weights, using an anisotropic Gaussian kernel:

[0063]

[0064] in, and They are vectors The projected lengths in the tangent and normal directions are constructed using a Gaussian kernel. The standard Gaussian kernel construction is a well-known technique and will not be elaborated further.

[0065] exist Establish a local coordinate system for the point:

[0066] Perpendicular to the stroke edge normal direction: unit vector ,in The optimized edge direction obtained in step S2 represents the normal direction of the edge.

[0067] Along the tangent direction of the stroke edge: unit vector It is perpendicular to the direction of the normal.

[0068] For vectors Calculate its projection: , ,in This represents the vector dot product operation.

[0069] and Control the decay rate of weights in the tangential and normal directions. Since edges typically extend continuously along the tangential direction but change drastically in the normal direction, a preset... , This forms a polymer nucleus that elongates along its edges, in which... , It can be adjusted by the implementer according to the specific implementation scenario.

[0070] Then, calculate the target pixel. directional consistency of polymerization strength ,in Represents the target pixel. In its local area The weights of directional consistency and anisotropic Gaussian kernel responses of all neighboring points are summed, and then weighted by adjusting the marginal significance coefficients of the neighboring points after nonnegation.

[0071] Therefore, the target pixel is calculated. Edge coherence coefficient The edge significance coefficient and uniform aggregation strength were obtained by uniformly fusing nonnegative processing. , making the target pixel The absence of either the edge significance coefficient or the uniformity aggregation strength will significantly reduce the response value, thus more rigorously screening out the true edge points that are both locally significant and in a coherent structure.

[0072] Step S4: Using the edge coherence coefficient and gradient direction, perform adaptive nonmaximum suppression based on the structural support of the pixel on the local edge ridge to generate a single-pixel wide binary edge image.

[0073] Obtain the target pixel point Edge coherence coefficient Subsequently, due to the high edge coherence coefficient of the pixels, the stroke edges of handwritten characters will appear as ridge-shaped high-response bands with a certain width.

[0074] When selecting edge points, non-maximum suppression only retains local maxima along the gradient normal direction. However, because the edge coherence coefficient enhances edge coherence through the aforementioned directional aggregation, the edge response band also possesses continuity information along its tangent direction, i.e., the ridge direction. If non-maximum suppression is used, it may suppress weak edge points that are not strictly maxima but lie on coherent ridges, causing breaks, while it may retain isolated high-response noise points.

[0075] True edges are continuous lines, while noise points are usually isolated or oriented randomly. A true edge pixel should not only appear as a local bulge in the intensity profile along the normal direction, but also have a sufficient number of companion points with consistent orientations as structural support along its tangent direction. Only points that simultaneously meet both conditions are ultimately determined to be edges.

[0076] To obtain the edge coherence coefficient for each pixel, an edge coherence coefficient feature map is constructed. Obtain the feature map of edge coherence coefficient. Decision points in Firstly, in its optimization direction The initial determination of extreme values ​​is performed, where the optimization direction is the normal direction.

[0077] exist In the direction indicated, the distance The forward point is obtained by bilinear interpolation at a precise location of 1 pixel. and backward point The edge coherence coefficient value is denoted as . and The current point value is Calculate traditional peak values. The process is as follows: If and ,but A value of 0 indicates a peak value, otherwise 0 indicates a non-peak value. The profile convexity is also calculated. It is used to quantify the degree of local prominence.

[0078] Define a The N×N local support window Ψ centered on the tangent direction is used to analyze the neighborhood and calculate the local structural support metric. N is an odd number, preset to 5, which can be adjusted by the implementer according to the specific implementation scenario.

[0079] Within the window Ψ, a single pixel regarded as The support points must satisfy their optimization direction. and High parallelism, i.e., the condition of directional consistency , This is the directional consistency threshold, preset to 0.9, which can be adjusted by the implementer according to the specific implementation scenario to ensure that the support point and the center point belong to the same edge segment, thereby counting the number of support points that meet the conditions in the window. And calculate the mean of the average edge coherence coefficient of these support points as the support strength. .

[0080] If point It is a strictly normal maximum point If a point has sufficient structural support, it is directly identified as an edge point. The point with the maximum normal value is... There is sufficient structural support for , The minimum structural support length threshold is preset to 3 based on the stroke continuity requirement, meaning that at least 3 pixels in the same direction are needed to form a short line segment.

[0081] If it is not a strictly maximum point, then the convexity must be positive at the same time. An edge point is determined only if it meets three conditions: sufficient support, and the average strength of the support points is not less than β times the strength of the center point. A non-strict maximum point represents... The convexity is positive. There is sufficient structural support for The average strength of the support points is not less than β times the strength of the center point. β is the weak connection tolerance coefficient, which is preset to 0.7. It can be adjusted by the implementer according to the specific implementation scenario, allowing the strength of the center point to be slightly lower than the average strength of its supporting partners, so as to preserve the edge points that are in the low strength trough but are still supported by the strong structure.

[0082] After traversing all pixels, the initial binary edge image can be obtained by determining and selecting the edge pixels. .

[0083] Step S5: Perform morphological processing and connected component analysis on the binary edge image to segment the character region, obtain the text through optical character recognition and compare it with the standard answer to determine whether it is an incorrect question and output the recognition result.

[0084] Binary image obtained after adaptive nonmaximum suppression It is a collection of lines that are a single pixel wide, but there may still be microscopic breaks caused by broken strokes in the original writing or noise interference. If these microscopic defects are not processed, they will incorrectly split a complete character into multiple fragments.

[0085] Since the goal is to identify incorrect answers, the process involves moving from the edge image to the character region and then to the recognized text. Therefore, it is necessary to solve the edge connectivity problem, connecting discrete edge points into a contour and filling it with a solid region that can be recognized by OCR.

[0086] For binary edge images Perform morphological closing operations to connect microscopic fractures: .in ⊖ and ⊖ represent expansion and erosion, respectively. B is the structuring element, which uses a 3×3 matrix of all 1s and can bridge breaks with a width of no more than 2 pixels. The structuring element can be adjusted by the implementer according to the specific implementation scenario.

[0087] However, Since it's still a line drawing, directly analyzing its connected components yields line regions, not character stroke regions that can be recognized by OCR. Therefore, contour finding and filling are used to convert the lines into filled regions.

[0088] Contour finding, a well-known technique in image processing, is used to... Extract all closed or nearly closed contours. For each found contour, fill its interior to generate a solid binary region mask. Contour finding is a well-known technique and will not be elaborated further.

[0089] Merge all filled regions to obtain a binary image representing the potential stroke regions of the character. .right Perform connected component analysis to obtain all connected regions. For each connected region Calculate its pixel area Height of the circumscribed rectangle and width .

[0090] Set filtering criteria to filter out obvious noise: If and If so, then that area will be retained as a candidate area for characters.

[0091] in, These are preset parameters, set based on prior knowledge of the dimensions and aspect ratios of common handwritten characters, for example... Used to remove extremely small noise. =2% of the total pixels in the image, used to filter out excessively large non-text areas. This is used to cover various character shapes, from tall and thin to wide and flat. These parameters can be adjusted by the implementer according to the specific implementation scenario.

[0092] Based on the bounding rectangle of each retained region, from the illumination-normalized image The corresponding grayscale image blocks are cropped out to form a character image sequence. Image cropping is a well-known technique and will not be described in detail here.

[0093] The character image sequence is input into a pre-trained optical character recognition model. The pre-trained optical character recognition model can be a pre-trained CRNN model. The pre-trained CRNN model is a well-known technique and will not be described in detail here.

[0094] The OCR model outputs the corresponding recognized text string. Simultaneously, the standard answer text for the current question is retrieved from a pre-set question-answer database. .

[0095] Calculate normalized edit distance similarity: ,in This indicates the calculation of the Levinstein edit distance. This indicates how to get the length of the text string. The maximum value between them is used for normalization of the Lewinstein edit distance.

[0096] The preset similarity threshold λ is set to an empirical value of 0.85, which can be adjusted by the implementer according to the specific implementation scenario. If the answer is incorrect, it is considered a wrong question, and the corresponding identifier and recognition result are output; otherwise, it is considered correct.

[0097] This invention also provides an image recognition-based error identification system. The system includes a processor and a memory, the memory storing computer program instructions. When the processor executes the computer program instructions, it implements an image recognition-based error identification method according to the first aspect of this invention. The system also includes other components well-known to those skilled in the art, such as a communication bus and a communication interface; their configuration and functions are known in the art and will not be described further here.

[0098] This invention also provides a smart printer with integrated error recognition functionality. The printer includes: an image acquisition module, such as a built-in camera or flatbed scanner, for capturing images of student assignments, test papers, etc., containing handwritten characters and containing errors; an error recognition system, built into the printer's main control chip, for performing image preprocessing, edge extraction, character segmentation, OCR recognition, and answer comparison; a printing module, such as a thermal printhead or inkjet printing mechanism, for outputting the recognized error content, corresponding standard answers, explanation text, or generated error notebook in paper form; a user interface, such as a touchscreen or a button-plus-display screen, for receiving user commands (such as "scan error questions," "print error notebook," "view error explanations," etc.) and providing feedback on the processing status; and a communication interface, such as a Wi-Fi or Bluetooth module, for synchronizing error data with a mobile app, cloud-based question bank, or teacher-side system.

[0099] Workflow Example: The user places the homework paper in the printer's scanning area and clicks the "Scan Wrong Questions" button. The printer acquires the image through its image acquisition module, and the built-in wrong question recognition system determines the wrong questions. If a question is identified as wrong, the system automatically retrieves the corresponding explanation from the local or cloud-based question bank, and integrates the original question image, the student's answer, and the correct answer with explanation into a single wrong question card, which is then printed. Users can also choose to generate "wrong question sets" in batches and print them with one click, achieving automatic collection and review of wrong questions. This implementation method deeply embeds the wrong question recognition algorithm into the printing device, forming an end-to-end closed loop for wrong question management. It does not rely on external terminal devices, improving ease of use and educational efficiency in home or classroom settings.

[0100] It should be noted that the preferred embodiments of the present invention have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present invention. For those skilled in the art, various modifications and improvements can be made without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this patent should be determined by the appended claims.

Claims

1. A method for identifying incorrect questions based on image recognition, characterized in that, Includes the following steps: Obtain images of incorrect questions containing handwritten characters and preprocess them, then calculate the gradient magnitude and gradient direction of the incorrect question images; Based on the gradient magnitude and gradient direction, pairwise pixel matching analysis is performed on each pixel in its local neighborhood, and after local statistical normalization, an edge saliency coefficient is constructed to characterize the degree of suspicion of the pixel as a stroke boundary, and the optimized edge direction is obtained at the same time. Based on the edge saliency coefficient and the optimized edge direction, the directional consistency aggregation intensity of each pixel point along the edge tangent direction within its local window is calculated, and then fused to obtain the edge coherence coefficient characterizing the structural coherence of the edge segment. Using the edge coherence coefficient and the optimized edge direction, and based on whether the pixel obtains sufficient directional consistency structural support on the local edge ridge, adaptive non-maximum suppression is performed to generate a single-pixel wide binary edge image. The binary edge image is subjected to morphological processing, connected component analysis and contour filling to segment the character region. The text is obtained by optical character recognition and compared with the standard answer to complete the judgment of incorrect questions.

2. The error identification method based on image recognition according to claim 1, characterized in that, The steps for calculating the gradient magnitude and gradient direction of the incorrect question image include: The gradient components are obtained by convolving the grayscale image after illumination equalization preprocessing using gradient operators in the horizontal and vertical directions. The gradient magnitude and gradient direction of each pixel are calculated based on the gradient components.

3. The error identification method based on image recognition according to claim 1, characterized in that, The steps of constructing an edge saliency coefficient that characterizes the degree of suspected stroke boundary of the pixel and obtaining the optimized edge direction include: Take any pixel in the incorrect question image as the target pixel. For the target pixel, calculate the pairing cost between each candidate pixel and the target pixel in the fan-shaped search region in the opposite direction of its gradient. The pairing cost is determined by the direction consistency factor, the relative difference ratio of gradient magnitude and the normalized Euclidean distance. The candidate pixel that minimizes the pairing cost is selected as the best consistency point, and the initial edge suspicion of the target pixel is calculated based on the minimum pairing cost. The initial edge likelihood is standardized using a local sliding window to obtain the edge significance coefficient. The gradient direction of the optimal consistency point is reversed and used as the optimized edge direction of the target pixel.

4. The error identification method based on image recognition according to claim 3, characterized in that, The step of calculating the directional consistency aggregation intensity of each pixel within its local window along the edge tangent direction, and then fusing them to obtain the edge coherence coefficient characterizing the structural coherence of the edge segment, includes: For each center pixel, in the local coordinate system defined by its optimized edge direction, the contribution weight of each neighboring point in the aggregation window to the center pixel is calculated. The contribution weight is obtained by multiplying the direction consistency weight and the anisotropic spatial distribution weight. The directional consistency aggregation strength is obtained by weighting the nonnegative edge significance coefficients of the neighboring points with the contribution weights. The geometric mean of the nonnegative edge saliency coefficient of the center pixel and the direction consistency aggregation intensity is calculated as the edge coherence coefficient.

5. The error identification method based on image recognition according to claim 4, characterized in that, The step of performing adaptive nonmaximum suppression includes: For each pixel to be decided, the peak value of the normal is determined in its optimized edge direction, and its normal profile convexity is calculated. Within the support window centered on the pixel to be decided, count the number of support points that are consistent with its edge direction, and calculate the average edge coherence coefficient of the support points. A minimum length threshold is preset. If the pixel to be decided is a normal peak point and the number of support points reaches the minimum length threshold, it is determined to be an edge point. If the pixel to be decided is not a non-directional peak point, but its normal profile convexity is positive, and the number of support points reaches the minimum length threshold, and the average edge coherence coefficient is not lower than the preset proportion of the edge coherence coefficient of the pixel to be decided, then it is determined to be an edge point; otherwise, the point is suppressed.

6. The method for identifying incorrect questions based on image recognition according to claim 5, characterized in that, When counting the number of support points, the method to determine whether the edge direction of the neighboring point is consistent with that of the pixel to be decided is as follows: calculate the absolute value of the cosine of the angle between the edge directions of the two points. If it is greater than the preset direction consistency threshold, it is determined to be consistent.

7. The method for identifying incorrect questions based on image recognition according to claim 1, characterized in that, The steps of segmenting the character region, obtaining the text through optical character recognition, and comparing it with the standard answer to complete the error judgment include: Perform morphological closing operations on binary edge images to connect micro-fractures; Find the contours in the processed image and fill them in to obtain a binary mask for the character stroke region; Connectivity analysis is performed on the binary mask to obtain multiple connected components. Character candidate regions are retained based on the area and aspect ratio thresholds of each connected component. The candidate character regions are input into a pre-trained optical character recognition model to obtain the recognized text. The text similarity between the candidate text and the corresponding standard answer is calculated, and the question is determined to be incorrect based on a preset similarity threshold.

8. The method for identifying incorrect questions based on image recognition according to claim 7, characterized in that, When filtering connected components, the upper limit of the area threshold is set according to the percentage of the total pixels in the image to filter out excessively large non-character regions.

9. A system for identifying incorrect answers, characterized in that: include: A processor and a memory, wherein the memory stores computer program instructions that, when executed by the processor, implement an image recognition-based error identification method according to any one of claims 1-8.

10. A printer, characterized in that, The system integrates the error recognition system as described in claim 9, and includes an image acquisition module, a printing module, and a user interface; the image acquisition module is used to acquire error images containing handwritten characters, the error recognition system processes the error images and determines the errors, and the printing module is used to output the determination results, error images, error analysis, or error sets in paper form.