Image enhancement method and device and electronic equipment
Through image color restoration, prospect and detail enhancement processing technology, the problem of poor low-light image processing effect in the existing technology has been solved, and high-quality image improvement has been achieved. It is suitable for mobile applications, taking into account both cost and user experience.
Patent Information
- Application Number
- CN202410934292.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2024-11-12
Smart Images

Figure CN118941453A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of document processing technology, and more specifically, to an image enhancement method, device, and electronic device. Background Art
[0002] PDF (Portable Document Format) is a commonly used electronic document format with the advantages of being cross-platform, easy to spread and protecting content. PDF files can encapsulate text, fonts, formats, colors, and graphics and images that are independent of equipment and resolution in one file. This format file can also contain electronic information such as hypertext links, sounds and dynamic images, and this format supports special-length files, with high integration and security reliability.
[0003] With the increasing popularity of smartphones, users usually use mobile phone cameras to take photos of documents and generate PDFs. However, due to the complexity of the user's shooting environment, there may be problems with the lighting, contrast, and brightness of the document scanned images, so it is necessary to enhance the document scanned images. Existing solutions usually directly use, for example, the document enhancement filter that comes with the iOS system, directly enhance the image contrast and brightness, etc. However, for darker images, the processing effect does not meet user needs. Summary of the invention
[0004] In view of the problems existing in the above-mentioned prior art, the embodiments of the present application provide an image enhancement method, device, and electronic device, which can improve the image quality of scanned images of generated PDF documents.
[0005] In a first aspect, an embodiment of the present application provides an image enhancement method, comprising:
[0006] Performing image color restoration processing on the scanned image of the PDF document;
[0007] Performing image foreground enhancement processing on the scanned image of the PDF document; and
[0008] Perform image detail enhancement processing on the scanned image of the PDF document.
[0009] Furthermore, the performing image color restoration processing on the scanned image of the PDF document includes:
[0010] The scanned image of the PDF document is subjected to image color restoration processing by using a perfect reflection algorithm.
[0011] Furthermore, the performing image foreground enhancement processing on the scanned image of the PDF document includes:
[0012] Scaling the scanned image of the PDF document;
[0013] Dividing the image of the scanned image of the PDF document into a plurality of equal areas;
[0014] Performing maximum color sampling on the plurality of equal regions and statistically analyzing the sampling; and
[0015] Determine whether the most colors of the multiple equal areas are similar. If so, analyze common colors within the most colors and output a background image with the same size as the original image according to the common colors. If not, output the original image.
[0016] Furthermore, the performing image detail enhancement processing on the scanned image of the PDF document includes:
[0017] The scanned image of the PDF document is subjected to image detail enhancement processing by using the USM sharpening enhancement algorithm.
[0018] Furthermore, it also includes:
[0019] Perform image noise reduction processing on the scanned image of the PDF document.
[0020] Furthermore, the performing image noise reduction processing on the scanned image of the PDF document includes:
[0021] A histogram normalization process is performed on the scanned image of the PDF document.
[0022] Furthermore, after the histogram normalization is performed on the scanned image of the PDF document, the method further includes:
[0023] Performing fuzzy filtering on the scanned image of the PDF document;
[0024] Performing image corrosion processing on the scanned image of the PDF document; and
[0025] The scanned image of the PDF document is subjected to bilateral blurring processing.
[0026] In a second aspect, the present application also provides an image enhancement device, including:
[0027] A color restoration module, used to perform image color restoration processing on the scanned image of the PDF document;
[0028] a foreground enhancement module, configured to perform image foreground enhancement processing on the scanned image of the PDF document; and
[0029] The detail enhancement module is used to perform image detail enhancement processing on the scanned image of the PDF document.
[0030] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor is configured to implement the image enhancement method according to the first aspect when executing the program.
[0031] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, wherein the computer program is used to implement the image enhancement method according to the first aspect above.
[0032] In a fifth aspect, an embodiment of the present application further provides a computer program product on which a computer program is stored, wherein the computer program is used to implement the image enhancement method according to the first aspect above.
[0033] The embodiments of the present application bring the following beneficial effects:
[0034] The image enhancement method provided in the embodiment of the present application performs image color restoration, foreground enhancement and detail enhancement processing on the scanned image of the PDF document. When the image is dark, the image quality of the scanned image of the generated PDF document can be improved, and the processing is fast, the operation is convenient, and the cost and user experience are taken into consideration. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying any creative work.
[0036] Figure 1 A schematic diagram of a flow chart of an image enhancement method provided in an embodiment of the present application;
[0037] Figure 2 A structural block diagram of an image enhancement device provided in an embodiment of the present application;
[0038] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0039] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0040] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments described in the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.
[0041] In the specification and claims of this application and the above-mentioned drawings, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of this application, unless otherwise specified, "multiple" means two or more. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to the specific circumstances.
[0042] For low-light images, the existing image processing technology will make the image darker and darker with poor results when using image enhancement filters. Moreover, when there are dust spots and stains on the document image, or the content on the other side of the scanned document page is vaguely visible, after being processed by enhancement filters or OpenCV (Open Source Computer Vision Library, cross-platform computer vision library) technology, they will remain permanently on the scanned document image, and the visual effect is not good.
[0043] Deep learning has good results in image processing, but it is costly. It requires a large amount of data for training, and the model is large in size, which is not suitable for mobile app packages distributed externally. In addition, after the model is deployed on the server, the interaction with the mobile terminal is easily affected by network fluctuations, resulting in poor user experience.
[0044] Therefore, the present application embodiment proposes an image enhancement method. Figure 1 FIG. 1 is a flow chart of an image enhancement method according to an embodiment of the present application. Figure 1 As shown, the image enhancement method of the embodiment of the present application includes the following steps:
[0045] S101: performing image color restoration processing on the scanned image of the PDF document;
[0046] Specifically, PDF documents are a commonly used electronic document format with advantages such as cross-platform, easy dissemination and content protection. PDF files can encapsulate text, fonts, formats, colors, and graphics and images that are independent of devices and resolutions in one file. When images are scanned, such as using a mobile terminal, color cast may occur.
[0047] Image color restoration is generally done by white balance processing. For the color cast phenomenon that occurs when shooting under a specific light source, white balance processing compensates by strengthening the corresponding complementary color so that white objects can be restored to white, or using a white balance algorithm to restore the input document image to the true color of the original light source.
[0048] S102: performing image foreground enhancement processing on the scanned image of the PDF document;
[0049] Specifically, the foreground has multiple functions in an image. It can increase the sense of space and perspective of the picture, let the audience feel the depth of the field in the photo, decorate the picture and set off the theme, and it can also balance the picture and increase the depth of the picture by creating a sense of layering.
[0050] The processing steps of foreground enhancement include: dividing the image of the scanned document into several regions of equal size, each region basically has the characteristics that the text body (foreground) occupies a small proportion of the region, but the background part occupies most of the region. At this time, when calculating the background layer of the region, the enhanced image can be obtained by using the original image / background layer.
[0051] S103: Perform image detail enhancement processing on the scanned image of the PDF document.
[0052] Specifically, the local edges of the enhanced document image are not so prominent and require certain detail enhancement operations.
[0053] Therefore, the image enhancement method provided in the embodiment of the present application performs image color restoration, foreground enhancement and detail enhancement on the scanned image of the PDF document. When the image is dark, the image quality of the scanned image of the generated PDF document can be improved, and can be processed quickly, easily operated, and take into account both cost and user experience.
[0054] Furthermore, in some embodiments of the present application, the performing of image color restoration processing on the scanned image of the PDF document includes:
[0055] The scanned image of the PDF document is subjected to image color restoration processing by using a perfect reflection algorithm.
[0056] Specifically, the implementation process of the perfect reflection algorithm is as follows: 1. Calculate the grayscale maximum values Rmax, Gmax, and Bmax of the three channels of the image RGB; 2. Use the sum of the three-channel values to determine the lower limit T of the brightest range of the image; 3. Calculate the three-channel mean values Rm, Gm, and Bm of the points where the sum of the three-channel values of the image is greater than T; 4. Calculate the compensation coefficient of the three channels, that is, the maximum value of a single channel divided by the average value of the bright area of a single channel. After the above operations, a picture with a normal light source can be obtained, thereby improving the image quality of the generated PDF document.
[0057] Furthermore, in some embodiments of the present application, the step of performing image foreground enhancement processing on the scanned image of the PDF document includes:
[0058] Scaling the scanned image of the PDF document;
[0059] Dividing the image of the scanned image of the PDF document into a plurality of equal areas;
[0060] Performing maximum color sampling on the plurality of equal regions and statistically analyzing the sampling; and
[0061] Determine whether the most colors of the multiple equal areas are similar. If so, analyze common colors within the most colors and output a background image with the same size as the original image according to the common colors. If not, output the original image.
[0062] Specifically, the image foreground enhancement processing of scanned images of PDF documents is mainly divided into three key steps: image area preprocessing, area sampling, and most color statistics and analysis:
[0063] 1. Image area preprocessing
[0064] The document images taken by the camera are usually large in size, so it is time-consuming to directly sample them. You can reduce them to a specified size. The commonly used scaling ratio is to keep the maximum width and height of 0-1000 as is, and to reduce it by 2 times when the maximum width and height is 1000-2000, and to reduce the rest by 3 times.
[0065] Then, the image is divided into several equal regions, for example, into 9 regions for the next step of region sampling.
[0066] 2. Regional sampling
[0067] That is, sampling obtains the approximately correct background color. The specific steps are: reduce the bit depth, clear the 4 least significant bits of each channel, randomly sample 30% of the pixels in the area, and obtain the most common number, that is, the most color, and this number must exceed about 40% of the sampled pixels. Each area finally obtains its own most color.
[0068] 3. Most colorful statistics and analysis
[0069] Regardless of the area of the document image, the most common colors are generally similar. First, perform approximate analysis of several most common colors. If they are not similar, output the original image. If they are similar, use k-means clustering to analyze the most common colors in several areas and find the most common color, i.e., the common color. The obtained most common color and / or common color is output as a background image of the same size as the original image, and finally the original image / background image is used for output in this step.
[0070] Furthermore, in some embodiments of the present application, the step of performing image detail enhancement processing on the scanned image of the PDF document includes:
[0071] The scanned image of the PDF document is subjected to image detail enhancement processing by using a USM (Unsharp mask) sharpening enhancement algorithm.
[0072] Specifically, the local edges of the enhanced document image are not so prominent, and certain detail enhancement operations are required. Here, the scanned image of the PDF document is enhanced with the USM sharpening enhancement algorithm to enhance the image details, thereby improving the edge highlighting effect of the document image and further improving the image quality. The USM sharpening enhancement algorithm first performs a Gaussian blur on the original image, then subtracts a coefficient from the original image and multiplies it by the Gaussian blurred image, and then scales the value to within the RGB pixel value range of 0 to 255. The key code is as follows:
[0073] / / Unsharp Mask
[0074] Mat blur,dst;
[0075] cv::GaussianBlur(src,blur,Size(0,0),25);
[0076] cv::addWeighted(src,1.5,blur,-0.5,0,dst);
[0077] Furthermore, in some embodiments of the present application, it also includes:
[0078] Perform image noise reduction processing on the scanned image of the PDF document.
[0079] Specifically, after the above steps, the foreground and background of the document image are already clear, but the image may still have other subtle interferences. At this time, it is necessary to perform certain noise reduction processing on the image to ensure that the image quality meets the user's needs.
[0080] Furthermore, in some embodiments of the present application, the performing image noise reduction processing on the scanned image of the PDF document includes:
[0081] A histogram normalization process is performed on the scanned image of the PDF document.
[0082] Specifically, an image histogram is a statistical table that reflects the distribution of pixels in an image. In fact, the horizontal axis represents the type of image pixels, which can be grayscale or color. The vertical axis represents the total number of pixels of each color value in the image or the percentage of all pixels. An image is composed of pixels, and a histogram that reflects the distribution of pixels can often be used as an important feature of image quality.
[0083] The pixels of some grayscale images are not distributed in [0,255], but in the sub-interval of [0,255]. Such images often do not look very clear to the naked eye. We can use histogram normalization to change its pixel distribution from the sub-interval of [0,255] to the range of [0,255]. In this way, the clarity of the image can be increased.
[0084] Furthermore, in some embodiments of the present application, after the histogram normalization is performed on the scanned image of the PDF document, the method further includes:
[0085] Performing fuzzy filtering on the scanned image of the PDF document;
[0086] Performing image corrosion processing on the scanned image of the PDF document; and
[0087] The scanned image of the PDF document is subjected to bilateral blurring processing.
[0088] Specifically, after the above steps, the foreground and background of the document image are clear, but the image may still have other subtle interference. At this time, the image needs to be subjected to certain noise reduction processing. The document image is subjected to fuzzy filtering processing, corrosion processing and bilateral fuzzy filtering in turn to ensure that the image quality meets user needs.
[0089] Figure 2 FIG. 2 is a structural block diagram of the image enhancement device 200 according to an embodiment of the present application. Figure 2 As shown, the image enhancement device 200 of the embodiment of the present application includes: a color restoration module 210, a foreground enhancement module 220 and a detail enhancement module 230, wherein:
[0090] A color restoration module 210 is used to perform image color restoration processing on the scanned image of the PDF document;
[0091] A foreground enhancement module 220, configured to perform image foreground enhancement processing on the scanned image of the PDF document; and
[0092] The detail enhancement module 230 is used to perform image detail enhancement processing on the scanned image of the PDF document.
[0093] The image enhancement device provided in the embodiment of the present application performs image color restoration, foreground enhancement and detail enhancement processing on the scanned image of the PDF document, which can improve the image quality of the scanned image of the generated PDF document, and can process quickly, operate conveniently, and take into account both cost and user experience.
[0094] It should be noted that the specific implementation of the image enhancement device in the embodiment of the present application is similar to the specific implementation of the image enhancement method in the embodiment of the present application. Please refer to the description of the method part for details, and no further details will be given here.
[0095] Figure 3 Schematic diagram of the structure of an electronic device 300 according to an embodiment of the present application.
[0096] like Figure 3 As shown, the electronic device 300 includes a central processing unit (CPU) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from the storage part 302 to a random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic device 300 are also stored. The CPU 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0097] The following components are connected to the I / O interface 305: an input section 306 including a keyboard, a mouse, etc.; an output section 307 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 308 including a hard disk, etc.; and a communication section 309 including a network interface card such as a LAN card, a modem, etc. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to the I / O interface 305 as needed. A removable medium 311, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 310 as needed, so that a computer program read therefrom is installed into the storage section 308 as needed.
[0098] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a machine-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 309, and / or installed from a removable medium 311. When the computer program is executed by a central processing unit (CPU) 301, the above-mentioned functions defined in the electronic device of the present application are executed.
[0099] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electronic device, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0100] In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction-executing electronic device, apparatus, or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction-executing electronic device, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0101] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the processing receiving device, method and computer program product according to various embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the aforementioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based electronic device that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0102] The units or modules involved in the embodiments of the present application may be implemented by software or hardware. The units or modules described may also be arranged in a processor, and the processor is used to implement the image enhancement method when executing the program:
[0103] Performing image color restoration processing on the scanned image of the PDF document;
[0104] Performing image foreground enhancement processing on the scanned image of the PDF document; and
[0105] Perform image detail enhancement processing on the scanned image of the PDF document.
[0106] As another aspect, the present application further provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiment; or may exist independently and not be assembled into the electronic device. The above computer-readable storage medium stores one or more programs, and when the above programs are used by one or more processors to execute the image enhancement method described in the present application:
[0107] Performing image color restoration processing on the scanned image of the PDF document;
[0108] Performing image foreground enhancement processing on the scanned image of the PDF document; and
[0109] Perform image detail enhancement processing on the scanned image of the PDF document.
[0110] As another aspect, the present application further provides a computer program product, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer program product stores one or more programs, and when the above programs are used by one or more processors to execute the image enhancement method described in the present application:
[0111] Performing image color restoration processing on the scanned image of the PDF document;
[0112] Performing image foreground enhancement processing on the scanned image of the PDF document; and
[0113] Perform image detail enhancement processing on the scanned image of the PDF document.
[0114] The above description is only a preferred embodiment of the present application, and does not limit the patent scope of the present application. All equivalent structural changes made by using the contents of the present application specification and drawings under the application concept of the present application, or directly / indirectly used in other related technical fields are included in the patent protection scope of the present application.
Claims
1. An image enhancement method for processing scanned images of PDF documents, characterized in that: include: Performing image color restoration processing on the scanned image of the PDF document; Performing image foreground enhancement processing on the scanned image of the PDF document; and Perform image detail enhancement processing on the scanned image of the PDF document.
2. The image enhancement method according to claim 1, characterized in that: The performing image color restoration processing on the scanned image of the PDF document includes: The scanned image of the PDF document is subjected to image color restoration processing by using a perfect reflection algorithm.
3. The image enhancement method according to claim 1, characterized in that: The performing image foreground enhancement processing on the scanned image of the PDF document includes: Scaling the scanned image of the PDF document; Dividing the image of the scanned image of the PDF document into a plurality of equal areas; Performing maximum color sampling on the plurality of equal regions and statistically analyzing the sampling; and Determine whether the most colors of the multiple equal areas are similar. If so, analyze common colors within the most colors and output a background image with the same size as the original image according to the common colors. If not, output the original image.
4. The image enhancement method according to claim 1, characterized in that: The performing image detail enhancement processing on the scanned image of the PDF document includes: The scanned image of the PDF document is subjected to image detail enhancement processing by using the USM sharpening enhancement algorithm.
5. The image enhancement method according to claim 1, characterized in that: Also includes: Perform image noise reduction processing on the scanned image of the PDF document.
6. The image enhancement method according to claim 5, characterized in that: The performing image noise reduction processing on the scanned image of the PDF document includes: A histogram normalization process is performed on the scanned image of the PDF document.
7. The image enhancement method according to claim 6, characterized in that: After the histogram normalization process is performed on the scanned image of the PDF document, the method further includes: Performing fuzzy filtering on the scanned image of the PDF document; Performing image corrosion processing on the scanned image of the PDF document; and The scanned image of the PDF document is subjected to bilateral blurring processing.
8. An image enhancement device for processing scanned images of PDF documents, characterized in that: include: A color restoration module, used to perform image color restoration processing on the scanned image of the PDF document; A foreground enhancement module, used to perform image foreground enhancement processing on the scanned image of the PDF document; and The detail enhancement module is used to perform image detail enhancement processing on the scanned image of the PDF document.
9. An electronic device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor is used to implement the image enhancement method according to any one of claims 1 to 7 when executing the program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is used to implement the image enhancement method according to any one of claims 1-7.
