Method and device for reducing noise of document images

Through cross sampling and HSV color space distance generation foreground masks, combined with object detection and European distance filling color, the noise problem in the electronicization process of document images is solved, and efficient noise reduction effect and calculation speed improvement are achieved.

CN116503264BActive Publication Date: 2025-09-02BEIJING THUNISOFT INFORMATION TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310065654.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-13
Publication Date
2025-09-02
Estimated Expiration
2043-01-13

AI Technical Summary

Technical Problem

In the process of electronicizing document images, the prior art is susceptible to the influence of image acquisition equipment and operation factors, resulting in noise such as salt and pepper noise, molar patterns, whitening, light leakage gradient, backlight word transmission and black edges, affecting the effect of document reading and text detection.

Method used

Cross-sampling is used to determine the background color and pixel board, generate a foreground mask based on HSV color space distance and adaptive binaryization, and repair noise elements through object detection. Finally, fill the color based on European distances, and obtain noise reduction results in combination with image enhancement technology.

Benefits of technology

It improves the speed of document noise reduction calculation, improves the noise reduction effect, effectively removes noise interference, and improves the reading and text detection quality of document images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116503264B_ABST
    Figure CN116503264B_ABST
Patent Text Reader

Abstract

The present application discloses a document image denoising method and device, the denoising method comprising: determining the pixel value and pixel plate of the background colour of the document image to be detected; determining the foreground mask of the document image to be detected based on the HSV colour space distance and adaptive binarisation; adjusting the foreground mask based on the target detection result of the document image to be detected to obtain an adjusted foreground mask; filling the background colour and foreground colour of the adjusted foreground mask based on the adjusted foreground mask and the pixel plate to obtain a denoised image, wherein the background colour and pixel plate are obtained by cross-sampling the document image to be detected; performing image enhancement based on the difference between the denoised image and the background colour in the document image to be detected to obtain a denoising result, which can improve the document denoising calculation speed and enhance the denoising effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of image data processing, and in particular to a method and device for reducing noise of document images. Background Art

[0002] Paper files are difficult to circulate and share, are easily damaged during storage, are inconvenient to use, and have low file utilization rates. By digitizing paper files through digital imaging technology, we can better achieve online, instant sharing and permanent preservation of files.

[0003] The digitization of dossier files is susceptible to numerous factors, including image acquisition equipment (such as high-definition cameras, scanners, and mobile phones) and operator manipulation. This can result in significant noise artifacts such as salt-and-pepper noise, moiré, white-out, light leakage, backlight bleed-through, and black edges. Noise in dossier images can significantly impact the ability to read the files, detect text (OCR), and ultimately, further utilize the electronic files.

[0004] Therefore, noise reduction for document images is very necessary. Summary of the Invention

[0005] The embodiment of the present application provides a new method for reducing noise of document images, which is used to solve the technical problem of reducing noise during the electronicization of files.

[0006] Specifically, a document image noise reduction method includes the following steps:

[0007] Determining pixel values ​​and a pixel plate of a background color of the document image to be detected, wherein the background color and the pixel plate are obtained by cross-sampling the document image to be detected;

[0008] Determining a foreground mask of the document image to be detected based on HSV color space distance and adaptive binarization;

[0009] Adjusting the foreground mask based on the target detection result of the document image to be detected to obtain an adjusted foreground mask;

[0010] Filling the background color and foreground color of the adjusted foreground mask based on the adjusted foreground mask and the pixel plate to obtain a denoised image;

[0011] Image enhancement is performed based on the difference between the denoised image and the background color in the document image to be detected to obtain a denoising result.

[0012] Furthermore, the step of determining the pixel value of the background color of the document image to be detected specifically includes:

[0013] According to a preset number of sampling points, symmetrical pixel points are selected from the document image to be detected as cross-sampling pixel points;

[0014] Quantizing the cross-sampling pixels according to a preset number of colors to obtain a cross-sampling result;

[0015] Using the color with the highest frequency in the cross sampling result as the background color of the document image to be detected;

[0016] Based on the background color of the document image to be detected, a pixel value of the background color is obtained.

[0017] Furthermore, determining the foreground mask of the document image to be detected based on the HSV color space distance and adaptive binarization specifically includes:

[0018] Converting the document image to be detected from an RGB color space image to an HSV color space image;

[0019] Generate a first mask based on threshold comparison of saturation and brightness of the HSV color space image;

[0020] Adaptively perform local binarization on the RGB color space image to generate a second mask;

[0021] The first mask and the second mask are combined to obtain a foreground mask.

