Image enhancement method, device, equipment and medium for OCR system
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-15
- Publication Date
- 2026-08-11
AI Technical Summary
[0006]针对现有技术中光学字符识别技术常因待识别图像存在模糊、噪声或光照不均等退化现象导致识别精度下降,传统图像增强方法直接对退化图像进行修复,但容易引入伪影或受限于特定退化类型,难以适应复杂多变的真实场景的问题,本发明提出一种用于OCR系统的图像增强方法,包括:
其一,通过提取待识别图像的退化特征,生成退化描述信息,通过退化描述信息对预设文字模板进行增强处理,生成多个退化版本的预设文字模板,从而构成目标文字模板集合,最终通过待识别图像与目标文字模板集合的匹配过程实现高精度的字符识别,该方法能够自适应各种退化场景,提高OCR系统的鲁棒性和准确性;
Smart Images

Figure CN122023190B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of optical character recognition technology, and in particular to image enhancement methods, apparatus, devices and media for OCR systems. Background Technology
[0002] Optical character recognition (OCR) technology, as the core bridge connecting physical text and digital information, has been widely used in many fields such as document digitization, smart office, autonomous driving, and mobile payment verification.
[0003] In practical applications, the recognition accuracy of OCR systems is highly dependent on the quality of the image to be recognized. However, due to various factors such as shooting environment (low light, backlight, shaky images), hardware limitations (insufficient camera resolution, lens smudges), and the condition of the text carrier (aging paper documents, blurred printing, stains), the images to be recognized often exhibit varying degrees of degradation. These degradation features directly damage the original structure and visual recognizability of the text, making it difficult for traditional OCR systems to accurately extract text features, thus leading to problems such as misrecognition and missed character recognition.
[0004] Currently, the common approach is to use image enhancement technology to preprocess the image to be recognized in order to improve image quality and facilitate subsequent character recognition. When processing low-quality text images, existing technologies often use direct enhancement of the image to be recognized. This approach has two key drawbacks: firstly, direct enhancement of severely degraded images may lead to irreversible loss of the original text features; secondly, the enhancement process is difficult to maintain visual consistency between different characters, which can easily cause confusion between similar characters. These problems severely restrict the recognition accuracy and robustness of OCR systems in complex real-world scenarios.
[0005] To address the aforementioned issues, existing technologies urgently need improvement. Summary of the Invention
[0006] To address the issue that existing optical character recognition technologies often suffer from decreased recognition accuracy due to degradation phenomena such as blurring, noise, or uneven lighting in the image to be recognized, traditional image enhancement methods directly repair degraded images. However, these methods are prone to introducing artifacts or are limited to specific degradation types, making them unsuitable for complex and varied real-world scenarios. This invention proposes an image enhancement method for OCR systems, comprising: Acquire the image to be recognized; If the clarity of the image to be identified does not meet the preset conditions, the degradation features in the image to be identified are extracted, and degradation description information is generated based on the degradation features. The preset text templates are enhanced based on the degradation description information to obtain a set of target text templates that match the visual characteristics of the image to be recognized. The image to be recognized is matched with the set of target text templates to complete optical character recognition.
[0007] Furthermore, if the clarity of the image to be identified meets a preset condition, the method further includes: The image to be identified is preprocessed to obtain the processed image to be identified; The preprocessing includes cropping invalid blank areas, tilt correction, contrast enhancement, and resolution adjustment of the image to be recognized.
[0008] Furthermore, the image to be identified does not meet the preset clarity conditions, including: Calculate the global or local sharpness index of the image to be identified; if the sharpness index is lower than a preset threshold, determine that the sharpness of the image to be identified does not meet the preset condition; and / or, The image to be identified is scored using a pre-trained image quality assessment model. If the score is lower than a preset score threshold, the image's clarity is determined to be unsatisfactory; and / or, A preliminary character recognition is performed on the image to be recognized to obtain a recognition confidence level. If the recognition confidence level is lower than a preset confidence threshold, it is determined that the clarity of the image to be recognized does not meet the preset conditions.
[0009] Furthermore, the degradation description information includes blur parameters, noise parameters, and illumination parameters. The enhancement processing of the preset text template based on the degradation description information includes at least one of the following operations: The preset text template is blurred based on the blur parameters; Noise is added to the preset text template based on the noise parameters; The preset text template is subjected to lighting simulation processing based on the lighting parameters.
[0010] Furthermore, matching the image to be identified with the target text template set includes: The text lines in the image to be identified are segmented to obtain multiple character fragments; Construct a multidimensional constraint field, which includes a geometric constraint field for constraining the spatial position of characters and a semantic constraint field for constraining the rationality of character sequences; Under the combined effect of the multidimensional constraint field, the character fragments are optimized and combined in position; In the process of position optimization and combination, the character fragments or candidate regions of characters composed of fragments are matched with the target text template set, and the confidence of the matched character categories is fed back to the multidimensional constraint field to collaboratively optimize the process of position optimization and combination.
[0011] Furthermore, matching the character fragments or candidate regions composed of fragments with the target text template set includes: During the iterative process of position optimization, based on the current geometric state of the character fragment, the system queries the target text template set for the character category and corresponding confidence level that match the character fragment. The probability that the current character fragment sequence constitutes semantically reasonable text is calculated based on the semantic constraint field and the confidence level.
[0012] Furthermore, the geometric constraint field is constructed based on at least one of the following typographic priors: character spacing, baseline alignment, and character size consistency. The semantic constraint field is constructed based on at least one language model among n-gram statistics, word frequency, and neural network language models.
[0013] An image enhancement method apparatus for an OCR system, the apparatus employing an image enhancement method for an OCR system as described in any of the preceding claims, specifically comprising the following modules: The acquisition module is used to acquire the image to be recognized; An extraction module, connected to the acquisition module, is used to extract degradation features from the image to be identified when the clarity of the image to be identified does not meet a preset condition, and to generate degradation description information based on the degradation features; The processing module, connected to the extraction module, is used to enhance the preset text templates based on the degradation description information to obtain a set of target text templates that match the visual characteristics of the image to be recognized. The matching module, connected to the processing module and the acquisition module, is used to match the image to be recognized with a set of target text templates to complete optical character recognition.
[0014] An electronic device, characterized in that the device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, it implements an image enhancement method for an OCR system as described in any of the preceding claims.
[0015] A computer-readable storage medium, characterized in that the computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement an image enhancement method for an OCR system as described in any of the preceding claims.
[0016] Compared with the prior art, the beneficial effects of the present invention are as follows: Firstly, by extracting degradation features from the image to be recognized, degradation description information is generated. The degradation description information is then used to enhance the preset text template, generating multiple degradation versions of the preset text template, thus forming a target text template set. Finally, high-precision character recognition is achieved through the matching process between the image to be recognized and the target text template set. This method can adapt to various degradation scenarios and improve the robustness and accuracy of the OCR system. Secondly, by using degenerate description information, it is possible to accurately simulate the visual degradation of the image to be recognized and generate a highly matching target text template. This avoids the additional distortion that may be introduced by directly enhancing the image to be recognized, and ensures the consistency between the target text template and the image to be recognized, thereby reducing character misrecognition. Third, by combining spatial layout and semantic information through a multi-dimensional constraint field, the accuracy of character positioning and sequence combination is improved. The confidence feedback mechanism enables the recognition process to be dynamically adjusted, reducing missed or false recognitions caused by incomplete or blurred fragments. Attached Figure Description
[0017] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0018] Figure 1 This is a flowchart illustrating an image enhancement method for an OCR system in Embodiment 1 of this application; Figure 2 This is a structural block diagram illustrating an image enhancement device for an OCR system in Embodiment 2 of this application; Figure 3 This is a structural block diagram illustrating an electronic device in Embodiment 3 of this application. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0020] The specific embodiments of the present invention will be described below.
[0021] In existing optical character recognition (OCR) technologies, the accuracy often declines due to degradation phenomena such as blurring, noise, or uneven lighting in the image to be recognized. Traditional image enhancement methods directly repair degraded images, but these methods are prone to introducing artifacts or are limited by specific degradation types, making them difficult to adapt to complex and varied real-world scenarios. For example, in the digitization of old documents, the combined effects of yellowing paper, ink diffusion, and scanner jitter create a complex degradation that existing methods often cannot effectively restore text edge features. This invention extracts the degradation features of the image to be recognized, generates degradation description information, and enhances a preset text template based on this description information. This generates a set of target text templates that match the visual characteristics of the image to be recognized. Finally, high-precision character recognition is achieved through the matching process between the image to be recognized and the target text templates. This method can adapt to various degradation scenarios, thereby improving the robustness and accuracy of the OCR system.
[0022] Example 1 like Figure 1 As shown, this invention proposes an image enhancement method for an OCR system, comprising: Step S1: Obtain the image to be recognized.
[0023] In this embodiment, staff members use an image acquisition device to photograph or scan the target document to obtain an image of the target document to be identified. The image acquisition device can be a digital camera, scanner, or mobile phone. The target document can be a hospital's paper medical document, various paper medical reports, or other documents that need to be converted from paper documents to electronic documents. In this embodiment, no specific limitation is made.
[0024] After acquiring the image to be recognized, a sharpness test is performed on the image to determine the subsequent processing method.
[0025] Step S2: If the clarity of the image to be identified does not meet the preset conditions, extract the degradation features in the image to be identified, and generate degradation description information based on the degradation features.
[0026] In this embodiment, the determination method for when the sharpness does not meet the preset conditions and the preprocessing operation when the sharpness meets the preset conditions are explained respectively.
[0027] (i) Clarity does not meet preset conditions Specifically, the global or local sharpness index of the image to be identified is calculated. If the sharpness index is lower than a preset index threshold, the image to be identified is determined to have a sharpness that does not meet the preset conditions. And / or, the image to be identified is scored using a pre-trained image quality assessment model. If the score is lower than a preset scoring threshold, the image to be identified is determined to have a sharpness that does not meet the preset conditions. And / or, preliminary character recognition is performed on the image to be identified to obtain a recognition confidence score. If the recognition confidence score is lower than a preset confidence score threshold, the image to be identified is determined to have a sharpness that does not meet the preset conditions.
[0028] The global sharpness index can be calculated using the average gradient energy of the entire image, while the local sharpness index can be obtained through block processing. For example, the image can be divided into multiple regions, the gradient energy of each region can be calculated, and the lowest value can be taken as the representative. The preset index threshold can be set based on historical data or experimental calibration. For example, the gradient energy threshold can be set to 0.1. The trained image quality assessment model scores the image to be recognized. If the score is lower than the preset score threshold, the sharpness of the image to be recognized is determined to be insufficient. The image quality assessment model can use a convolutional neural network (CNN) combined with a regression layer structure. For example, VGG or ResNet can be used as the backbone network and trained on a large image quality dataset to output a quality score, such as a value between 0 and 1. The preset score threshold can be set to 0.7. If it is lower than 0.7, the image quality is considered insufficient. The initial character recognition can use a lightweight OCR model, such as the basic mode of Tesseract OCR. The recognition confidence can be calculated by the output probability or posterior probability of the classifier. The preset confidence threshold can be set to 0.7.
[0029] Among them, the above three judgment methods can be used independently or in combination to form a multi-dimensional quality assessment system. For example, a logical rule can be set: if any two methods are judged as not satisfying, then the degradation feature extraction in step S2 is executed.
[0030] In this embodiment, when the clarity of the image to be identified does not meet the preset conditions, it proves that the degradation degree of the image to be identified has exceeded the range of conventional processing. Degradation features are extracted from the image to be identified, and degradation description information is generated. Degradation features include, but are not limited to, blurring, noise, and uneven illumination. The specific extraction method is as follows: Blur parameter extraction: The degree of blur is quantified by analyzing the point spread function (PSF) or frequency domain features of the image to be identified. For example, the radius of the Gaussian blur kernel can be estimated using a blind deconvolution algorithm, or the blur parameters can be obtained by calculating the attenuation slope of the power spectrum of the image to be identified. The blur parameters can be expressed as the radius of the Gaussian kernel, and the value range can be 0.5-5.0 pixels.
[0031] Noise parameter extraction: The noise type and intensity are determined by noise estimation algorithms, such as wavelet transform or block variance analysis; for example, for Gaussian noise, the noise variance is extracted; for salt-and-pepper noise, the noise density is extracted. The noise parameter can be expressed as variance value or density value.
[0032] Illumination parameter extraction: By analyzing the brightness distribution of the image to be identified, such as histogram analysis or Retinex algorithm to characterize the illumination conditions, for example, calculating the overall average brightness and contrast index of the image to be identified, or detecting the gradient change pattern of the shadow area, the illumination parameters can be expressed as brightness adjustment coefficients or shadow gradient directions.
[0033] Based on the extracted degradation features, degradation description information is generated, which includes the specific values and types of fuzzy parameters, noise parameters, and illumination parameters.
[0034] (ii) Situation where the clarity meets the preset conditions Specifically, the image to be identified is preprocessed to obtain a processed image to be identified; wherein, the preprocessing includes cropping invalid blank areas, tilt correction, contrast enhancement, and resolution adjustment of the image to be identified.
[0035] The process includes several key steps: **Invalid blank area cropping:** **Removing blank areas without text information from an image by detecting image edges or text region boundaries.** This can be achieved using edge detection algorithms combined with connected component analysis to reduce redundant information in the image and lower the computational complexity of subsequent processing. **Tilt correction:** **Detecting the tilt angle of text lines and rotating the image to restore horizontal alignment.** This can be achieved using Hough transform or projection analysis algorithms to eliminate text tilt caused by shooting angle deviations. **Contrast enhancement:** **Adjusting the brightness difference between the foreground and background in the image to improve the recognizability of text edges.** This can be achieved using histogram equalization or adaptive gamma correction algorithms to improve the distinction between text and background in low-contrast environments. **Resolution adjustment:** **Scaling the image to the pixel size required by the OCR model.** This can be achieved using bilinear interpolation or deep learning-based super-resolution reconstruction methods to adapt to different resolution input images and ensure compatibility with the recognition model.
[0036] In this embodiment, when the sharpness index of the image to be recognized meets the preset conditions, the effective text region is first located by edge detection and connected component analysis and the surrounding blank area is cropped to eliminate irrelevant background interference. Then, the Hough transform is used to detect the tilt angle of the text line, and the image is rotated and corrected by affine transformation. Then, the histogram equalization algorithm is applied to enhance the contrast between the text and the background. Finally, the image is scaled according to the preset model input size.
[0037] It should be noted that the preprocessing steps can be performed in a fixed order, such as cropping first, then correction, then enhancement and adjustment, or they can be adaptively selected according to the characteristics of the image to be processed. Quality verification can also be performed after preprocessing to ensure that the quality of the image to be processed meets the OCR input standard.
[0038] Step S3: Enhance the preset text template based on the degradation description information to obtain a set of target text templates that match the visual characteristics of the image to be recognized.
[0039] Step S3 specifically includes: the degradation description information includes blur parameters, noise parameters, and illumination parameters; the enhancement processing of the preset text template based on the degradation description information includes at least one of the following operations: blurring the preset text template based on the blur parameters; adding noise to the preset text template based on the noise parameters; and performing illumination simulation processing on the preset text template based on the illumination parameters.
[0040] In this embodiment, after determining that the image to be recognized has degradation features, a clear preset text template is processed using extracted blur parameters, noise parameters, and illumination parameters. For example, based on the Gaussian kernel radius value in the blur parameters, the preset text template is blurred to the same degree; based on the variance value in the noise parameters, Gaussian noise conforming to the intensity distribution is added to the preset text template; based on the brightness coefficient in the illumination parameters, the overall brightness of the preset text template is adjusted or a gradient shadow effect is generated. The preset text templates after the above operations constitute a target text template set, wherein the visual characteristics of the target text templates match the degradation features of the image to be recognized, which facilitates improving the accuracy of character recognition in the subsequent target text template set matching stage.
[0041] Among them, the preset text template is a library of clean and standard character images storing various fonts and sizes. The preset text template can be determined according to the field corresponding to the image to be recognized. For the medical field, the preset text templates include, but are not limited to, standard fonts, handwritten fonts, commonly used character combinations for prescription abbreviations, and high-frequency characters in drug names. Special optimizations are made for easily confused characters, such as q and 9, U and μ, for example, by adding template variations or feature annotations. Standard fonts include, but are not limited to, Song and Hei fonts; commonly used character combinations for prescription abbreviations include bid and tid; and high-frequency characters in drug names include ammonia and phenol. For the education field, the preset text templates include printed fonts, various handwritten fonts, mathematical symbols, and common formula structures. Common formula structures include, but are not limited to, integral symbols and fractional forms.
[0042] In this embodiment, multiple degraded versions of the preset text template are generated by enhancing the preset text template, thereby forming a target text template set. The target text templates in the target text template set have a high degree of matching with the image to be recognized in terms of visual characteristics, thereby improving the robustness of subsequent matching. The enhancement process of the preset text template can be performed in batches, and a caching mechanism is used to store commonly used template sets to improve processing efficiency.
[0043] Step S4: Match the image to be recognized with the target text template set to complete optical character recognition.
[0044] Step S4 specifically includes: segmenting the text lines in the image to be identified to obtain multiple character fragments; constructing a multidimensional constraint field, which includes a geometric constraint field for constraining the spatial position of characters and a semantic constraint field for constraining the rationality of character sequences; optimizing and combining the positions of the character fragments under the combined action of the multidimensional constraint field; wherein, in the process of optimizing and combining the positions, the character fragments or the candidate regions of characters composed of fragments are matched with the target text template set, and the confidence of the matched character categories is fed back to the multidimensional constraint field to collaboratively optimize the process of optimizing and combining the positions.
[0045] The step of matching the character fragments or the candidate character regions composed of fragments with the target text template set includes: during the iterative process of position optimization, querying the target text template set for character categories and corresponding confidence levels that match the character fragments based on the current geometric state of the character fragments; and calculating the probability that the current character fragment sequence constitutes semantically reasonable text based on the semantic constraint field and the confidence level.
[0046] The geometric constraint field is constructed based on at least one of the following typographic priors: character spacing, baseline alignment, and character size consistency; the semantic constraint field is constructed based on at least one of the following language models: n-gram statistics, word frequency, and neural network language models.
[0047] Character fragments are individual characters or character components separated from text lines using image segmentation techniques. Segmentation methods can include edge detection combined with connected component analysis or projection segmentation. For low-quality images, character fragments may include broken or overlapping characters, so the segmentation algorithm needs to be fault-tolerant, for example, by using a deep learning-based segmentation network, such as U-Net. The geometric constraint field is constructed based on character typography priors and includes character spacing, baseline alignment, and character size consistency. Character spacing can be determined using character spacing statistics, baseline alignment can be determined using text line bottom alignment detection, and character size consistency can be determined using height and width variance constraints.
[0048] The semantic constraint field is constructed based on a language model, which includes, but is not limited to, n-gram statistics, word frequency, and neural network language models. The semantic constraint field is used to evaluate the probability that a character sequence constitutes a reasonable text. Position optimization and combination are performed on character fragments under the combined effect of the multi-dimensional constraint field. The position optimization and combination process is implemented through optimization algorithms, including but not limited to dynamic programming, greedy algorithms, and genetic algorithms. The objective function is to maximize the weighted sum of geometric constraints and semantic constraints. During the iteration process, character fragments or candidate regions composed of fragments are matched with the target text template set, and the matching confidence is calculated.
[0049] For matching character fragments or candidate regions of characters composed of fragments with a set of target text templates: use image matching algorithms to calculate the similarity between character fragments and target text templates to obtain the confidence of character categories. Among them, image matching algorithms include, but are not limited to, normalized cross-correlation matching, feature point matching, and deep learning feature matching. The confidence can be set to a probability value between 0 and 1.
[0050] For confidence feedback: the confidence obtained from the matching is fed back to the multidimensional constraint field, and the constraint weights are dynamically adjusted. For example, when the matching confidence of a certain character fragment is high, the semantic constraint field can relax the pairing restrictions of adjacent characters; when the confidence is low, the geometric constraint field strengthens the requirements for character alignment accuracy. Through multiple rounds of iterative optimization, the final character sequence is obtained, thereby completing optical character recognition.
[0051] In this embodiment, the position optimization and combination process is described as follows: For example, a word in the image to be identified is segmented into a fragment sequence due to noise interference: H, e, |, -, *, o. The geometric constraint field, based on baseline alignment and character size consistency, finds that the bottom position of fragment * is abnormal and the size is inconsistent, so its weight is reduced; the semantic constraint field, based on the n-gram model, evaluates the probability of Hello to be higher than Hel-*o. Through target text template matching, fragments "|" and "-" have a high confidence in matching the target text template "l", so they are merged into "l", and the final output is "Hello".
[0052] Example 2 like Figure 2 As shown, the present invention also proposes an image enhancement device for an OCR system, using an image enhancement method for an OCR system as described in any one of Embodiment 1, comprising the following modules: The acquisition module is used to acquire the image to be recognized; An extraction module, connected to the acquisition module, is used to extract degradation features from the image to be identified when the clarity of the image to be identified does not meet a preset condition, and to generate degradation description information based on the degradation features; The processing module, connected to the extraction module, is used to enhance the preset text templates based on the degradation description information to obtain a set of target text templates that match the visual characteristics of the image to be recognized. The matching module, connected to the processing module and the acquisition module, is used to match the image to be recognized with a set of target text templates to complete optical character recognition.
[0053] This invention addresses the issue of decreased recognition accuracy in optical character recognition (OCR) technology due to degradation phenomena such as blurring, noise, or uneven lighting in the image to be recognized. Traditional image enhancement methods directly repair degraded images, but these methods are prone to introducing artifacts or are limited by specific degradation types, making them difficult to adapt to complex and varied real-world scenarios. Existing methods often fail to effectively restore text edge features. This invention extracts degradation features from the image to be recognized, generates degradation description information, and enhances preset text templates based on this description information to generate a set of target text templates that match the visual characteristics of the image to be recognized. Finally, high-precision character recognition is achieved through the matching process between the image to be recognized and the target text templates. This method can adapt to various degradation scenarios, thereby improving the robustness and accuracy of the OCR system.
[0054] Example 3 Figure 3 This is a structural block diagram of an electronic device provided in an embodiment of this application. Figure 3 As shown, the electronic device includes a memory, a processor, and a communication bus; the memory and the processor are connected via the communication bus. The memory stores an image enhancement method for an OCR system, which can be loaded and executed by the processor, as provided in the above embodiments.
[0055] The memory can be used to store instructions, programs, code, code sets, or instruction sets. The memory 301 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for at least one function, and instructions for implementing an image enhancement method for an OCR system provided in the above embodiments. The data storage area may store data involved in the image enhancement method for an OCR system provided in the above embodiments.
[0056] The processor may include one or more processing cores. The processor executes instructions, programs, code sets, or instruction sets stored in memory, and calls data stored in memory to perform various functions and process data as described in this application. The processor may be at least one of the following: Application-Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Digital Signal Processing Device (DSPD), Programmable Logic Device (PLD), Field Programmable Gate Array (FPGA), Central Processing Unit (CPU), controller, microcontroller, and microprocessor. It is understood that, for different devices, the electronic devices used to implement the above-described processor functions may also be other types, and the embodiments of this application do not specifically limit this.
[0057] A communication bus can include a pathway for transmitting information between the aforementioned components. The communication bus can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Communication buses can be categorized into address buses, data buses, control buses, etc. For ease of representation, Figure 3 The symbol is represented by a single double arrow, but this does not mean that there is only one bus or one type of bus.
[0058] Example 4 This application provides a computer-readable storage medium storing a computer program that can be loaded by a processor and executed as described in the above embodiments, an image enhancement method for an OCR system.
[0059] In this embodiment, the computer-readable storage medium can be a tangible device that holds and stores instructions used by an instruction execution device. The computer-readable storage medium can be, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any combination thereof. Specifically, the computer-readable storage medium can be a portable computer disk, a hard disk, a USB flash drive, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), staging random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory stick, floppy disk, optical disk, magnetic disk, mechanical encoding device, or any combination thereof.
[0060] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the technical solutions of the embodiments of the present invention.
Claims
1. An image enhancement method for an OCR system, characterized in that, include: Acquire the image to be recognized; If the clarity of the image to be identified does not meet the preset conditions, the degradation features in the image to be identified are extracted, and degradation description information is generated based on the degradation features. The preset text templates are enhanced based on the degradation description information to obtain a set of target text templates that match the visual characteristics of the image to be recognized. The image to be recognized is matched with a set of target text templates to complete optical character recognition; The step of matching the image to be identified with the target text template set includes: The text lines in the image to be identified are segmented to obtain multiple character fragments; Construct a multidimensional constraint field, which includes a geometric constraint field for constraining the spatial position of characters and a semantic constraint field for constraining the rationality of character sequences; Under the combined effect of the multidimensional constraint field, the character fragments are optimized and combined in position; In the process of position optimization and combination, the character fragments or candidate regions of characters composed of fragments are matched with the target text template set, and the confidence of the matched character categories is fed back to the multidimensional constraint field to collaboratively optimize the process of position optimization and combination. The step of matching the character fragments or candidate regions of characters composed of fragments with the target text template set includes: During the iterative process of position optimization, based on the current geometric state of the character fragment, the system queries the target text template set for the character category and corresponding confidence level that match the character fragment. The probability that the current character fragment sequence constitutes semantically reasonable text is calculated based on the semantic constraint field and the confidence level.
2. The image enhancement method for an OCR system according to claim 1, characterized in that, If the clarity of the image to be identified meets a preset condition, the method further includes: The image to be identified is preprocessed to obtain the processed image to be identified; The preprocessing includes cropping invalid blank areas, tilt correction, contrast enhancement, and resolution adjustment of the image to be recognized.
3. The image enhancement method for an OCR system according to claim 1, characterized in that, The image to be identified does not meet the preset clarity conditions, including: Calculate the global or local sharpness index of the image to be identified; if the sharpness index is lower than a preset threshold, determine that the sharpness of the image to be identified does not meet the preset condition; and / or, The image to be identified is scored using a pre-trained image quality assessment model. If the score is lower than a preset score threshold, the image's clarity is determined to be unsatisfactory; and / or, A preliminary character recognition is performed on the image to be recognized to obtain a recognition confidence level. If the recognition confidence level is lower than a preset confidence threshold, it is determined that the clarity of the image to be recognized does not meet the preset conditions.
4. The image enhancement method for an OCR system according to claim 1, characterized in that, The degradation description information includes blur parameters, noise parameters, and illumination parameters. The enhancement processing of the preset text template based on the degradation description information includes at least one of the following operations: The preset text template is blurred based on the blur parameters; Noise is added to the preset text template based on the noise parameters; The preset text template is subjected to lighting simulation processing based on the lighting parameters.
5. The image enhancement method for an OCR system according to claim 1, characterized in that, The geometric constraint field is constructed based on at least one of the typographic priors of character spacing, baseline alignment, and character size consistency. The semantic constraint field is constructed based on at least one language model among n-gram statistics, word frequency, and neural network language models.
6. An image enhancement device for an OCR system, characterized in that, The device employs an image enhancement method for an OCR system as described in any one of claims 1 to 5, specifically comprising the following modules: The acquisition module is used to acquire the image to be recognized; An extraction module, connected to the acquisition module, is used to extract degradation features from the image to be identified when the clarity of the image to be identified does not meet a preset condition, and to generate degradation description information based on the degradation features; The processing module, connected to the extraction module, is used to enhance the preset text templates based on the degradation description information to obtain a set of target text templates that match the visual characteristics of the image to be recognized. The matching module, connected to the processing module and the acquisition module, is used to match the image to be recognized with a set of target text templates to complete optical character recognition; The step of matching the image to be identified with the target text template set includes: The text lines in the image to be identified are segmented to obtain multiple character fragments; Construct a multidimensional constraint field, which includes a geometric constraint field for constraining the spatial position of characters and a semantic constraint field for constraining the rationality of character sequences; Under the combined effect of the multidimensional constraint field, the character fragments are optimized and combined in position; In the process of position optimization and combination, the character fragments or candidate regions of characters composed of fragments are matched with the target text template set, and the confidence of the matched character categories is fed back to the multidimensional constraint field to collaboratively optimize the process of position optimization and combination. The step of matching the character fragments or candidate regions of characters composed of fragments with the target text template set includes: During the iterative process of position optimization, based on the current geometric state of the character fragment, the system queries the target text template set for the character category and corresponding confidence level that match the character fragment. The probability that the current character fragment sequence constitutes semantically reasonable text is calculated based on the semantic constraint field and the confidence level.
7. An electronic device, characterized in that, The device includes: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, it implements an image enhancement method for an OCR system as described in any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement an image enhancement method for an OCR system as described in any one of claims 1-5.
Citation Information
Patent Citations
Handwritten mathematical formula offline identification method and system
CN107729865A
OCR character recognition method and system based on end-to-end network
CN121053512A