Picture enhancement method and device for format document, equipment and medium
By initializing and segmenting the pictures of the layout document, combined with local enhancement strategies and enhanced parameter optimization, the problem of unclear text in blurred pictures is solved, and efficient picture enhancement and OCR recognition effects are achieved.
Patent Information
- Application Number
- CN202411339767.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-02-25
AI Technical Summary
The prior art has difficulty in effectively handling fuzzy pictures, especially in PDF and CAJ literature, resulting in difficulties in reading and OCR recognition.
By initializing the original image of the layout document, a binary image is obtained, and then a preset segmentation algorithm is used to determine the table area and text area. For different regions, local enhancement strategies based on content and enhanced parameter optimization strategies based on geometric features are used for enhancement, and finally denoising is performed to output enhancement renderings.
It realizes clarity of text data in blurred pictures, improves the readability of pictures, and achieves better results in OCR recognition, while maintaining the comfortable view of the overall image.
Smart Images

Figure CN119515725A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of document processing technology, and in particular to a method and device, equipment and medium for enhancing images of layout documents. Background Art
[0002] With the continuous development of Internet technology, PDF (Portable Document Format) and CAJ (an electronic document format, mainly used to store and display the electronic version of Chinese academic journals) are being used in various professional documents, work materials, archived materials, etc. in more and more industries and fields, and the number of related resources in PDF and CAJ formats has increased dramatically. As a result, the content types of documents in different fields are diverse, the layouts are complex, and the sources of generation and processing are complex, which leads to the problem of blurred scanned file content or blurred images in documents, which is common in PDF and CAJ documents, causing great trouble to readers.
[0003] With the continuous development of information technology, various image processing technologies are also constantly developing and iterating. Various readers on the market have also added image processing functions to their products to a greater or lesser extent, allowing users to easily and smoothly read some complex layouts of content. OCR (Optical Character Recognition) technology is a typical representative of this. Through OCR technology, the text can be corrected and rearranged, and the blurred scanned documents can be made clearer, from unreadable to readable. However, this technology is often only used in scanned files; for non-scanned files, OCR technology is often used to only provide the function of extracting text in the image, and there is no processing for the blurred image itself. And OCR often only has a good recognition accuracy rate for relatively clear text images. This can certainly solve most problems, but it also has its limitations and inappropriateness. When the user wants to read the original image in the document, or save the image for other purposes, the image is still blurred and not suitable for reading. Therefore, how to make the text in the blurred image clear so that it is suitable for readers to read or used as the original image for OCR recognition has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] In view of the above problems, the present application is proposed to provide a method, device, equipment and medium for enhancing images of layout documents that overcome the above problems or at least partially solve the above problems. The technical solution is as follows:
[0005] In a first aspect, a method for enhancing an image in a layout document is provided, comprising:
[0006] Initialize the original image of the layout document to obtain a binary image of the original image;
[0007] Using a preset segmentation algorithm to determine the table area and text area of the binary image;
[0008] For the table area, a local enhancement strategy based on the table content is used to locally enhance the table area;
[0009] For text regions, a local enhancement strategy based on text content is used to enhance the text region locally, and an enhancement parameter optimization strategy based on text geometric features is used to enhance the text region.
[0010] After enhancing the table area and the text area, the enhanced image is denoised to output an enhanced effect image.
[0011] In a possible implementation, the initialization process includes gray-scaling and binarization.
[0012] In a possible implementation, the preset segmentation algorithm includes a preset edge detection algorithm, a projection algorithm, and a transformation algorithm; using the preset segmentation algorithm to determine the table area and the text area of the binary image includes:
[0013] Use the preset edge detection algorithm to identify the edges in the binary image and highlight the boundaries in the binary image by detecting gradient changes;
[0014] Visualize the cumulative distribution of pixels in the binary image by performing horizontal and vertical projections through a preset projection algorithm, thereby distinguishing table columns and text rows;
[0015] A preset transformation algorithm is used to detect the straight line structure in the binary image, thereby obtaining the table area and text area of the binary image.
[0016] In a possible implementation, for a table area, a local enhancement strategy based on table content is adopted to locally enhance the table area, including:
[0017] For the table area, use the preset enhanced edge filter to extract the edge information of the table area, and then superimpose it with the original image to enhance the table lines. At the same time, adjust the sharpness to highlight the details; and apply histogram equalization to adjust the local contrast.
[0018] In a possible implementation, for a text region, a local enhancement strategy based on text content is adopted to locally enhance the text region, and an enhancement parameter optimization strategy based on text geometric features is adopted to enhance the text region, including:
[0019] For the text area, a bilateral filter is used to smooth the text area to remove background noise and retain edge details; a local adaptive enhancement strategy is applied to enhance the clarity of the text part through local binarization while maintaining background smoothness; and, according to the font size in the text area, an enhancement strategy that matches the font size is applied.
[0020] In a possible implementation, based on the font size in the text area, an enhancement strategy matching the font size is applied, including:
[0021] For the text area whose font size belongs to the first size interval, a local contrast enhancement method is applied to adaptively adjust the local contrast;
[0022] For the text area whose font size belongs to the second size interval, adaptive binarization is used to suppress the background noise and display the text part clearly; in addition, multi-scale detail enhancement is performed to extract and enhance the details at different scales, so as to retain the font structure and suppress background impurities;
[0023] For text areas whose font size belongs to the third size interval, a refined edge detection and enhancement method is used to extract and enhance the text edges.
[0024] In a possible implementation, for a text area whose font size belongs to a first size interval, after applying a local contrast enhancement method and adaptively adjusting the local contrast, the method further includes:
[0025] Perform sharpening filtering to enhance edge processing and make the text more prominent.
[0026] In a second aspect, a picture enhancement device for layout documents is provided, comprising:
[0027] An initialization processing unit, used for initializing the original image of the layout document to obtain a binary image of the original image;
[0028] A determination unit, used to determine a table area and a text area of a binary image using a preset segmentation algorithm;
[0029] A table area enhancement unit, used for locally enhancing the table area by adopting a local enhancement strategy based on table content;
[0030] A text region enhancement unit, for locally enhancing the text region using a local enhancement strategy based on text content and enhancing the text region using an enhancement parameter optimization strategy based on text geometric features;
[0031] The output unit is used to perform noise removal on the enhanced image after enhancing the table area and the text area, and output an enhanced effect image.
[0032] In a possible implementation, the initialization process includes gray-scaling and binarization.
[0033] In a possible implementation, the preset segmentation algorithm includes a preset edge detection algorithm, a projection algorithm, and a transformation algorithm; and the determination unit is further used to:
[0034] Use the preset edge detection algorithm to identify the edges in the binary image and highlight the boundaries in the binary image by detecting gradient changes;
[0035] Visualize the cumulative distribution of pixels in the binary image by performing horizontal and vertical projections through a preset projection algorithm, thereby distinguishing table columns and text rows;
[0036] A preset transformation algorithm is used to detect the straight line structure in the binary image, thereby obtaining the table area and text area of the binary image.
[0037] In a possible implementation manner, the table area enhancement unit is further used to:
[0038] For the table area, use the preset enhanced edge filter to extract the edge information of the table area, and then superimpose it with the original image to enhance the table lines. At the same time, adjust the sharpness to highlight the details; and apply histogram equalization to adjust the local contrast.
[0039] In a possible implementation manner, the text area enhancement unit is further used to:
[0040] For the text area, a bilateral filter is used to smooth the text area to remove background noise and retain edge details; a local adaptive enhancement strategy is applied to enhance the clarity of the text part through local binarization while maintaining background smoothness; and, according to the font size in the text area, an enhancement strategy that matches the font size is applied.
[0041] In a possible implementation manner, the text area enhancement unit is further used to:
[0042] For the text area whose font size belongs to the first size interval, a local contrast enhancement method is applied to adaptively adjust the local contrast;
[0043] For the text area whose font size belongs to the second size interval, adaptive binarization is used to suppress the background noise and display the text part clearly; in addition, multi-scale detail enhancement is performed to extract and enhance the details at different scales, so as to retain the font structure and suppress background impurities;
[0044] For text areas whose font size belongs to the third size interval, a refined edge detection and enhancement method is used to extract and enhance the text edges.
[0045] In a possible implementation manner, the text area enhancement unit is further used to:
[0046] For a text area whose font size belongs to the first size interval, after applying a local contrast enhancement method and adaptively adjusting the local contrast, the method further includes:
[0047] Perform sharpening filtering to enhance edge processing and make the text more prominent.
[0048] According to a third aspect, an electronic device is provided, comprising a processor and a memory, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute any one of the above-described image enhancement methods for layout documents.
[0049] In a fourth aspect, a storage medium is provided, wherein the storage medium stores a computer program, wherein the computer program is configured to execute any of the above-mentioned image enhancement methods for layout documents when running.
[0050] By means of the above technical scheme, the picture enhancement method, device, equipment and medium for layout documents provided in the embodiments of the present application can initialize the original picture of the layout document to obtain a binary image of the original picture; use a preset segmentation algorithm to determine the table area and text area of the binary image; for the table area, use a local enhancement strategy based on the table content to locally enhance the table area; for the text area, use a local enhancement strategy based on the text content to locally enhance the text area, and use an enhancement parameter optimization strategy based on text geometric features to enhance the text area; after the enhancement processing of the table area and the text area, the enhanced image is denoised and an enhancement effect diagram is output. It can be seen that the embodiment of the present application performs different enhancement operations on text and tables based on the local enhancement strategy of the content; and optimizes the enhancement parameters based on geometric features to strengthen the enhancement effect of the text area, so that the blurred image is enhanced through multi-level enhancement and fusion, and the text data in the image is clarified. Through this method, readers can read and obtain valid data on blurred images in the document more efficiently; in the case where there are many content errors after OCR recognition, after image enhancement, re-OCR recognition can also achieve better recognition effect; this embodiment improves the clarity of the text while maintaining the comfortable look and feel of the overall image, avoiding visual fatigue caused by excessive enhancement; and it can process different image areas more comprehensively, with higher adaptability and flexibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.
[0052] Figure 1 A flow chart of a method for enhancing an image in a layout document provided in an embodiment of the present application is shown;
[0053] Figure 2 A flowchart of a method for enhancing an image in a layout document provided by another embodiment of the present application is shown;
[0054] Figure 3 A structural diagram of a picture enhancement device for layout documents provided in an embodiment of the present application is shown;
[0055] Figure 4 A structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0056] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0057] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that such use is interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the term "including" and its variants are to be interpreted as open-ended terms meaning "including but not limited to".
[0058] In order to solve the above technical problems, the present application embodiment provides a method for enhancing an image in a layout document, such as Figure 1 As shown, the image enhancement method for layout documents may include the following steps S101 to S105:
[0059] Step S101, initializing the original image of the layout document to obtain a binary image of the original image;
[0060] Step S102, using a preset segmentation algorithm to determine the table area and text area of the binary image;
[0061] Step S103, for the table area, adopting a local enhancement strategy based on the table content to locally enhance the table area;
[0062] Step S104, for the text area, adopting a local enhancement strategy based on text content to locally enhance the text area, and adopting an enhancement parameter optimization strategy based on text geometric features to enhance the text area;
[0063] Step S105, after enhancing the table area and the text area, denoising is performed on the enhanced image to output an enhanced effect image.
[0064] In the above step S101, the initialization processing can be grayscale and binarization. Grayscale is the process of converting a color image into a grayscale image. A color image usually contains three color channels, RGB, while a grayscale image has only one brightness channel. This can reduce the amount of data and simplify subsequent processing.
[0065] RGB stands for red, green, and blue, which are the three primary colors of light. In the RGB model, a variety of colors can be produced by combining red, green, and blue lights of different intensities.
[0066] Grayscale images only contain brightness information and remove color information, so that image processing algorithms can focus on the brightness changes of the image, which is beneficial for many brightness-based image analysis tasks (such as edge detection, contour extraction, etc.).
[0067] Binarization is the process of converting a grayscale image into an image containing only two pixel values, usually black and white, which can further simplify the image structure. Based on binarization, different objects in the image can be easily distinguished, which facilitates image segmentation.
[0068] The embodiment of the present application performs different enhancement operations on text and tables based on a local enhancement strategy for the content; and optimizes enhancement parameters based on geometric features to strengthen the enhancement effect of the text area. In this way, the blurred image is enhanced through multi-level enhancement and fusion, and the text data in the image is clarified. Through this method, readers can read and obtain valid data on blurred images in the document more efficiently; in the case where there are many errors in the content obtained after OCR recognition, after image enhancement, re-OCR recognition can also achieve better recognition effects; this embodiment improves the clarity of the text while maintaining a comfortable look and feel of the overall image, avoiding visual fatigue caused by excessive enhancement; and it can process different image areas more comprehensively, with higher adaptability and flexibility.
[0069] The present application provides a possible implementation method. The preset segmentation algorithm mentioned in step S102 may include a preset edge detection algorithm, a projection algorithm, and a transformation algorithm. Step S102 uses the preset segmentation algorithm to determine the table area and the text area of the binary image, and specifically includes the following steps A1 to A3:
[0070] Step A1, using a preset edge detection algorithm to identify the edge in the binary image, and highlighting the boundary in the binary image by detecting gradient changes.
[0071] In this step, the preset edge detection algorithm may be a Canny edge detection algorithm, etc., which is not limited in this embodiment.
[0072] The Canny edge detection algorithm mainly includes the following steps:
[0073] Noise Removal: Smoothing the image using a Gaussian filter to reduce noise in the image, as noise may be falsely detected as edges;
[0074] Calculate gradient: Use the gradient operator to calculate the gradient of the image. The gradient represents the intensity and direction of the change in image brightness.
[0075] Non-maximum suppression: non-maximum suppression is performed on the gradient amplitude in the gradient direction to ensure that the edge is a thin line, that is, only the local maximum value is retained on the edge of the gradient map;
[0076] Dual Threshold Detection: Use two thresholds (a high threshold and a low threshold) to identify strong edges, weak edges, and non-edges. Strong edges are those where the gradient value is higher than the high threshold, while weak edges are those where the gradient value is lower than the high threshold but higher than the low threshold;
[0077] Edge tracking: Connect strong edges with weak edges to form a continuous edge through hysteresis detection;
[0078] Edge refinement: Refine the detected edges to obtain the thinnest possible edges;
[0079] Post-processing: Finally, the edges are post-processed to remove discontinuities due to noise or other factors.
[0080] Step A2, performing horizontal and vertical projections by using a preset projection algorithm to visualize the cumulative distribution of pixels in the binary image, thereby distinguishing between table columns and text rows.
[0081] Step A3: using a preset transformation algorithm to detect the straight line structure in the binary image, thereby obtaining a table area and a text area of the binary image.
[0082] In this step, the preset transformation algorithm may be, for example, Hough transformation, which is not limited in this embodiment. Hough transformation can be used to detect geometric shapes, such as straight lines, circles, ellipses, etc., from an image. It is a mapping method from image space to parameter space, which can transform points in an image into curves in parameter space and identify specific shapes by finding peaks in parameter space.
[0083] In the embodiment of the present application, a possible implementation method is provided. In the above step S103, for the table area, a local enhancement strategy based on the table content is adopted to locally enhance the table area, which may specifically include the following steps B1:
[0084] Step B1, for the table area, use a preset enhanced edge filter to extract the edge information of the table area, and then superimpose it with the original image to enhance the table lines, while highlighting the details by adjusting the sharpness; and apply histogram equalization to adjust the local contrast.
[0085] In this step, the preset edge enhancement filter may be a Laplacian filter, etc., which is not limited in this embodiment. The Laplacian filter is based on the second-order derivative of the image and is used to enhance the fast intensity change areas in the image, which usually correspond to the edges.
[0086] The table area usually contains a large number of lines and small text. This embodiment uses the Laplacian filter to extract the edge information of the table, and then superimposes it with the original image to enhance the table lines, and adjusts the sharpness to make the details more prominent. In addition, histogram equalization is applied to enhance the local contrast while avoiding excessive enhancement and introducing noise, so that the small text in the table is clearer.
[0087] In the embodiment of the present application, a possible implementation method is provided. In the above step S104, for the text area, a local enhancement strategy based on text content is adopted to locally enhance the text area, and an enhancement parameter optimization strategy based on text geometric features is adopted to enhance the text area. Specifically, the following steps C1 may be included:
[0088] Step C1: for the text area, use a bilateral filter to smooth the text area, remove background noise, and retain edge details; apply a local adaptive enhancement strategy to enhance the clarity of the text part through local binarization while maintaining background smoothness; and, according to the font size in the text area, apply an enhancement strategy that matches the font size.
[0089] For pure text areas, generally, too much sharpening is not needed, but the overall look and feel is improved. A bilateral filter is used to smooth the image, which not only removes background noise but also retains edge details, making the look and feel of the text area more comfortable. In the text area, a local adaptive enhancement strategy is applied to avoid losing too many details during the processing process; local binarization is used to enhance the clarity of the text part while keeping the background smooth.
[0090] In addition, the text area is usually divided into many different types of text. One of the more obvious and easily recognizable features is the font size. The font size of the title, text, footnote, etc. is obviously different. In the process of image processing, it is impossible to distinguish whether it is a title or text, but the font size can be obtained. For texts in different font size ranges, different text enhancement processing is carried out to achieve a better image text enhancement effect.
[0091] A possible implementation method is provided in the embodiment of the present application. In the above step C1, an enhancement strategy matching the font size is applied according to the font size in the text area, which may specifically include the following steps D1 to D3:
[0092] Step D1, for a text area whose font size belongs to a first size interval, applying a local contrast enhancement method to adaptively adjust the local contrast;
[0093] Step D2: for the text area whose font size belongs to the second size interval, adaptive binarization is used to suppress the background noise and display the text part clearly; and multi-scale detail enhancement is performed to extract and enhance the details at different scales, thereby retaining the font structure and suppressing the background impurities;
[0094] Step D3: for the text area whose font size belongs to the third size interval, a refined edge detection and enhancement method is used to extract and enhance the text edges.
[0095] After applying a local contrast enhancement method to the text area whose font size belongs to the first size interval in step D1 and adaptively adjusting the local contrast, the method further includes:
[0096] Perform sharpening filtering to enhance edge processing and make the text more prominent.
[0097] The above introduces Figure 1 There are multiple implementation methods for each link of the illustrated embodiment. The image enhancement method for layout documents in the embodiment of the present application will be further explained below through specific embodiments.
[0098] Figure 2 A flowchart of a method for enhancing an image in a layout document provided by another embodiment of the present application is shown, comprising the following steps:
[0099] 1) Get images in PDF and CAJ documents.
[0100] 2) Image preprocessing: binarization of the image and preliminary removal of noise.
[0101] 3) Feature extraction and segmentation: The table area and text area in the image are obtained through traditional algorithms, and a content-based local enhancement strategy is applied to perform different enhancement operations on the table area and text area respectively.
[0102] 4) Enhanced edge sharpening: Use an enhanced edge filter (such as the Laplacian filter) to enhance the clarity of lines and text.
[0103] 5) Adjust contrast: Apply adaptive histogram equalization to improve the local contrast of the image while avoiding excessive introduction of noise.
[0104] 6) Enhancement parameter optimization based on geometric features: Different enhancement strategies are applied according to the geometric features of the text image, that is, the font size, to achieve better enhancement effects.
[0105] 7) Smoothing and local adaptive enhancement: Use bilateral filters to smooth the image, remove background noise while retaining the clarity of text edges, making the text area more comfortable to look at. Local adaptation is to adapt contrast and enhance text clarity.
[0106] 8) Image post-processing: Use morphological operations (such as erosion and dilation operations) to further remove small noise points to ensure a clean output image.
[0107] 9) Output the enhanced effect diagram.
[0108] In another specific embodiment, the present invention describes an image enhancement method applied to PDF and CAJ document reading, which enhances blurred images through multi-level enhancement and fusion to clarify text data in the images.
[0109] Through this method, readers can read more efficiently and obtain valid data from blurred images in documents. If there are many errors in the content obtained after OCR recognition, re-OCR recognition after image enhancement can also achieve better recognition results.
[0110] This paper describes an innovative method to enhance blurred images in PDF and CAJ documents. The implementation steps are as follows:
[0111] First, the original image is initialized, including grayscale and binarization. A series of initialization operations are performed to obtain a binary image that meets the requirements, thereby simplifying the image structure and reducing computational complexity.
[0112] Secondly, the binary image is analyzed based on traditional algorithms such as edge detection, projection method, and Hough transform, and feature extraction and segmentation are performed to locate the table area and text area in the image. The specific process of this step is to use the Canny edge detection algorithm to identify the main edges in the image and highlight the boundaries in the image by detecting gradient changes; then, the projection method is applied to visualize the cumulative distribution of pixels in the image through horizontal and vertical projections to distinguish between table columns and text rows; and Hough transform is used to detect the straight line structure in the image. Through these steps, the image can be accurately segmented into table areas and text areas, forming the basis for further enhancement processing.
[0113] Then, different local enhancement strategies are applied based on the content. Differentiate and process the table area and the text area, and apply different enhancement strategies. The table area is enhanced and sharpened for table lines, and the text area is enhanced and adaptively enhanced locally. The specific implementation steps are as follows: the local enhancement strategy based on content.
[0114] Finally, in view of the complexity of text data, the enhancement parameters of the text area are optimized based on geometric features to obtain the expected image enhancement effect. The specific implementation steps are as follows:
[0115] The content-based local enhancement strategy and the optimization of enhancement parameters based on geometric features in this method are the key to determining the image enhancement effect.
[0116] Content-based local enhancement strategy: Different enhancement operations are performed based on the image content (i.e. text and tables). This method can significantly improve the readability of complex images. The enhancement processing strategies for different contents are as follows:
[0117] (1) Table areas usually contain a large number of lines and small text. Laplacian filtering is used to extract the edge information of the table, and then it is superimposed with the original image to enhance the table lines. At the same time, the sharpness is adjusted to make the details more prominent. In addition, histogram equalization is applied to enhance the local contrast while avoiding excessive enhancement and introducing noise, making the small text in the table clearer.
[0118] (2) For pure text areas, generally too much sharpening is not needed, but the overall look and feel is improved. A bilateral filter is used to smooth the image, which not only removes background noise but also retains edge details, making the look and feel of the text area more comfortable. In the text area, a local adaptive enhancement strategy is applied to avoid losing too many details during the processing process; local binarization is used to enhance the clarity of the text part while keeping the background smooth.
[0119] Enhancement parameter optimization based on geometric features: Text areas are usually divided into many different types of text. One of the more obvious and easily recognizable features is the font size. The font size of titles, text, footnotes, etc. is obviously different. In the process of image processing, it is impossible to distinguish whether it is a title or text, but the font size can be obtained. For texts in different font size ranges, different text enhancement processing is carried out to achieve a better image text enhancement effect. The specific parameter optimization method is as follows:
[0120] (1) Larger text sizes usually occupy more space. Local contrast enhancement methods can be applied to make the fonts clearer without introducing too much noise by adaptively adjusting the local contrast. Appropriate sharpening filtering can be performed as needed to enhance the edges and make the text more prominent.
[0121] (2) For texts with relatively regular font sizes, they can be roughly identified as the main text. Adaptive binarization is used in the dense text area of the main text to ensure that background noise is suppressed and the text part is clearly displayed. Multi-scale detail enhancement is also performed to extract and enhance details at different scales, thereby retaining the font structure and suppressing background impurities.
[0122] (3) For the processing of small-font text areas, since small fonts may be blurred due to low resolution, refined edge detection and enhancement methods (such as Sobel edge enhancement) are used to extract and enhance the fine text edges to make the text clearer. Sobel edge enhancement is an algorithm widely used in the fields of image processing and computer vision for edge detection. It highlights high-frequency areas in the image by calculating the spatial gradient of image brightness. These areas usually correspond to edges.
[0123] Through this comprehensive method, after multi-level enhancement and fusion of the image, users can get a clearer enhanced image than the original image. Whether it is reading or OCR recognition, better results can be achieved, further improving the user's experience when reading the content of the document.
[0124] In summary, the solution provided by the present invention can enhance the image as a whole, clarify the text content therein without changing the image itself, and make the text in the blurred image clearer, making it easier for readers to read or use as the original image for OCR recognition, and can achieve better results.
[0125] The original intention of the present invention is to optimize the text reading experience. The main type of image enhancement is the text type, so it has a better enhancement effect on blurred images with more text or pure text content.
[0126] In summary, the problem solved by the present invention is that the text content in the blurred picture is difficult to read, and the present invention provides the user with an "original picture" with clear text content as much as possible, providing the user with a better reading experience and making reading more convenient and efficient.
[0127] Based on the image enhancement methods for layout documents provided in the above embodiments, and based on the same inventive concept, an embodiment of the present application also provides an image enhancement device for layout documents.
[0128] Figure 3 is a structural diagram of a picture enhancement device for layout documents provided in an embodiment of the present application. Figure 3 As shown, the image enhancement device for layout documents may specifically include an initialization processing unit 310 , a determination unit 320 , a table area enhancement unit 330 , a text area enhancement unit 340 and an output unit 350 .
[0129] The initialization processing unit 310 is used to perform initialization processing on the original image of the layout document to obtain a binary image of the original image;
[0130] A determination unit 320, configured to determine a table area and a text area of a binary image using a preset segmentation algorithm;
[0131] The table area enhancement unit 330 is used to locally enhance the table area by using a local enhancement strategy based on the table content;
[0132] A text region enhancement unit 340 is used to enhance the text region locally by using a local enhancement strategy based on text content and an enhancement parameter optimization strategy based on text geometric features;
[0133] The output unit 350 is used to perform noise removal on the enhanced image after the enhancement processing is performed on the table area and the text area, and output an enhancement effect image.
[0134] A possible implementation method is provided in an embodiment of the present application, and the initialization process includes grayscale and binarization.
[0135] In an embodiment of the present application, a possible implementation method is provided, wherein the preset segmentation algorithm includes a preset edge detection algorithm, a projection algorithm, and a transformation algorithm; and the determination unit 320 is further configured to:
[0136] Use the preset edge detection algorithm to identify the edges in the binary image and highlight the boundaries in the binary image by detecting gradient changes;
[0137] Visualize the cumulative distribution of pixels in the binary image by performing horizontal and vertical projections through a preset projection algorithm, thereby distinguishing table columns and text rows;
[0138] A preset transformation algorithm is used to detect the straight line structure in the binary image, thereby obtaining the table area and text area of the binary image.
[0139] A possible implementation method is provided in an embodiment of the present application, wherein the table area enhancement unit 330 is further configured to:
[0140] For the table area, use the preset enhanced edge filter to extract the edge information of the table area, and then superimpose it with the original image to enhance the table lines. At the same time, adjust the sharpness to highlight the details; and apply histogram equalization to adjust the local contrast.
[0141] A possible implementation method is provided in an embodiment of the present application, wherein the text area enhancement unit 340 is further configured to:
[0142] For the text area, a bilateral filter is used to smooth the text area to remove background noise and retain edge details; a local adaptive enhancement strategy is applied to enhance the clarity of the text part through local binarization while maintaining background smoothness; and, according to the font size in the text area, an enhancement strategy that matches the font size is applied.
[0143] A possible implementation method is provided in an embodiment of the present application, wherein the text area enhancement unit 340 is further configured to:
[0144] For the text area whose font size belongs to the first size interval, a local contrast enhancement method is applied to adaptively adjust the local contrast;
[0145] For the text area whose font size belongs to the second size interval, adaptive binarization is used to suppress the background noise and display the text part clearly; in addition, multi-scale detail enhancement is performed to extract and enhance the details at different scales, so as to retain the font structure and suppress background impurities;
[0146] For text areas whose font size belongs to the third size interval, a refined edge detection and enhancement method is used to extract and enhance the text edges.
[0147] A possible implementation method is provided in an embodiment of the present application, wherein the text area enhancement unit 340 is further configured to:
[0148] For a text area whose font size belongs to the first size interval, after applying a local contrast enhancement method and adaptively adjusting the local contrast, the method further includes:
[0149] Perform sharpening filtering to enhance edge processing and make the text more prominent.
[0150] Based on the same inventive concept, an embodiment of the present application also provides an electronic device, including a processor and a memory, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the image enhancement method for layout documents of any one of the above embodiments.
[0151] In an exemplary embodiment, an electronic device is provided, such as Figure 4 As shown, Figure 4 The electronic device 400 shown includes: a processor 401 and a memory 403. The processor 401 and the memory 403 are connected, such as through a bus 402. Optionally, the electronic device 400 may also include a transceiver 404. It should be noted that in actual applications, the transceiver 404 is not limited to one, and the structure of the electronic device 400 does not constitute a limitation on the embodiments of the present application.
[0152] Processor 401 may be a CPU (Central Processing Unit), a GPU (Graphics Processing Unit), a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. Processor 401 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0153] The bus 402 may include a path to transmit information between the above components. The bus 402 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 402 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0154] The memory 403 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to these.
[0155] The memory 403 is used to store the computer program code for executing the solution of the present application, and the execution is controlled by the processor 401. The processor 401 is used to execute the computer program code stored in the memory 403 to implement the contents shown in the above method embodiment.
[0156] Among them, electronic devices include but are not limited to: mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0157] Based on the same inventive concept, an embodiment of the present application further provides a storage medium, in which a computer program is stored, wherein the computer program is configured to execute the image enhancement method for layout documents of any one of the above embodiments when running.
[0158] Those skilled in the art can clearly understand that the specific working processes of the systems, devices, and modules described above can refer to the corresponding processes in the aforementioned method embodiments, and for the sake of brevity, they are not further described here.
[0159] Those skilled in the art can understand that the technical solution of the present application can be essentially or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, which includes a number of program instructions, so that an electronic device (such as a personal computer, a server, or a network device, etc.) executes all or part of the steps of the method described in each embodiment of the present application when running the program instructions. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.
[0160] Alternatively, all or part of the steps of implementing the aforementioned method embodiments may be accomplished by hardware associated with program instructions (such as electronic devices such as personal computers, servers, or network devices), and the program instructions may be stored in a computer-readable storage medium. When the program instructions are executed by a processor of an electronic device, the electronic device executes all or part of the steps of the methods described in the embodiments of the present application.
[0161] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that within the spirit and principles of the present application, they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not deviate from the protection scope of the present application.
Claims
1. A method for enhancing an image in a layout document, characterized in that: include: Initialize the original image of the layout document to obtain a binary image of the original image; Using a preset segmentation algorithm to determine the table area and text area of the binary image; For the table area, a local enhancement strategy based on the table content is used to locally enhance the table area; For text regions, a local enhancement strategy based on text content is used to enhance the text region locally, and an enhancement parameter optimization strategy based on text geometric features is used to enhance the text region. After enhancing the table area and the text area, the enhanced image is denoised to output an enhanced effect image.
2. The method according to claim 1, characterized in that The initialization process includes gray-scaling and binarization.
3. The method according to claim 1 or 2, characterized in that: The preset segmentation algorithm includes a preset edge detection algorithm, a projection algorithm, and a transformation algorithm; The preset segmentation algorithm is used to determine the table area and text area of the binary image, including: Use the preset edge detection algorithm to identify the edges in the binary image and highlight the boundaries in the binary image by detecting gradient changes; Visualize the cumulative distribution of pixels in the binary image by performing horizontal and vertical projections through a preset projection algorithm, thereby distinguishing table columns and text rows; A preset transformation algorithm is used to detect the straight line structure in the binary image, thereby obtaining the table area and text area of the binary image.
4. The method according to claim 1 or 2, characterized in that: For the table area, a local enhancement strategy based on the table content is used to locally enhance the table area, including: For the table area, use the preset enhanced edge filter to extract the edge information of the table area, and then superimpose it with the original image to enhance the table lines. At the same time, adjust the sharpness to highlight the details; and apply histogram equalization to adjust the local contrast.
5. The method according to claim 1 or 2, characterized in that: For text regions, a local enhancement strategy based on text content is used to enhance the text region locally, and an enhancement parameter optimization strategy based on text geometric features is used to enhance the text region, including: For the text area, a bilateral filter is used to smooth the text area to remove background noise and retain edge details; a local adaptive enhancement strategy is applied to enhance the clarity of the text part through local binarization while maintaining background smoothness; and, according to the font size in the text area, an enhancement strategy that matches the font size is applied.
6. The method according to claim 5, characterized in that Based on the font size in the text area, apply enhancement strategies that match the font size, including: For the text area whose font size belongs to the first size interval, a local contrast enhancement method is applied to adaptively adjust the local contrast; For the text area whose font size belongs to the second size interval, adaptive binarization is used to suppress the background noise and display the text part clearly; in addition, multi-scale detail enhancement is performed to extract and enhance the details at different scales, so as to retain the font structure and suppress background impurities; For text areas whose font size belongs to the third size interval, a refined edge detection and enhancement method is used to extract and enhance the text edges.
7. The method according to claim 6, characterized in that For a text area whose font size belongs to the first size interval, after applying a local contrast enhancement method and adaptively adjusting the local contrast, the method further includes: Perform sharpening filtering to enhance edge processing and make the text more prominent.
8. A picture enhancement device for layout documents, characterized in that: include: An initialization processing unit, used for initializing the original image of the layout document to obtain a binary image of the original image; A determination unit, used to determine a table area and a text area of a binary image using a preset segmentation algorithm; A table area enhancement unit, used for locally enhancing the table area by adopting a local enhancement strategy based on table content; A text region enhancement unit, for locally enhancing the text region using a local enhancement strategy based on text content and enhancing the text region using an enhancement parameter optimization strategy based on text geometric features; The output unit is used to perform noise removal on the enhanced image after enhancing the table area and the text area, and output an enhanced effect image.
9. An electronic device, characterized in that: The invention comprises a processor and a memory, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the image enhancement method for layout documents according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the image enhancement method for layout documents according to any one of claims 1 to 7 when running.