[0022] Furthermore, the target detection result of the document image to be detected includes at least one of a fingerprint, a red seal, a photo, a nail hole, a saddle seal, and a portrait. The adjusting the foreground mask based on the target detection result of the document image to be detected to obtain the adjusted foreground mask specifically includes:

[0023] If the target detection result includes a portrait and / or a photo, the corresponding elements of the portrait and / or the photo in the foreground mask are retained;

[0024] If the target detection result includes nail marks and / or nail holes, repairing corresponding elements of the nail marks and / or nail holes in the foreground mask;

[0025] If the target detection result includes a red seal, separating the foreground and background of the red seal in the target detection result, and merging the separated foreground of the red seal into the foreground mask;

[0026] If the target detection result includes a fingerprint, the foreground and background of the fingerprint in the target detection result are separated, and the separated foreground of the fingerprint is merged into the foreground mask.

[0027] In the embodiment of the present specification, if the target detection result includes nail marks and / or nail holes, repairing the corresponding elements of the nail marks and / or nail holes in the foreground mask specifically includes:

[0028] If the target detection result includes nail marks and / or nail holes, the inpaint method is used to repair the corresponding elements of the nail marks and / or nail holes in the foreground mask.

[0029] Furthermore, if the target detection result includes a red seal, separating the foreground and background of the red seal in the target detection result, and merging the separated foreground of the red seal into the foreground mask, specifically includes:

[0030] If the target detection result includes a red seal, a color filtering method is used to separate the foreground and background of the red seal in the target detection result, and the separated foreground of the red seal is merged into the foreground mask.

[0031] Furthermore, if the target detection result includes a fingerprint, separating the foreground and background of the fingerprint in the target detection result, and merging the separated foreground of the fingerprint into the foreground mask, specifically includes:

[0032] If the target detection result includes a fingerprint, a video background extraction method is used to separate the foreground and background of the fingerprint in the target detection result, and the separated foreground of the fingerprint is merged into the foreground mask.

[0033] Furthermore, the step of filling the background color and foreground color of the adjusted foreground mask based on the adjusted foreground mask and the pixel plate to obtain a noise-reduced image specifically includes:

[0034] Using the background color as the background color of the adjusted foreground mask;

[0035] Based on the Euclidean distance between the pixel plate and the non-background color in the document image to be detected, the corresponding color in the pixel plate with the shortest Euclidean distance is used as the assigned color, and the foreground color of the adjusted foreground mask is filled to obtain a denoised image.

[0036] Furthermore, obtaining the pixel panel specifically includes:

[0037] Using the background color as the background color of the adjusted foreground mask;

[0038] Based on the Euclidean distance between the pixel plate and the non-background color in the document image to be detected, the corresponding color in the pixel plate with the shortest Euclidean distance is used as the assigned color, and the foreground color of the adjusted foreground mask is filled to obtain a denoised image.

[0039] An embodiment of the present application also provides a device for reducing noise of document images.

[0040] Specifically, a document image noise reduction device includes:

[0041] A background color determination module, which determines the pixel value and pixel plate of the background color of the document image to be detected, wherein the background color and pixel plate are obtained by cross-sampling the document image to be detected;

[0042] A foreground determination module, which determines the foreground mask of the document image to be detected based on HSV color space distance and adaptive binarization;

[0043] an adjustment module, which adjusts the foreground mask based on the target detection result of the document image to be detected to obtain an adjusted foreground mask;

[0044] a filling module, which fills the background color and foreground color of the adjusted foreground mask based on the adjusted foreground mask and the pixel plate to obtain a noise-reduced image;

[0045] The enhancement module performs image enhancement based on the difference between the denoised image and the background color in the document image to be detected to obtain a denoising result.

[0046] Furthermore, the step of determining the pixel value of the background color of the document image to be detected specifically includes:

[0047] According to a preset number of sampling points, symmetrical pixel points are selected from the document image to be detected as cross-sampling pixel points;

[0048] Quantizing the cross-sampling pixels according to a preset number of colors to obtain a cross-sampling result;

[0049] Using the color with the highest frequency in the cross sampling result as the background color of the document image to be detected;

[0050] Based on the background color of the document image to be detected, a pixel value of the background color is obtained.

[0051] Furthermore, determining the foreground mask of the document image to be detected based on the HSV color space distance and adaptive binarization specifically includes:

[0052] Converting the document image to be detected from an RGB color space image to an HSV color space image;

[0053] Generate a first mask based on threshold comparison of saturation and brightness of the HSV color space image;

[0054] Adaptively perform local binarization on the RGB color space image to generate a second mask;

[0055] The first mask and the second mask are combined to obtain a foreground mask.

