Method and device for removing seal of electronic certificate and electronic equipment
By obtaining seal position information and using the dark channel defog removal algorithm to process electronic certificate pictures, the problem of poor seal removal effect in the existing technology is solved, and high accuracy and efficient seal removal is achieved, which is suitable for automated processing of electronic certificates.
Patent Information
- Application Number
- CN202411021819.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2024-11-15
AI Technical Summary
The prior art does not work well when removing seals from electronic document pictures, especially due to insufficient training data and relying on manual operations, resulting in limited automated processing flow.
By obtaining seal position information, separating seal images from non-seal images, using dark channel defog algorithm to enhance and suppress seal pixels, remove seal pixels, and finally merge non-seal images to obtain target electronic certificate images that remove seal interference.
It improves the accuracy and efficiency of seal removal, simplifies the calculation method, is suitable for widespread use, can effectively remove seals and enhance covered text information.
Smart Images

Figure CN118967430A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image processing, and specifically relates to a method, device and electronic equipment for removing seals from electronic certificates. Background Art
[0002] With the development of technology and the popularization of digital services, uploading electronic certificate images as information proof has been supported in various batch registration and review scenarios. However, the seals in some electronic certificates are fixedly stamped on the text area involving personal information, and this part of the information is somewhat obscured.
[0003] In the related technology, one type of method for removing seals from electronic certificate images is seal removal technology based on artificial intelligence. However, this type of method needs to be trained based on a sufficiently diverse labeled data set. Electronic certificates are closely related to personal privacy and are difficult to obtain in large quantities. Insufficient training data can easily lead to poor results in the final seal removal. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a method, device and electronic device for removing seals from electronic certificates, which can solve the problem of poor effect of removing seals from electronic certificate images.
[0005] In a first aspect, an embodiment of the present application provides a method for removing seals from an electronic certificate, the method comprising: obtaining a seal image and a non-seal image of an electronic certificate image based on seal position information; obtaining a dehazed image by enhancing seal pixels and text pixels in the seal image and suppressing noise pixels in the seal image; removing the seal pixels in the dehazed image to obtain a seal-removed image; merging the non-seal image with the seal-removed image to obtain a target electronic certificate image with seal interference removed.
[0006] In the second aspect, an embodiment of the present application provides a device for removing seals from electronic certificates, the device comprising: a first acquisition module, used to acquire a seal image and a non-seal image of an electronic certificate image based on seal position information; a second acquisition module, used to acquire a dehazed image by enhancing seal pixels and text pixels in the seal image and suppressing noise pixels in the seal image; a third acquisition module, used to remove the seal pixels in the dehazed image and acquire a seal-removed image; and a fourth acquisition module, used to merge the non-seal image with the seal-removed image to obtain a target electronic certificate image with seal interference removed.
[0007] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.
[0008] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0009] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.
[0010] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.
[0011] In the embodiment of the present application, the seal image and the non-seal image of the electronic certificate image can be obtained according to the seal position information; the seal pixels and text pixels in the seal image are enhanced, and the noise pixels in the seal image are suppressed to obtain the defogging image; the seal pixels in the defogging image are removed to obtain the seal removal image; finally, the non-seal image and the seal removal image are merged to obtain the target electronic certificate image with the seal interference removed. Not only can the seal be effectively removed, but the text information covered by the seal can also be enhanced. The seal removal accuracy is high, and the calculation method is simple and easy to implement, which is suitable for wide use. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 A schematic diagram of a process for removing a seal from an electronic document provided in an embodiment of the present application is shown;
[0013] Figure 2 A schematic diagram showing a functional module diagram of electronic seal removal provided in an embodiment of the present application;
[0014] Figure 3 A schematic diagram of the structure of a device for removing a seal from an electronic document provided in an embodiment of the present application is shown;
[0015] Figure 4 A structural block diagram of an electronic device provided by an exemplary embodiment of the present application is shown;
[0016] Figure 5 A structural block diagram of another electronic device provided by an exemplary embodiment of the present application is shown. DETAILED DESCRIPTION
[0017] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0018] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0019] With the development of science and technology and the popularization of digital services, the use of electronic certificates is becoming more and more widespread and convenient, becoming one of the trends in digital development. With the promotion of electronic certificates, uploading electronic certificate images as information proof is supported in various batch registration and review scenarios.
[0020] The seals in some electronic certificates are fixedly stamped on the text area involving personal information, and this part of information is blocked to a certain extent. Under manual review, this part of information is easy to distinguish. However, in the context of the increasingly popular automatic batch extraction of certificate information based on optical character recognition (OCR) and other technologies, the problem of seals in electronic certificate images blocking the text information of the certificate has been highlighted. Since the position of the seals in electronic certificates is fixed, it is easy for the text information in an electronic certificate image to be unrecognizable, which means that all electronic certificate images of this type cannot be recognized. Therefore, to ensure the smooth operation of the automated processing flow of electronic certificates, it is necessary to effectively deal with the problem of seals in electronic certificates blocking the text.
[0021] In the related art, the methods for removing seals from electronic certificate images mainly include the following categories:
[0022] The first category is the stamp removal technology based on image processing tools such as Adobe Photoshop / Photoshop. Using professional image processing software such as Photoshop, the stamp area in the image is dynamically replaced.
[0023] The second category is the seal removal technology based on traditional image processing. The seal and text information in the image are separated in color gamut or structure through color model transformation, histogram statistics, morphological processing, etc., and then the seal removal technology based on artificial intelligence is used.
[0024] The third category uses artificial intelligence technology to process the original electronic certificate image or directly generate an image without the seal. For example, based on U-net (a deep learning network), the image is segmented at the pixel level, and then the pixels judged to be seals are replaced or processed; based on the Generative Adversarial Network (GAN), the generation model and the discriminant model are continuously optimized during the training process to directly generate a version of the input image without the seal.
[0025] The above three methods can meet the needs of removing seals from electronic certificate images to a certain extent, but they also have their own shortcomings. Based on the application status of the three methods in actual scenarios, the three methods are analyzed as follows:
[0026] The first type is the seal removal technology based on image processing tools such as Photoshop. This type of method is highly dependent on manual operation, requiring manual confirmation of the seal area in the image and careful processing of the image. Although the processing results obtained based on this type of technology retain text information more accurately, the reliance on manual processing is contrary to the trend of automated and streamlined processing of electronic certificates in the context of digitalization. Each image requires specific processing parameters and cannot be integrated into the intelligent automation process. More importantly, relying on manual processing of text information that can be distinguished by the human eye is meaningless in itself.
[0027] The second category is the seal removal technology based on traditional image processing. Compared with the first category of methods, the seal removal technology based on traditional image processing can realize dynamic processing of images by statistically analyzing the color channels and edge parameters of the images, which is more suitable for the needs of automated processing. For example, in a specific scheme, a method based on the statistical results of the grayscale value of the red channel is proposed to obtain the optimal threshold for judging seal pixels through iterative calculation of the maximum and minimum grayscale values and the initial threshold; in another specific scheme, the spatial features of each pixel in the LAB (a color mode, L represents luminosity, a represents the range from magenta to green, and b represents the range from yellow to blue) image are clustered to distinguish the image pixels into seals, seal edges, backgrounds and texts. This type of method realizes targeted processing of different images based on various classification algorithms for judging the boundaries between seal pixels and text pixels, greatly reducing the dependence on manual work. However, the effect of this type of method on seal removal depends on the classification algorithm for distinguishing seal pixels from non-seal pixels. Due to the diversity of document types and actual scenes, the classification boundaries between pixels are difficult to determine. In addition, although electronic certificate images are clearer than those taken for paper certificates, image compression still occurs during the upload process, causing changes in the original pixel values of the image or interference from noise pixels. This has a negative impact on the judgment of parameters such as thresholds in the classification algorithm, increasing the difficulty of designing removal algorithms and reducing the versatility of such methods.
[0028] In addition, one of the reasons why the seal removal method based on traditional image processing is unstable is that this type of method needs to clarify the difference boundary between seal pixels and non-seal pixels in pixel values based on techniques such as histograms or contrast, and this boundary is generally the threshold of pixel values. However, with the compression during image upload and the differences in screenshot devices, the background pixels outside the seal and the black text pixels have a phenomenon of lighter or sudden color changes, and the difference in channel values between non-seal pixels and red seal pixels becomes smaller. The colors of the intersections of seal pixels, text pixels, noise pixels, and background pixels in the image tend to be consistent, resulting in the lack of significant differences such as steep increases in the pixel distribution curve in subsequent methods based on histogram analysis, so the accurate boundary between seal pixels and non-seal pixels cannot be determined. In addition, noise pixels caused by compression are also enhanced along with image enhancement.
[0029] The third category is the seal removal technology based on artificial intelligence. Based on back propagation and training on a specific data set, this method can obtain an end-to-end network with seal removal capabilities without manual adjustment. The trained network has a certain degree of generalization. At present, there are many technical branches based on adversarial generative networks and image segmentation networks, which have achieved results that exceed traditional methods in multiple scenarios. For example, in a specific scheme, CycleGAN (a derivative model of GAN) is used as a seal removal network, and seal samples and no-seal samples are used as model training data to achieve end-to-end removal of image seals. However, when it comes to electronic certificate scenarios, this type of method does not have obvious advantages. First of all, this type of method needs to be trained based on a sufficiently diverse annotated data set. Insufficient data will lead to underfitting of the model, and electronic certificates are closely related to personal privacy and are difficult to obtain in large quantities; the placement or shooting methods of certificates are varied, and there are many types of certificates. The current seal removal models based on GAN and other technologies generally use single-type certificate seal removal as an application scenario, and the effect is not significant when migrating to new certificate scenarios. In addition, the demand for computing power is also an important reason restricting its development. Deploying artificial intelligence (AI) models often requires graphics processing unit (GPU) resources or high-performance central processing unit (CPU).
[0030] In the related art, in the defogging algorithm based on the dark channel, the dark channel is defined as:
[0031]
[0032] Among them, J C (y) represents the dark primary color of the three channels c of the expected haze-free image J, Ω(x) represents the local area block centered on pixel x, and c represents the three channels in the red, green, and blue (RGB) color model.
[0033] In the traditional dark channel based defogging algorithm theory, the minimum channel value J in the non-fog area dark The value of should tend to 0, that is, the pixel value of at least one channel is close to 0. The final result of this method is an image in which the pixel color of non-fog objects in the foggy area is significantly enhanced.
[0034] Figure 1 A method for removing a seal from an electronic document provided by an exemplary embodiment of the present application is shown. The method 100 can be executed by an electronic device. In other words, the method can be executed by software or hardware installed in the electronic device. The electronic device can be a terminal device such as a mobile phone. Figure 1 As shown, the method mainly includes the following steps:
[0035] S101: Acquire a seal image and a non-seal image of an electronic certificate image according to seal position information.
[0036] In the embodiment of the present application, the seal image and the non-seal image of the electronic certificate image can be obtained according to the seal position information, so as to perform targeted operations on the seal image that distinguishes the electronic certificate image, which can not only improve the accuracy of seal removal, but also improve work efficiency and save resources. In an optional implementation, before obtaining the seal image and the non-seal image of the electronic certificate image according to the seal position information, the method also includes:
[0037] By performing channel separation on the electronic certificate image, a red channel in the channel is extracted to obtain a red channel grayscale image of the electronic certificate image;
[0038] According to the hierarchical subordination relationship of the contours in the red channel grayscale image, the outer contour of the red channel grayscale image is obtained, and based on the outer contour, the seal position information is obtained.
[0039] In an embodiment of the present application, the red channel of the electronic certificate image can be separated in the RGB color space and converted into a grayscale image; then, the hierarchical subordination of the contours in the red channel grayscale image is calculated through a method library such as the Open Source Computer Vision Library (opencv), and all outer contours are identified; finally, based on the outer contours, the seal position information of the electronic certificate image is obtained.
[0040] In the above optional implementation, obtaining the seal position information based on the outer contour includes:
[0041] When the radius of the minimum circumscribed circle of the outer contour is not less than a preset first threshold, obtaining a first potential circle;
[0042] Obtain a second potential circle by using the Hough circle detection method on the red channel grayscale image;
[0043] The first potential circle and the second potential circle whose overlap degree is higher than a second threshold are determined as valid circles, and seal position information is acquired according to the valid circles.
[0044] In the embodiment of the present application, the center and corresponding radius of the minimum circumscribed circle of the outer contour can be calculated, and the circumscribed circles with too small radius can be screened out, and the radius of the minimum circumscribed circle of the outer contour that is not less than the preset first threshold is selected as the first potential circle; then the second potential circle is obtained by using the Hough circle detection method on the red channel grayscale image; the first potential circle and the second potential circle whose overlap degree is higher than the second threshold are determined as valid circles, and the seal position information can be obtained based on the valid circle. It should be noted that in actual applications, the shape of the seal image can be a square tangent to the area where the valid circle is located, or a circle slightly larger than the area where the valid circle is located, and the embodiment of the present application does not make specific limitations.
[0045] The process of obtaining the seal position information in the embodiment of the present application does not require a large number of model parameters and data sets that deep learning methods rely on, and has higher positioning efficiency, which is more in line with the efficiency requirements in the use scenarios of electronic certificate images; and based on the comprehensive screening of outer contour and Hough circle detection, while covering all potential seal areas as much as possible, it can filter out possible interference from non-circular or circular-like areas.
[0046] S102: enhancing the seal pixels and text pixels in the seal image and suppressing the noise pixels in the seal image to obtain a defogging image.
[0047] In the embodiment of the present application, the seal pixels and text pixels in the seal image can be enhanced by a dark channel defogging method, and the noise pixels in the seal image can be suppressed to obtain a defogged image.
[0048] In an optional implementation, the step of suppressing noise pixels in the seal image by enhancing seal pixels and text pixels in the seal image includes:
[0049] When the seal image is processed according to the dark channel defogging algorithm, the red channel of the seal image is enhanced by using an enhancement constant so as to enhance the seal pixels and the text pixels;
[0050] When the seal image is processed according to the dark channel defogging algorithm, the non-red channel of the seal image is suppressed by adding the non-red channel to a suppression constant, so as to suppress the noise pixels in the seal image.
[0051] In the embodiment of the present application, the key pixels such as seal pixels and text pixels can be enhanced in a targeted manner, and the boundary between the key pixels and the noise pixels can be clarified, so as to avoid the interference of noise pixels (noise pixels are noise pixels other than seal pixels and text pixels caused by image propagation or compression) with the threshold calculation and other processes in the seal removal process. During the test process of the embodiment of the present application, it was found that the blurred boundary between the key pixels and the non-key pixels caused by the transmission process of the electronic certificate image can be roughly regarded as the "fogging" scene on the picture. Therefore, in the embodiment of the present application, the problem of the narrowing of the gap between the key pixels and the non-key pixels in the process of uploading the electronic certificate image and the blurred boundary is converted into a defogging task. Under the original defogging algorithm based on the dark channel, the pixel color of the non-key area in the image and the green pixels caused by compression during the image upload process will also be enhanced, which will have a negative impact on the subsequent seal removal.
[0052] The embodiment of the present application uses an improved defogging algorithm based on a dark channel to perform defogging on the seal image. In the improved defogging algorithm based on a dark channel, the non-red channel is suppressed, that is, only the red seal pixels and the black text pixels are regarded as potential fog areas (corresponding to the areas where the defogging algorithm needs to perform defogging calculations). The improved dark channel can be defined as:
[0053]
[0054] Among them, γ is the enhancement constant, and λ is the suppression constant. The brightness of the pixels in the dark channel represents whether there is fog. The idea of the improved dark channel calculation method is to adjust the dark channel area by adjusting the minimum value in the RGB channel, highlighting the two pixel areas of seal pixels and text pixels, which have high red (Red, R) channel values. In order to avoid the situation where the pixel value exceeds 255 and becomes meaningless pixel value, the green (Green, G) and blue (Blue, B) channel values are adjusted by adding to the fixed value.
[0055] The result after processing based on the improved dark channel defogging method can suppress the greenish pixels and other interfering noise pixels caused by compression while enhancing the seal and text pixels, making the seal pixels and text pixels that are the focus of attention more prominent. In addition, in the calculation process of the estimated transmittance of the dark channel defogging method, based on the actual defogging scene, a part of the fog needs to be retained to reflect the image depth of field, so the parameter ω is introduced. However, in the embodiment of the present application, it is not necessary to reflect the depth of field, and the fog in the area of concern should be removed as much as possible. Therefore, in the embodiment of the present application, the depth of field parameter ω is adjusted to be set to a constant 1.
[0056] The improved dark channel dehazing algorithm used in the embodiment of the present application has better effects in highlighting key pixel areas such as seal pixels and text pixels and suppressing noise. While enhancing the features of key pixels such as seals and text, it retains the distinction between non-key pixels, making it easier to remove seal pixels later.
[0057] S103: removing the stamp pixels in the dehazed image to obtain a stamp-removed image.
[0058] In the embodiment of the present application, the seal pixels in the dehazed image may be removed to obtain a seal-removed image.
[0059] In an optional implementation, removing the seal pixels in the defogging image to obtain the seal-removed image includes:
[0060] Step 1: for each pixel of the dehazed image, when the difference between the maximum value and the minimum value in the red, green, and blue channels of the pixel is less than the light color threshold, and the maximum value is less than the upper threshold, the pixel is determined to be a light color text pixel, and the light color text pixel is enhanced;
[0061] Step 2, for each non-light-colored text pixel of the dehazed image, if the red channel of the pixel is greater than or equal to the distinction threshold, determine that the pixel is a seal pixel, and replace the seal pixel with a pre-acquired background color pixel;
[0062] Step 3: After traversing each pixel of the dehazed image, a stamp-removed image is obtained.
[0063] In an embodiment of the present application, when removing the seal pixels in the defogged image, step 1 can be performed first to enhance the light-colored text pixels in the defogged image. In practical applications, some black text pixels in the electronic certificate image will change from the original black pixel color of the text to gray or light brown light-colored pixels due to image compression and other reasons during the image transmission process. Since the color is too light, it is easy to be regarded as noise and removed, resulting in the lack of a horizontal line in text such as "month" and "day", which affects the OCR recognition effect. In an embodiment of the present application, this type of text pixel is called a light-colored text pixel. According to experimental statistics, the R, G, and B channel values of this type of pixel are close and the R channel value is low, which is easy to be misscreened.
[0064] In the embodiments of the present application, a light color threshold α can be set. This threshold is a hyperparameter that can be adjusted and is used to determine the lower limit for judging whether a processed pixel is regarded as a light color text pixel. Then, an upper threshold β is set. This threshold is also a hyperparameter that can be adjusted and is used to judge whether a processed pixel is a non-light color text pixel. For each pixel in the dehazed image, the maximum value max and the minimum value min of the R, G, and B channels are taken. When max - min < α and max < β are satisfied, the pixel is regarded as a light color text pixel, and the color of the pixel is enhanced. When the conditions for light color text pixels are not met, no enhancement processing is performed. In the embodiments of the present application, aiming at the situation where light color text pixels in the electronic certificate scenario are easily misfiltered, resulting in damage to the text structure and affecting the recognition result, an enhancement operation for light color text pixels is specifically made, and the light color text pixels are judged and strengthened, significantly improving the problem of easy damage to the text structure.
[0065] In the embodiments of the present application, when removing the seal pixels in the dehazed image, the seal pixels can be removed by performing step 2. For each non-light color text pixel in the dehazed image, when the red channel of the pixel is greater than or equal to the discrimination threshold, it can be determined that the pixel is a seal pixel, and then the seal pixel is replaced with a pre-acquired background color pixel. The value of the background color pixel can be obtained by calculating the average value, or can be determined according to a preset pixel value that meets the user's requirements. Through the replacement operation, the interference and occlusion effects of the seal pixels on text recognition can be removed.
[0066] In an alternative implementation, the calculation method of the discrimination threshold is as follows:
[0067]
[0068] Wherein, R represents the red channel in the grayscale histogram of the electronic certificate image, and G represents the green channel in the grayscale histogram of the electronic certificate image.
[0069] In the embodiments of the present application, for the discrimination threshold thr, its calculation method can be that when the difference in the distribution numbers of the R channel and the G channel from the distribution number difference at thr to the distribution number difference at thr + i is all above 0, thr is used as the discrimination threshold of the R channel for distinguishing seals and text. The idea of this calculation method comes from the fact that after the dehazing process in S102, by statistically analyzing the pixel distribution of the seal area in the electronic seal image, it is found that the difference between the R channel value and the G channel in the seal area is obvious, and the R channel value is significantly greater than the G channel. Therefore, thr can be used as the demarcation point for determining whether the pixel is a seal pixel. If R >= thr for the pixel, the pixel is regarded as a seal pixel; when R < thr, the pixel is regarded as a text pixel and no processing is performed on it.
[0070] S104: Merging the non-seal image with the seal-removed image to obtain a target electronic certificate image with seal interference removed.
[0071] In the embodiment of the present application, the non-seal image and the seal-removed image may be merged to obtain a target electronic certificate image with seal interference removed.
[0072] In the embodiment of the present application, before the non-seal image and the seal-removed image are merged, when the color difference between the non-seal image and the seal-removed image is greater than a preset color difference threshold, the non-seal image and the seal-removed image can be uniformly processed according to a preset rule. In actual applications, the preset rule can be determined according to user needs, such as performing some special processing on pixels to meet actual needs.
[0073] In the embodiment of the present application, the seal image and the non-seal image of the electronic certificate image can be obtained according to the seal position information; the seal pixels and text pixels in the seal image are enhanced, and the noise pixels in the seal image are suppressed to obtain the defogging image; the seal pixels in the defogging image are removed to obtain the seal removal image; finally, the non-seal image and the seal removal image are merged to obtain the target electronic certificate image with the seal interference removed. Not only can the seal be effectively removed, but the text information covered by the seal can also be enhanced. The seal removal accuracy is high, the calculation method is simple and easy to implement, and the calculation efficiency is high, which is suitable for wide use.
[0074] Figure 2 A schematic diagram of the electronic seal removal function module diagram provided by the embodiment of the present application is shown, wherein the seal area denoising module can implement S102, and the seal removal module can implement S103. For the input electronic certificate image, the seal in the image is detected by the seal area positioning module, and the seal position information and the image are input into the seal area denoising module; the image is divided into two parts, the seal area and the non-seal area, in the seal area denoising module, the noise in the seal area is removed in a targeted manner, and the text pixels and seal pixels are enhanced in a targeted manner; the seal area with noise removed is sent to the seal removal module, the seal pixels are removed, and the text pixels and background pixels are retained; the processed seal area is combined with the non-seal area obtained by the seal area denoising module to obtain the final seal-free electronic certificate image.
[0075] The electronic certificate seal removal method provided in the embodiment of the present application can be executed by a device for removing electronic certificate seals. In the embodiment of the present application, the electronic certificate seal removal method is executed by the device for removing electronic certificate seals as an example to illustrate the device for removing electronic certificate seals provided in the embodiment of the present application.
[0076] Figure 3The schematic diagram of the structure of the electronic document seal removal device provided by an exemplary embodiment of the present application is shown. The electronic document seal removal device can be implemented as follows: Figure 1 In the embodiment shown, all or part of the contents, the device for removing electronic certificate seal includes: a first acquisition module 301 , a second acquisition module 302 , a third acquisition module 303 and a fourth acquisition module 304 .
[0077] In an embodiment of the present application, a first acquisition module 301 is used to acquire a seal image and a non-seal image of an electronic certificate image based on seal position information; a second acquisition module 302 is used to acquire a dehazed image by enhancing seal pixels and text pixels in the seal image and suppressing noise pixels in the seal image; a third acquisition module 303 is used to remove the seal pixels in the dehazed image and acquire a seal-removed image; and a fourth acquisition module 304 is used to merge the non-seal image with the seal-removed image to obtain a target electronic certificate image with seal interference removed.
[0078] In an optional implementation, before being used to obtain the seal image and the non-seal image of the electronic document image according to the seal position information, the first acquisition module 301 is further used to:
[0079] By performing channel separation on the electronic certificate image, a red channel in the channel is extracted to obtain a red channel grayscale image of the electronic certificate image;
[0080] According to the hierarchical subordination relationship of the contours in the red channel grayscale image, the outer contour of the red channel grayscale image is obtained, and based on the outer contour, the seal position information is obtained.
[0081] In an optional implementation, when the first acquisition module 301 is used to acquire the seal position information based on the outer contour, it is specifically used to:
[0082] When the radius of the minimum circumscribed circle of the outer contour is not less than a preset first threshold, obtaining a first potential circle;
[0083] Obtain a second potential circle by using the Hough circle detection method on the red channel grayscale image;
[0084] The first potential circle and the second potential circle whose overlap degree is higher than a second threshold are determined as valid circles, and seal position information is acquired according to the valid circles.
[0085] In an optional implementation, when the second acquisition module 302 is used to suppress noise pixels in the seal image by enhancing the seal pixels and text pixels in the seal image, it is specifically used to:
[0086] When the seal image is processed according to the dark channel defogging algorithm, the red channel of the seal image is enhanced by using an enhancement constant so as to enhance the seal pixels and the text pixels;
[0087] When the seal image is processed according to the dark channel defogging algorithm, the non-red channel of the seal image is suppressed by adding the non-red channel to a suppression constant, so as to suppress the noise pixels in the seal image.
[0088] In an optional implementation, the third acquisition module 303, when used to remove the seal pixels in the defogging image and obtain the seal-removed image, is specifically used to:
[0089] For each pixel of the defogging image, when the difference between the maximum value and the minimum value in the red, green and blue channels of the pixel is less than the light color threshold, and the maximum value is less than the upper threshold, the pixel is determined to be a light color text pixel, and the light color text pixel is enhanced;
[0090] For each non-light-colored text pixel of the dehazed image, if the red channel of the pixel is greater than or equal to a discrimination threshold, determine that the pixel is a seal pixel, and replace the seal pixel with a pre-acquired background color pixel;
[0091] After traversing each pixel of the dehazed image, a stamp-removed image is obtained.
[0092] In an optional implementation, the distinction threshold is calculated as follows:
[0093]
[0094] Wherein, R represents the red channel in the grayscale histogram of the electronic certificate image, and G represents the green channel in the grayscale histogram of the electronic certificate image.
[0095] The electronic document seal removal device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a palmtop computer, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.
[0096] The electronic certificate seal removal device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0097] The electronic certificate seal removal device provided in the embodiment of the present application can achieve Figure 2 To avoid repetition, the various processes implemented in the illustrated method embodiment will not be described again here.
[0098] Alternatively, if Figure 4 As shown, an embodiment of the present application also provides an electronic device 400, including a processor 401 and a memory 402, wherein the memory 402 stores a program or instruction that can be executed on the processor 401, and when the program or instruction is executed by the processor 401, the various steps of the above-mentioned method for removing the electronic certificate seal are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0099] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0100] Figure 5FIG. 1 is a block diagram of another electronic device 500 according to an exemplary embodiment of the present application. The electronic device 500 may be implemented as a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart watch, a TV, etc. The electronic device 500 may also be referred to as a user device, a portable terminal, a laptop terminal, a desktop terminal, etc.
[0101] Typically, the electronic device 500 includes a processor 501 and a memory 502 .
[0102] The processor 501 may include one or more processing cores, such as a 4-core processor, a 10-core processor, etc. The processor 501 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 501 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 501 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 501 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0103] The memory 502 may include one or more computer-readable storage media, which may be non-transitory. The memory 502 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 502 is used to store at least one instruction, which is used to be executed by the processor 501 to implement all or part of the steps in the method for removing the electronic certificate seal shown in the method embodiment of the present application.
[0104] In some embodiments, the electronic device 500 may further optionally include: a peripheral device interface 503 and at least one peripheral device. The processor 501, the memory 502 and the peripheral device interface 503 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 503 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 504, a display screen 505, a camera assembly 506, an audio circuit 507 and a power supply 508.
[0105] In some embodiments, the electronic device 500 further includes one or more sensors 509 , including but not limited to: an acceleration sensor 510 , a gyroscope sensor 511 , a pressure sensor 512 , an optical sensor 513 , and a proximity sensor 514 .
[0106] Those skilled in the art will understand that Figure 5 The structure shown in the figure does not constitute a limitation on the electronic device 500, and may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.
[0107] An embodiment of the present application also provides a computer-readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned method for removing the electronic certificate seal are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0108] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0109] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned method for removing electronic certificate seals, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0110] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0111] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the method for removing the electronic certificate seal as described above, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0112] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0113] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0114] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A method for removing a seal from an electronic document, It is characterized in that include: Acquire a seal image and a non-seal image of the electronic certificate image according to the seal position information; The defogging image is obtained by enhancing the seal pixels and the text pixels in the seal image and suppressing the noise pixels in the seal image; Removing the seal pixels from the defogging image to obtain a seal-removed image; The non-seal image is combined with the seal-removed image to obtain a target electronic certificate image with seal interference removed.
2. The method according to claim 1, It is characterized in that Before acquiring the seal image and the non-seal image of the electronic document image according to the seal position information, the method further includes: By performing channel separation on the electronic certificate image, a red channel in the channel is extracted to obtain a red channel grayscale image of the electronic certificate image; According to the hierarchical subordination relationship of the contours in the red channel grayscale image, the outer contour of the red channel grayscale image is obtained, and based on the outer contour, the seal position information is obtained.
3. The method according to claim 2, It is characterized in that Based on the outer contour, obtaining the seal position information includes: When the radius of the minimum circumscribed circle of the outer contour is not less than a preset first threshold, obtaining a first potential circle; Obtain a second potential circle by using the Hough circle detection method on the red channel grayscale image; The first potential circle and the second potential circle whose overlap degree between the first potential circle and the second potential circle is higher than a second threshold are determined as valid circles, and seal position information is acquired according to the valid circles.
4. The method according to claim 1, It is characterized in that The method of suppressing noise pixels in the seal image by enhancing seal pixels and text pixels in the seal image includes: When the seal image is processed according to the dark channel defogging algorithm, the red channel of the seal image is enhanced by using an enhancement constant so as to enhance the seal pixels and the text pixels; When the seal image is processed according to the dark channel defogging algorithm, the non-red channel of the seal image is suppressed by adding the non-red channel to a suppression constant, so as to suppress the noise pixels in the seal image.
5. The method according to claim 1, It is characterized in that The step of removing the seal pixels in the defogging image to obtain the seal-removed image comprises: For each pixel of the defogging image, when the difference between the maximum value and the minimum value in the red, green and blue channels of the pixel is less than the light color threshold, and the maximum value is less than the upper threshold, the pixel is determined to be a light color text pixel, and the light color text pixel is enhanced; For each non-light-colored text pixel of the dehazed image, if the red channel of the pixel is greater than or equal to a discrimination threshold, determine that the pixel is a seal pixel, and replace the seal pixel with a pre-acquired background color pixel; After traversing each pixel of the dehazed image, a stamp-removed image is obtained.
6. The method according to claim 5, It is characterized in that The calculation method of the distinction threshold is: Wherein, R represents the red channel in the grayscale histogram of the electronic certificate image, and G represents the green channel in the grayscale histogram of the electronic certificate image.
7. A device for removing seals from electronic documents, It is characterized in that include: A first acquisition module, used for acquiring a seal image and a non-seal image of the electronic certificate image according to the seal position information; A second acquisition module is used to acquire a defogging image by enhancing the seal pixels and text pixels in the seal image and suppressing the noise pixels in the seal image; A third acquisition module is used to remove the seal pixels in the defogging image to obtain a seal-removed image; The fourth acquisition module is used to merge the non-seal image with the seal-removed image to obtain a target electronic certificate image with seal interference removed.
8. An electronic device, It is characterized in that The electronic device includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the method for removing an electronic certificate seal as described in any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the method for removing an electronic certificate seal as described in any one of claims 1 to 6 are implemented.
10. A computer program product, It is characterized in that The computer program product stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the method for removing an electronic certificate seal as claimed in any one of claims 1 to 6 are implemented.