[0056] Furthermore, the target detection result of the document image to be detected includes at least one of a fingerprint, a red seal, a photo, a nail hole, a saddle seal, and a portrait. The adjusting the foreground mask based on the target detection result of the document image to be detected to obtain the adjusted foreground mask specifically includes:

[0057] If the target detection result includes a portrait and / or a photo, the corresponding elements of the portrait and / or the photo in the foreground mask are retained;

[0058] If the target detection result includes nail marks and / or nail holes, repairing corresponding elements of the nail marks and / or nail holes in the foreground mask;

[0059] If the target detection result includes a red seal, separating the foreground and background of the red seal in the target detection result, and merging the separated foreground of the red seal into the foreground mask;

[0060] If the target detection result includes a fingerprint, the foreground and background of the fingerprint in the target detection result are separated, and the separated foreground of the fingerprint is merged into the foreground mask.

[0061] In the embodiment of the present specification, if the target detection result includes nail marks and / or nail holes, repairing the corresponding elements of the nail marks and / or nail holes in the foreground mask specifically includes:

[0062] If the target detection result includes nail marks and / or nail holes, the inpaint method is used to repair the corresponding elements of the nail marks and / or nail holes in the foreground mask.

[0063] Furthermore, if the target detection result includes a red seal, separating the foreground and background of the red seal in the target detection result, and merging the separated foreground of the red seal into the foreground mask, specifically includes:

[0064] If the target detection result includes a red seal, a color filtering method is used to separate the foreground and background of the red seal in the target detection result, and the separated foreground of the red seal is merged into the foreground mask.

[0065] Furthermore, if the target detection result includes a fingerprint, separating the foreground and background of the fingerprint in the target detection result, and merging the separated foreground of the fingerprint into the foreground mask, specifically includes:

[0066] If the target detection result includes a fingerprint, a video background extraction method is used to separate the foreground and background of the fingerprint in the target detection result, and the separated foreground of the fingerprint is merged into the foreground mask.

[0067] Furthermore, the step of filling the background color and foreground color of the adjusted foreground mask based on the adjusted foreground mask and the pixel plate to obtain a noise-reduced image specifically includes:

[0068] Using the background color as the background color of the adjusted foreground mask;

[0069] Based on the Euclidean distance between the pixel plate and the non-background color in the document image to be detected, the corresponding color in the pixel plate with the shortest Euclidean distance is used as the assigned color, and the foreground color of the adjusted foreground mask is filled to obtain a denoised image.

[0070] Furthermore, obtaining the pixel panel specifically includes:

[0071] The non-background colors in the cross sampling result are added to a color queue, the colors in the color queue are sorted according to a preset color rule, and the sorted color queue is extracted according to a preset time interval to obtain the pixel panel.

[0072] The technical solution provided by the embodiment of the present application has at least the following beneficial effects: determining the pixel value and pixel plate of the background color of the document image to be detected, wherein the background color and pixel plate are obtained by cross-sampling the document image to be detected; determining the foreground mask of the document image to be detected based on the HSV color space distance and adaptive binarization; adjusting the foreground mask based on the target detection result of the document image to be detected to obtain an adjusted foreground mask; filling the background color and foreground color of the adjusted foreground mask based on the adjusted foreground mask and the pixel plate to obtain a denoised image; performing image enhancement based on the difference between the denoised image and the background color in the document image to be detected to obtain a denoising result, which can improve the document denoising calculation speed and enhance the denoising effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0074] Figure 1 A schematic diagram of a document image noise reduction method provided in an embodiment of this specification;

[0075] Figure 2 A schematic diagram of a cross-sampling method provided in an embodiment of this specification;

[0076] Figure 3 A schematic diagram of obtaining a pixel panel provided in an embodiment of this specification;

[0077] Figure 4 A framework diagram of a document image noise reduction method provided in an embodiment of this specification;

[0078] FIG5 is a schematic diagram showing the effect of a document image noise reduction method provided by an embodiment of this specification;

[0079] Figure 6 A schematic diagram of a document image noise reduction device provided in an embodiment of this specification. DETAILED DESCRIPTION

[0080] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0081] Existing techniques for noise reduction in black-and-white documents involve dividing the document image into N×N blocks, where N depends on the number of pixels per inch (PII) in the image. Each block A, along with the four blocks above, below, and to the left and right, is examined. If noise is detected in a block A, all pixels within that block are changed to white, thereby removing the noise from the document image. This method only works for black-and-white images of Chinese characters and has poor robustness. It is ineffective for images such as handwritten text or tables containing images.

[0082] For color document denoising, the method involves grayscale preprocessing of the color document image, followed by bilateral filtering for denoising, image background estimation, background subtraction and image enhancement, energy function construction, network graph construction, and finally energy function minimization using a graph cut algorithm based on augmenting paths. Although this method can significantly improve the binarization of document images against complex backgrounds and is applicable to document images with complex backgrounds such as those with multiple colors, stroke gradients, ink smudges, page stains or textures, uneven lighting, and low contrast, it can only be used for low-quality document images, and problems may arise when estimating the stroke width of text when encountering multiple widths. Furthermore, the color of color images is not preserved.

[0083] Another document denoising method uses random sampling to obtain the background color. This is then compared with the pixel values ​​in HSV space to create a first foreground mask. To address uneven image brightness, adaptive local binarization is performed to obtain a second foreground mask. The first and second foreground masks are then ANDed together to form the final foreground mask. Then, a kmeans clustering method is used to generate a pixel plate, extract representative colors, and fill the foreground with the background color. The mask is then filled with representative colors that are more similar. However, this method is time-consuming and can easily distort color images, discoloring or even losing key evidence such as fingerprints, seals, and photographs. It also easily introduces salt-and-pepper noise and is unable to remove black edges, punch holes, and nail marks that affect document quality. The denoised image can appear lighter or darker.

[0084] It can be seen that the existing methods for document denoising cannot achieve good denoising effects.

[0085] Figure 1 This is a schematic diagram of a document image noise reduction method provided in an embodiment of this specification. Figure 1 As shown, the noise reduction method includes the following steps:

[0086] Step S101: Determine the pixel value and pixel plate of the background color of the document image to be detected, wherein the background color and pixel plate are obtained by cross-sampling the document image to be detected.

[0087] Generally speaking, the document image to be detected is a document image in the JPG format. If the document image to be detected is a document image in other formats, the document image in other formats needs to be converted into a document image in the JPG format.

[0088] Determining the pixel value of the background color of the document image to be detected specifically includes:

[0089] According to a preset number of sampling points, symmetrical pixel points are selected from the document image to be detected as cross-sampling pixel points;

[0090] Quantizing the cross-sampling pixels according to a preset number of colors to obtain a cross-sampling result;

[0091] Using the color with the highest frequency in the cross sampling result as the background color of the document image to be detected;

[0092] Based on the background color of the document image to be detected, a pixel value of the background color is obtained.

[0093] It should be noted that, in the cross sampling result, colors other than the color with the highest frequency, i.e., non-background colors, constitute the pixel panel.

[0094] Compared to random sampling, cross sampling reduces the number of pixel samples. The preset sampling points typically consist of 1% of the pixels in the document being inspected. For example, a 2081×5231 image has 5,267,011 pixels. Sampling at 1% would require approximately 50,000 pixels, significantly reducing the number of samples.

[0095] When performing cross sampling, it is only necessary to obtain symmetrical pixel points. Figure 2 This is a schematic diagram of a cross sampling method provided in the embodiment of this specification. Figure 2 As shown, sampling can be performed along the diagonal lines from the four corners of the document to be detected. Of course, other symmetrical sampling methods can also be selected, and the specific method of selecting symmetrical pixel points for cross sampling does not constitute a limitation of this application.

[0096] For the RGB color space, the so-called "how much" of RGB refers to brightness, and is represented by integers. Normally, RGB each has 256 levels of brightness, which are represented by numbers from 0, 1, 2... to 255, a total of 256 levels, including a total of 256 colors. In the process of determining the background color, in order to reduce the amount of calculation, the number of colors can be reduced according to business needs, so the number of colors can be preset artificially. In one embodiment of the present specification, the preset number of colors can be 100. The colors corresponding to the preset number of colors can be obtained by the pseudo-clustering method, which will not be repeated here.

[0097] Step S103: Determine the foreground mask of the document image to be detected based on the HSV color space distance and adaptive binarization.

[0098] In the embodiment of this specification, determining the foreground mask of the document image to be detected based on the HSV color space distance and adaptive binarization specifically includes:

[0099] Converting the document image to be detected from an RGB color space image to an HSV color space image;

[0100] Generate a first mask based on threshold comparison of saturation and brightness of the HSV color space image;

[0101] Adaptively perform local binarization on the RGB color space image to generate a second mask;

[0102] The first mask and the second mask are combined to obtain a foreground mask.

[0103] HSV (Hue, Saturation, Value) is a color space defined by the intuitive properties of color. H (Hue) represents hue, a fundamental property of color; S (Saturation) represents saturation, a value between 0 and 1; and V (Value) represents lightness, a value between 0 and 1. In the embodiments of this specification, only saturation and brightness are considered when calculating color similarity. The thresholds for saturation and brightness can be set selectively, with a typical range of 0.05 to 0.15 being optimal. The HSV color space image is compared with the background value to obtain a first mask.

[0104] The first mask and the second mask are merged to obtain a foreground mask. Specifically, the first mask and the second mask are performed an AND operation to obtain the foreground mask.

[0105] Step S105: Based on the target detection result of the document image to be detected, the foreground mask is adjusted to obtain an adjusted foreground mask.

[0106] Since the image to be detected may contain fingerprints, red seals, photos, nail holes, interline seals, portraits and other targets that may affect the document noise, it is necessary to perform target detection to obtain target detection results.

[0107] Currently, target detection methods can adopt a variety of methods. In one embodiment of this specification, a target detection model obtained by training based on the yolov5 model is adopted.

[0108] In an embodiment of the present specification, the target detection result of the document image to be detected includes at least one of: a fingerprint, a red seal, a photo, a nail hole, a saddle seal, and a portrait. Adjusting the foreground mask based on the target detection result of the document image to be detected to obtain the adjusted foreground mask specifically includes:

[0109] If the target detection result includes a portrait and / or a photo, the corresponding elements of the portrait and / or the photo in the foreground mask are retained;

[0110] If the target detection result includes nail marks and / or nail holes, repairing corresponding elements of the nail marks and / or nail holes in the foreground mask;

[0111] If the target detection result includes a red seal, separating the foreground and background of the red seal in the target detection result, and merging the separated foreground of the red seal into the foreground mask;

[0112] If the target detection result includes a fingerprint, the foreground and background of the fingerprint in the target detection result are separated, and the separated foreground of the fingerprint is merged into the foreground mask.

[0113] In the embodiment of the present specification, if the target detection result includes nail marks and / or nail holes, repairing the corresponding elements of the nail marks and / or nail holes in the foreground mask specifically includes:

[0114] If the target detection result includes nail marks and / or nail holes, the inpaint method is used to repair the corresponding elements of the nail marks and / or nail holes in the foreground mask.

[0115] In the embodiment of this specification, if the target detection result includes a red seal, the foreground and background of the red seal in the target detection result are separated, and the foreground of the separated red seal is merged into the foreground mask, specifically including:

[0116] If the target detection result includes a red seal, a color filtering method is used to separate the foreground and background of the red seal in the target detection result, and the separated foreground of the red seal is merged into the foreground mask.

[0117] In the embodiment of this specification, if the target detection result includes a fingerprint, separating the foreground and background of the fingerprint in the target detection result, and merging the separated foreground of the fingerprint into the foreground mask specifically includes:

[0118] If the target detection result includes a fingerprint, a video background extraction method is used to separate the foreground and background of the fingerprint in the target detection result, and the separated foreground of the fingerprint is merged into the foreground mask.

[0119] Because fingerprint edges may be blurred, to ensure completeness and clarity in fingerprint extraction, the video background extraction method can use the GMM (Gaussian Mixture Model) method. Specifically, the fingerprint size (i.e., width and height) is determined based on the fingerprint's coordinate position in the target detection results. A window with a step size of k is set and the fingerprint is slid across the target detection result image to simulate video frames. Based on the simulated video frames, the GMM method is iteratively used to separate the fingerprint's foreground and background.

[0120] The foreground and background of the fingerprint can also be separated by using the KNN (K-Nearest Neighbor) method or the color filtering method.

[0121] Step S107: Based on the adjusted foreground mask and the pixel plate, the background color and foreground color of the adjusted foreground mask are filled to obtain a denoised image.

[0122] In the embodiment of this specification, filling the background color and foreground color of the adjusted foreground mask based on the adjusted foreground mask and the pixel plate to obtain a noise-reduced image specifically includes:

[0123] Using the background color as the background color of the adjusted foreground mask;

[0124] Based on the Euclidean distance between the pixel plate and the non-background color in the document image to be detected, the corresponding color in the pixel plate with the shortest Euclidean distance is used as the assigned color, and the foreground color of the adjusted foreground mask is filled to obtain a denoised image.

[0125] For two colors, the greater the distance between them, the greater the difference between them, and vice versa. When the distance between two colors is calculated using Euclidean distance, the shorter the Euclidean distance, the smaller the difference between the two colors. At this point, the color corresponding to the shortest Euclidean distance in the pixel panel is used as the assigned color to fill the adjusted foreground mask with the foreground color.

[0126] As mentioned above, in the cross sampling result, the colors other than the color with the highest frequency, i.e., non-background colors, constitute a pixel panel. In the embodiment of this specification, the pixel panel is obtained by:

[0127] The non-background colors in the cross sampling result are added to a color queue, the colors in the color queue are sorted according to a preset color rule, and the sorted color queue is extracted according to a preset time interval to obtain the pixel panel.

[0128] The preset color rule is based on the RGB color of the pixel, which is obtained by using the differences in blue, green and red between different pixels. Figure 3 A schematic diagram of obtaining a pixel panel is provided in the embodiment of this specification, such as Figure 3As shown, taking two pixels as an example, the color of pixel 1 is color 1 (B, G, R), and the color of pixel 2 is color 2 (B, G, R). First, compare color 1 (B) with color 2 (B). If color 1 (B) ≠ color 2 (B), then further determine whether color 1 (B) is greater than color 2 (B). If color 1 (B) > color 2 (B), then use color 1 (B, G, R) as the color of the pixel board. If color 1 (B) < color 2 (B), then use color 2 (B, G, R) as the color of the pixel board. If color 1 (B) = color 2 (B), then further compare color 1 (G) with color 2 (G). If color 1 (G) ≠ color 2 (G), then further determine whether color 1 (G) is greater than color 2 (G). If color 1 (G )>color2(G), then color1(B,G,R) is used as the color of the pixel plate. If color1(G)<color2(G), then color2(B,G,R) is used as the color of the pixel plate. If color1(G)=color2(G), then color1(R) is further compared with color2(R). If color1(R)≠color2(R), then it is further determined whether color1(R) is greater than color2(R). If color1(R)>color2(R), then color1(B,G,R) is used as the color of the pixel plate. If color1(G)<color2(G), then color2(B,G,R) is used as the color of the pixel plate. Based on the same idea, the pixels corresponding to the non-background colors in the first mask are compared to obtain the pixel plate.

[0129] Step S109: performing image enhancement based on the difference between the denoised image and the background color in the document image to be detected to obtain a denoising result.

[0130] Because the sampled image is quantized, the background of the image after noise reduction may appear slightly lighter or darker than the original image, necessitating further image enhancement. Specifically, the difference between the background color of the noise-reduced image and the document image to be inspected is calculated, and the average difference value is then calculated. Gamma transformation and sharpening are then applied to increase the image quality, thereby achieving better noise reduction results.

[0131] In order to further improve the noise reduction method provided in the embodiments of this specification, Figure 4 This is a framework diagram of a document image noise reduction method provided in an embodiment of this specification. Figure 4 As shown, the document image to be detected generates a first mask through HSV color space distance, and generates a second mask through adaptive local binarization. The first mask and the second mask are merged to generate a foreground mask; based on the target detection result of the document image to be detected, the foreground mask is adjusted to obtain an adjusted foreground mask; further, the foreground mask and pixel plate are adjusted to obtain a denoised image; the denoised image is enhanced and the denoised result is output.

[0132] The noise reduction method provided in the embodiment of this specification can improve the speed of document noise reduction calculation and enhance the noise reduction effect. Figure 5 is a schematic diagram of the effect of a document image noise reduction method provided in the embodiment of this specification. The pictures from left to right are the original picture, the previous noise reduction effect, and the noise reduction effect of this application. Figure 5A As shown in , the salt and pepper noise can be reduced. Figure 5B As shown in the figure, the noise reduction effect is better after removing the nail holes. Figure 5C As shown, for pictures, better noise reduction effect can be achieved.

[0133] The embodiments of this specification provide a method for reducing noise of a document image. Based on the same idea, the embodiments of this specification also provide a device for reducing noise of a document image. Figure 6 This is a schematic diagram of a document image noise reduction device provided in an embodiment of this specification. Figure 6 As shown, the noise reduction device includes:

[0134] Background color determination module 601, determines the pixel value of the background color of the document image to be detected;

[0135] A foreground determination module 603 determines a foreground mask and a pixel plate of the document image to be detected based on HSV color space distance and adaptive binarization, wherein the background color and pixel plate are obtained by cross-sampling the document image to be detected;

[0136] An adjustment module 605 adjusts the foreground mask based on the target detection result of the document image to be detected to obtain an adjusted foreground mask;

[0137] A filling module 607 fills the background color and the foreground color of the adjusted foreground mask based on the adjusted foreground mask and the pixel plate to obtain a noise-reduced image;

[0138] The enhancement module 609 performs image enhancement based on the difference between the denoised image and the background color in the document image to be detected to obtain a denoising result.

[0139] In the embodiment of this specification, determining the pixel value of the background color of the document image to be detected specifically includes:

[0140] According to a preset number of sampling points, symmetrical pixel points are selected from the document image to be detected as cross-sampling pixel points;

[0141] Quantizing the cross-sampling pixels according to a preset number of colors to obtain a cross-sampling result;

[0142] Using the color with the highest frequency in the cross sampling result as the background color of the document image to be detected;

[0143] Based on the background color of the document image to be detected, a pixel value of the background color is obtained.

[0144] In the embodiment of this specification, determining the foreground mask of the document image to be detected based on the HSV color space distance and adaptive binarization specifically includes:

[0145] Converting the document image to be detected from an RGB color space image to an HSV color space image;

[0146] Generate a first mask based on threshold comparison of saturation and brightness of the HSV color space image;

[0147] Adaptively perform local binarization on the RGB color space image to generate a second mask;

[0148] The first mask and the second mask are combined to obtain a foreground mask.

[0149] In an embodiment of the present specification, the target detection result of the document image to be detected includes at least one of: a fingerprint, a red seal, a photo, a nail hole, a saddle seal, and a portrait. Adjusting the foreground mask based on the target detection result of the document image to be detected to obtain the adjusted foreground mask specifically includes:

[0150] If the target detection result includes a portrait and / or a photo, the corresponding elements of the portrait and / or the photo in the foreground mask are retained;

[0151] If the target detection result includes nail marks and / or nail holes, repairing corresponding elements of the nail marks and / or nail holes in the foreground mask;

[0152] If the target detection result includes a red seal, separating the foreground and background of the red seal in the target detection result, and merging the separated foreground of the red seal into the foreground mask;

[0153] If the target detection result includes a fingerprint, the foreground and background of the fingerprint in the target detection result are separated, and the separated foreground of the fingerprint is merged into the foreground mask.

[0154] In the embodiment of the present specification, if the target detection result includes nail marks and / or nail holes, repairing the corresponding elements of the nail marks and / or nail holes in the foreground mask specifically includes:

[0155] If the target detection result includes nail marks and / or nail holes, the inpaint method is used to repair the corresponding elements of the nail marks and / or nail holes in the foreground mask.

[0156] In the embodiment of this specification, if the target detection result includes a red seal, the foreground and background of the red seal in the target detection result are separated, and the foreground of the separated red seal is merged into the foreground mask, specifically including:

[0157] If the target detection result includes a red seal, a color filtering method is used to separate the foreground and background of the red seal in the target detection result, and the separated foreground of the red seal is merged into the foreground mask.

[0158] In the embodiment of this specification, if the target detection result includes a fingerprint, separating the foreground and background of the fingerprint in the target detection result, and merging the separated foreground of the fingerprint into the foreground mask specifically includes:

[0159] If the target detection result includes a fingerprint, a video background extraction method is used to separate the foreground and background of the fingerprint in the target detection result, and the separated foreground of the fingerprint is merged into the foreground mask.

[0160] In the embodiment of this specification, filling the background color and foreground color of the adjusted foreground mask based on the adjusted foreground mask and the pixel plate to obtain a noise-reduced image specifically includes:

[0161] Using the background color as the background color of the adjusted foreground mask;

[0162] Based on the Euclidean distance between the pixel plate and the non-background color in the document image to be detected, the corresponding color in the pixel plate with the shortest Euclidean distance is used as the assigned color, and the foreground color of the adjusted foreground mask is filled to obtain a denoised image.

[0163] In the embodiments of this specification, obtaining the pixel panel specifically includes:

[0164] The non-background colors in the cross sampling result are added to a color queue, the colors in the color queue are sorted according to a preset color rule, and the sorted color queue is extracted according to a preset time interval to obtain the pixel panel.

[0165] It should be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, product, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, product, or apparatus. In the absence of further limitations, the phrase "comprises a..." to define an element does not preclude the presence of other identical elements in the process, method, product, or apparatus that includes the element.

[0166] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0167] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A document image noise reduction method, characterized in that: The noise reduction method comprises: Determine the pixel value and pixel plate of the background color of the document image to be detected, wherein the background color and pixel plate are obtained by cross-sampling the document image to be detected, and the pixel value of the background color of the document image to be detected is determined, specifically including: selecting symmetrical pixel points from the document image to be detected as cross-sampling pixel points according to a preset number of sampling points; quantizing the cross-sampling pixel points according to a preset number of colors to obtain a cross-sampling result; using the color with the highest frequency in the cross-sampling result as the background color of the document image to be detected; and obtaining the pixel value of the background color based on the background color of the document image to be detected; obtaining the pixel plate specifically includes: adding the non-background colors in the cross-sampling result to a color queue, sorting the colors in the color queue according to a preset color rule, and extracting the sorted color queue according to a preset time interval to obtain the pixel plate; Determining a foreground mask of the document image to be detected based on HSV color space distance and adaptive binarization; Adjusting the foreground mask based on the target detection result of the document image to be detected to obtain an adjusted foreground mask; Based on the adjusted foreground mask and the pixel plate, filling the background color and foreground color of the adjusted foreground mask to obtain a denoised image, specifically comprising: using the background color as the background color of the adjusted foreground mask; based on the Euclidean distance between the pixel plate and the non-background color in the document image to be detected, using the corresponding color in the pixel plate with the shortest Euclidean distance as the assigned color, filling the foreground color of the adjusted foreground mask to obtain the denoised image; Image enhancement is performed based on the difference between the denoised image and the background color in the document image to be detected to obtain a denoising result.

2. The noise reduction method according to claim 1, wherein: Determining the foreground mask of the document image to be detected based on the HSV color space distance and adaptive binarization specifically includes: Converting the document image to be detected from an RGB color space image to an HSV color space image; Generate a first mask based on threshold comparison of saturation and brightness of the HSV color space image; Adaptively perform local binarization on the RGB color space image to generate a second mask; The first mask and the second mask are combined to obtain a foreground mask.

3. The noise reduction method according to claim 1, wherein: The target detection result of the document image to be detected includes at least one of a fingerprint, a red seal, a photo, a nail hole, a saddle seal, and a portrait. The adjusting the foreground mask based on the target detection result of the document image to be detected to obtain the adjusted foreground mask specifically includes: If the target detection result includes a portrait and / or a photo, the corresponding elements of the portrait and / or the photo in the foreground mask are retained; If the target detection result includes nail marks and / or nail holes, repairing corresponding elements of the nail marks and / or nail holes in the foreground mask; If the target detection result includes a red seal, separating the foreground and background of the red seal in the target detection result, and merging the separated foreground of the red seal into the foreground mask; If the target detection result includes a fingerprint, the foreground and background of the fingerprint in the target detection result are separated, and the separated foreground of the fingerprint is merged into the foreground mask.

4. The noise reduction method according to claim 3, wherein: If the target detection result includes nail marks and / or nail holes, repairing corresponding elements of the nail marks and / or nail holes in the foreground mask specifically includes: If the target detection result includes nail marks and / or nail holes, the inpaint method is used to repair the corresponding elements of the nail marks and / or nail holes in the foreground mask.

5. The noise reduction method according to claim 3, wherein: If the target detection result includes a red seal, separating the foreground and background of the red seal in the target detection result, and merging the separated foreground of the red seal into the foreground mask, specifically including: If the target detection result includes a red seal, a color filtering method is used to separate the foreground and background of the red seal in the target detection result, and the separated foreground of the red seal is merged into the foreground mask.

6. The noise reduction method according to claim 3, wherein: If the target detection result includes a fingerprint, separating the foreground and background of the fingerprint in the target detection result, and merging the foreground of the separated fingerprint into the foreground mask, specifically includes: If the target detection result includes a fingerprint, a video background extraction method is used to separate the foreground and background of the fingerprint in the target detection result, and the separated foreground of the fingerprint is merged into the foreground mask.

7. A document image noise reduction device, characterized in that: The noise reduction device comprises: A background color determination module determines the pixel value and pixel plate of the background color of the document image to be detected, wherein the background color and pixel plate are obtained by cross-sampling the document image to be detected, and the pixel value of the background color of the document image to be detected is determined, specifically including: selecting symmetrical pixel points from the document image to be detected as cross-sampling pixel points according to a preset number of sampling points; quantizing the cross-sampling pixel points according to a preset number of colors to obtain a cross-sampling result; using the color with the highest frequency in the cross-sampling result as the background color of the document image to be detected; and obtaining the pixel value of the background color based on the background color of the document image to be detected; obtaining the pixel plate specifically includes: adding the non-background colors in the cross-sampling result to a color queue, sorting the colors in the color queue according to a preset color rule, and extracting the sorted color queue according to a preset time interval to obtain the pixel plate; A foreground determination module, which determines the foreground mask of the document image to be detected based on HSV color space distance and adaptive binarization; an adjustment module, which adjusts the foreground mask based on the target detection result of the document image to be detected to obtain an adjusted foreground mask; a filling module, based on the adjusted foreground mask and the pixel plate, filling the background color and foreground color of the adjusted foreground mask to obtain a denoised image, specifically comprising: using the background color as the background color of the adjusted foreground mask; and based on the Euclidean distance between the pixel plate and the non-background color in the document image to be detected, filling the foreground color of the adjusted foreground mask with the corresponding color in the pixel plate with the shortest Euclidean distance as the assigned color to obtain the denoised image; The enhancement module performs image enhancement based on the difference between the denoised image and the background color in the document image to be detected to obtain a denoising result.

Citation Information

Patent Citations

  • Document image denoising method based on seal recognition, server and storage medium

    CN110443773A

  • Document image noise reduction method based on foreground masking

    CN110807747A