Seal image processing method and device and electronic equipment
By using downsampling and upsampling processing combined with variability convolution algorithm in stamp image processing, the problem of poor noise removal effect in the prior art is solved, and the retention rate and recognition accuracy of text features are improved.
Patent Information
- Application Number
- CN202411667228.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-04-25
AI Technical Summary
The prior art has poor noise removal effect when processing seal images, resulting in difficulty in identifying.
By acquiring the target image, downsampling and upsampling are performed using the first seal processing model, the text feature probability of the pixel is calculated in combination with the variability convolution algorithm, and the weight value of the pixel is determined based on the probability to enhance the retention of text features and noise removal of text features.
It improves the retention rate of text features in seal images, enhances the noise removal effect, and improves the accuracy of subsequent recognition.
Smart Images

Figure CN119887565A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a seal image processing method and device and electronic equipment. Background Art
[0002] With the continuous development of science and technology, people are increasingly handling various affairs through the Internet, which has also made electronic documents widely used in people's work and life. Although electronic documents are easy to spread, they are also easy to tamper with. Therefore, for various documents that need to confirm identity or produce legal effect, it is still necessary to use traditional seals to stamp on paper documents to ensure the authenticity and reliability of the content. However, for the convenience of dissemination and processing, after using the seal to stamp the paper document, the signed paper document can be processed electronically, for example, scanned to obtain an electronic file. In this case, the processing of the seal image scanned in the electronic file becomes particularly important for correctly identifying the content of the electronic file and confirming the authenticity and reliability of the electronic file.
[0003] However, in the process of scanning paper, background noise will inevitably be introduced into the electronic document obtained by scanning, and after the seal image is superimposed with this background noise, it will bring great difficulties to the subsequent recognition. Therefore, a seal processing solution that can improve the accuracy of seal image recognition is needed. Summary of the invention
[0004] The embodiments of the present application provide a seal image processing method and device and an electronic device to solve the defect of poor noise removal effect when processing seal images in the prior art.
[0005] In order to achieve the above technical objectives, the present application embodiment proposes a seal image processing method, comprising:
[0006] Get the target image;
[0007] Performing a first number of downsampling processes on the target image using a first seal processing model to obtain a first processed image, wherein before each downsampling process, the downsampled image is first processed using a variable convolution algorithm to obtain a probability that each pixel in the image belongs to a text feature, and determining a first weight value of each pixel based on a difference between the probability of each pixel and a preset threshold;
[0008] The first processed image is subjected to the first amount of upsampling processing using the first seal processing model to obtain a second processed image, wherein in each upsampling processing, pixels to be retained are determined based on a first weight value of a downsampled image corresponding to the image subjected to the upsampling processing.
[0009] Another embodiment of the present application provides a seal image processing device, comprising:
[0010] An acquisition module, used for acquiring a target image;
[0011] A downsampling processing module, used for performing a first number of downsampling processes on the target image using a first seal processing model to obtain a first processed image, wherein before each downsampling process, the downsampled image is first processed using a variable convolution algorithm to obtain a probability that each pixel in the image belongs to a text feature, and a first weight value of each pixel is determined based on a difference between the probability of each pixel and a preset threshold;
[0012] An upsampling processing module is used to perform the first amount of upsampling processing on the first processed image using the first seal processing model to obtain a second processed image, wherein in each upsampling processing, the pixels that need to be retained are determined based on the first weight value of the downsampled image corresponding to the image of the upsampling processing.
[0013] The present application also provides an electronic device, including:
[0014] Memory, used to store programs;
[0015] The processor is used to run the program stored in the memory to execute the seal image processing method according to the embodiment of the present application.
[0016] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program executable by a processor is stored, wherein the program, when executed by the processor, implements the seal image processing method provided in the embodiment of the present application.
[0017] According to the seal image processing method, device and electronic device of the embodiments of the present application, a target image is acquired; a first seal processing model is used to perform a first number of downsampling processes on the target image to obtain a first processed image, wherein before each downsampling process, the downsampled image is first processed using a variable convolution algorithm to obtain the probability that each pixel in the image belongs to a text feature, and a first weight value of each pixel is determined based on the difference between the probability of each pixel and a preset threshold value; the first processed image is upsampled the first number of times using the first seal processing model to obtain a second processed image, wherein in each upsampling process, the pixels to be retained are determined based on the first weight value of the downsampled image corresponding to the image processed by the upsampling process. Therefore, using the seal image processing method according to the embodiment of the present application, variable convolution processing can be performed first when downsampling the target image. In this processing, the weight value of the pixel with text features can be enhanced in each downsampling process by making the pixels with a higher probability of belonging to the text feature have a larger weight, and in the upsampling process, the pixels that need to be retained are determined based on the weight values obtained in the corresponding downsampling process, so that more pixels with text features can be retained in the processed image, thereby improving the noise removal effect.
[0018] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0020] Figure 1 A flowchart of an embodiment of the seal image processing method provided by the present application;
[0021] Figure 2 A schematic structural diagram of an embodiment of a seal image processing device provided by the present application;
[0022] Figure 3 A schematic diagram of the structure of an electronic device embodiment provided in this application. DETAILED DESCRIPTION
[0023] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0024] Embodiment 1
[0025] With the rapid advancement of science and technology, people are increasingly relying on the Internet to handle various matters, which has led to the widespread use of electronic documents in daily work and life. Although electronic documents are easy to disseminate, they are easy to be tampered with. In documents that require identity verification or have legal effect, traditional seals are still needed on paper documents to ensure the authenticity and reliability of the content. However, in order to facilitate dissemination and processing, after stamping on paper documents, they can be converted into electronic files by scanning. In this case, how to process the scanned seal image in the electronic file becomes particularly important for correctly identifying the content of the file and confirming its authenticity and reliability.
[0026] However, when scanning paper documents, background noise is inevitably introduced. This noise is superimposed on the seal image, which brings great difficulties to the subsequent recognition work. In the prior art, the following methods are mainly used to remove background noise in seal images:
[0027] 1. Background removal: The features of the seal image are extracted through the neural network model to generate feature images of the seal and background. The seal image is segmented using the segmentation decoder to obtain an image with the seal as the foreground. Then, the seal is removed through the background removal module based on the seal image, background feature image and segmented image to obtain an image without background noise.
[0028] 2. Mask guidance: The seal positioning module creates a mask to represent the seal position, extracts the texture information of the background text, and passes this information and the mask to the seal removal module. This module removes the seal while retaining the background text, thus removing the seal background.
[0029] 3. Color channel separation: Separate the color channels of the image, extract the color channel corresponding to the stamp area, and segment the image to generate a binary image containing the stamp and background areas. Create a mask image, use the image restoration algorithm to repair the stamp area in the mask image, and then overlay the restored image on the original image to obtain the target image after removing the stamp.
[0030] However, the current seal image background removal technology faces multiple challenges in the implementation process. First, the cost issue is significant. The complex neural network model and the need for a large amount of computing resources make it costly when applied in resource-limited environments. In addition, data acquisition is difficult. Usually, a large amount of seal data without background and seal data with added noise are required, and the collection of these data is often difficult and the noise distribution is difficult to match the actual application. In terms of efficiency, the feature extraction and image segmentation process of the neural network model may require multiple iterations, especially in the processing of high-resolution or complex background images, the processing time is long, affecting the overall efficiency. Structurally, the seal removal model and the mask-guided method involve the collaboration of multiple modules, such as feature extraction, image segmentation, and mask generation, which leads to a complex algorithm structure, difficult to maintain and optimize, and increases the difficulty of porting and deployment on different platforms or devices. In terms of accuracy, in the case of poor seal image quality, such as blur, occlusion or uneven illumination, the existing technology often finds it difficult to accurately identify the seal area, and the complex and diverse background noise also reduces the recognition accuracy. Generalization ability is also a problem. Although it performs well on specific types of seal images, the generalization ability of the technology may be insufficient when faced with seal images of different styles, shapes or colors. The color channel separation method has specific requirements for image quality and color distribution, which limits its application under various conditions, especially in images with color distortion or incomplete color information, where the method may be ineffective. In addition, as the diversity and complexity of seal images increase, existing technologies may appear weak in responding to new challenges and need to be retrained or adjusted to adapt to new seal designs or background noise types, increasing maintenance costs. Finally, under different lighting conditions, seal materials or background complexity, the robustness of existing technologies is insufficient, which affects the effect of removing background noise, and may not provide stable and reliable processing results in dynamically changing environments or conditions.
[0031] To this end, the present application embodiment proposes a seal image processing method, which can modify the processing model to be used based on the text features of the current seal image when processing the current seal image, thereby improving the accuracy of background noise recognition. Figure 1 is a flow chart showing the seal image processing method according to the present application. Figure 1 As shown in , the seal image processing method according to the embodiment of the present application includes:
[0032] S101, acquiring a target image;
[0033] In step S101, a target image as a recognition target can be obtained. For example, the target image can be an image obtained by a user scanning or photographing a paper contract document, or can be an image of a contract document or a certificate uploaded by another person and obtained by the user from the Internet. In addition, in step S101, a seal image contained in the target image obtained in this way can be obtained as the first seal image. For example, various seal image detection means can be used to detect the position where the seal image exists in the target image, and then the image at the position is extracted as the first seal image.
[0034] For example, in an embodiment of the present application, a target detection algorithm may be first used to determine the area where the seal is located, and then a feature extraction algorithm may be used to extract seal features from the image of the area, and the position information of the seal may be determined based on the extracted seal features and image information of the target image, such as pixel coordinates. In an embodiment of the present application, the position information of the seal may be the coordinates of the pixels constituting the seal. Based on the position information of the seal, various seal document detection methods may be further combined to determine the area where the seal is located, so that the image of the area may be intercepted and used as the first seal image.
[0035] S102: Perform a first amount of downsampling processing on the target image using a first seal processing model to obtain a first processed image.
[0036] In step S102, the target image acquired in step S101 may be subjected to multiple downsampling processes using the first seal processing model. For example, in an embodiment of the application, the first seal processing model may be a Unet model. And before each downsampling process, the downsampled image may be processed using a variable convolution algorithm to obtain the probability that each pixel in the image belongs to a text feature, and the first weight value of each pixel is determined based on the difference between the probability of each pixel and a preset threshold. For example, in an embodiment of the present application, a variable convolution may be used to calculate the characteristic value of each pixel for the target image, and the probability that each pixel within a predetermined range is a text feature is determined based on the characteristic value. Then the probability of each pixel calculated in this way can be compared with a preset threshold. If the probability of a certain pixel is greater than the preset threshold, the pixel may be a text feature, and if the difference between the probability and the preset threshold is larger, that is, it is larger than the preset threshold, then the probability that the pixel is a text feature is also greater. On the contrary, if the probability of a pixel in a certain area is less than the preset threshold, the probability that the pixel is a text feature is smaller, that is, it may be noise, and if the difference between the probability and the preset threshold is larger, that is, it is smaller than the preset threshold, then the probability that the pixel is noise is also greater. Therefore, in step S102, the weight value of each pixel can be further determined based on the difference between the probability value and the preset threshold, that is, the pixel with a greater probability of belonging to a text feature can be determined to have a larger weight value, and the pixel with a greater probability of being noise can be determined to have a smaller weight value. In addition, a convolution calculation can be performed before each downsampling process to determine the weight value of each pixel in the current image.
[0037] S103: Perform a first amount of upsampling processing on the first processed image using the first seal processing model to obtain a second processed image.
[0038] In step S103, the first processed image obtained after multiple downsampling processes using the first seal processing model in step S102 may be further upsampled multiple times using the first seal processing model. In the embodiment of the present application, the number of upsampling processes may be the same as the number of downsampling processes, so that each upsampling process may correspond to a downsampling process, and therefore in each upsampling process, the pixels to be retained may be determined based on the first weight value of the downsampled image corresponding to the image of the upsampling process. In the upsampling process, interpolation processing can be performed based on the first weight values of the pixels in the corresponding downsampled image based on each pixel of the upsampled image to obtain a processed image with more pixels. Therefore, by performing multiple upsampling processes, the compressed image after the same number of downsampling processes can be restored to a second processed image with the same size or resolution as the target image. Since the first weight value of the corresponding downsampled image is used in the interpolation process during the upsampling process to determine the pixels to be retained in the second processed image, pixels with a higher probability, that is, pixels closer to text features, can be retained in the final restored upsampled image, so that noise can be removed and text can be retained in the final second processed image.
[0039] In addition, in the embodiment of the present application, after the second processed image is obtained, the noise probability of each pixel in the image belonging to the noise feature can also be calculated for the second processed image, and then it can be determined whether the noise probability of each pixel is greater than the first noise threshold. When the number of pixels whose noise probability is greater than the preset noise threshold exceeds the predetermined number threshold, it can mean that the noise processing effect of the second processed image does not meet the preset standard, and therefore the downsampling process in step S102 and the upsampling process in step S103 can be repeated for the second processed image until the number of pixels whose noise probability is greater than the preset noise threshold is less than the number threshold.
[0040] In addition, in the embodiment of the present application, the text features can also be extracted based on the first seal image extracted or determined in the target image acquired in step S101. For example, various text feature extraction algorithms or text feature extraction models can be used to detect and extract text features from the first seal image. While extracting the text features, the position information corresponding to the text features, such as relative position information, can also be determined based on the image information of the target image, such as pixel coordinate information. In the embodiment of the present application, the position information of the text feature can be the relative position of the center point or edge of the text feature relative to the edge of the seal image, or when the specification of the target image is determined, such as when the target image is determined to be A4 paper size, the position information of the text feature can also be the pixel coordinate information of the feature in the A4 paper area. Therefore, in the embodiment of the present application, each text feature extracted from the seal image and the corresponding position information can also be associated with each other as the first feature information. Then the first seal processing model can be modified based on the extracted first feature information. For example, in an embodiment of the present application, the attention module used in the variable convolution processing can be modified based on the various text features contained in the first feature information, so that the parameters in the attention module can reflect these text features, that is, the second seal processing module obtained after the modification can include parameters generated according to the various text features in the first feature information and with reference to the corresponding position information.
[0041] For example, in an embodiment of the present application, the similarity between the position information of each text feature in the first seal image and the position information of the preset seal text feature can be calculated based on the various text features contained in the first feature information and the corresponding position information. When the similarity of the calculated position information is greater than the preset position threshold, the similarity between the text feature corresponding to the position information in the first seal image and the preset seal text feature at the corresponding position is further calculated to determine the text feature whose similarity is greater than the preset image threshold as the text feature information of the first seal image. Then, the attention module in the first seal processing model can be updated based on the determined text feature information, for example, the parameters in the attention module are generated according to the text feature information, thereby generating the second seal processing model.
[0042] In addition, in the embodiment of the present application, the noise threshold can be updated each time after the second processed image is obtained, so that the same preset standard is not always used when performing noise detection after each round of multiple upsampling processes, but the noise threshold used at the time can be updated each time according to the processing results of the previous round, so that the speed of iterative convergence can be accelerated, and it can also be ensured that the noise threshold used each time can more accurately reflect the characteristic distribution characteristics of the seal image processed at the time. For example, after the noise feature information of the seal image generated last time is calculated, the preset text feature information corresponding to the first noise threshold is first obtained, and the similarity between the first feature information and each feature contained in the preset text feature information is calculated, and then the second noise threshold is calculated based on the similarity and the first noise threshold, and the second noise threshold is used as the first noise threshold used to determine whether the noise value of the seal image meets the requirements at the time.
[0043] In addition, in the embodiment of the present application, the first processing model can be trained in advance. For example, a first group of seal images can be obtained first. Such seal images can be seal images that have been manually screened in advance, or can also be seal images that have been noise-processed and obtained through the Internet. For example, each seal image in the first group of seal images can contain its own seal image and does not contain noise features. In the embodiment of the present application, the seal image obtained in this way can also contain noise features with characteristic values lower than a predetermined standard, that is, it can be a seal image containing a small amount of noise features. Then, a preset noise generation algorithm can be used to generate noise to be superimposed based on the text features of the seal image, and a noise image can be generated based on the generated noise to be superimposed. Then, the noise image is superimposed with the corresponding seal image to generate a noisy seal image. Thus, a seal image in which the noise features are known can be obtained. Therefore, the noisy seal image and the corresponding seal image can be used as training data to train the preset seal processing model to obtain the first seal processing model.
[0044] In addition, when the seal processing model is trained, the noise type information can be further added to the training data obtained in the above manner. For example, the similarity of the standard noise feature corresponding to the preset noise type can be calculated based on the noise feature of the noise to be superimposed, and the noise type of the noise to be superimposed can be determined based on the similarity. Therefore, the seal processing model can be optimized for different types of noise, so that the trained seal processing model can identify noise more accurately.
[0045] According to the seal image processing method of the embodiment of the present application, a target image is obtained; the target image is subjected to a first number of downsampling processes using a first seal processing model to obtain a first processed image, wherein before each downsampling process, the downsampled image is first processed using a variable convolution algorithm to obtain the probability that each pixel in the image belongs to a text feature, and the first weight value of each pixel is determined based on the difference between the probability of each pixel and a preset threshold; the first processed image is subjected to the first number of upsampling processes using the first seal processing model to obtain a second processed image, wherein in each upsampling process, the pixels to be retained are determined based on the first weight value of the downsampled image corresponding to the image subjected to the upsampling process. Therefore, using the seal image processing method according to the embodiment of the present application, a variable convolution process can be performed first when the target image is subjected to downsampling process, in which the weight value of the pixel with the text feature can be enhanced in each downsampling process by making the pixel with a larger probability of belonging to the text feature have a larger weight, and the pixels to be retained are determined based on the weight value obtained in the corresponding downsampling process in the upsampling process, so that more pixels with text features can be retained in the processed image, thereby improving the effect of noise removal.
[0046] Embodiment 2
[0047] Figure 2 This is a schematic diagram of the structure of an embodiment of the seal image processing device provided by the present application. Figure 2 As shown in , the seal image processing device provided in the embodiment of the present application may include: an acquisition module 21, a downsampling processing module 22 and an upsampling processing module 23.
[0048] The acquisition module 21 can be used to acquire a target image;
[0049] The acquisition module 21 can acquire a target image as a recognition target. For example, the target image can be an image obtained by a user scanning or photographing a paper contract document, or it can be an image of a contract document or a certificate uploaded by another person and obtained by the user from the Internet. In addition, the acquisition module 21 can also acquire a seal image contained in the target image acquired in this way as the first seal image. For example, various seal image detection means can be used to detect the position where the seal image exists in the target image, and then the image at the position is extracted as the first seal image.
[0050] For example, in an embodiment of the present application, a target detection algorithm may be first used to determine the area where the seal is located, and then a feature extraction algorithm may be used to extract seal features from the image of the area, and the position information of the seal may be determined based on the extracted seal features and image information of the target image, such as pixel coordinates. In an embodiment of the present application, the position information of the seal may be the coordinates of the pixels constituting the seal. Based on the position information of the seal, various seal document detection methods may be further combined to determine the area where the seal is located, so that the image of the area may be intercepted and used as the first seal image.
[0051] The downsampling processing module 22 may be configured to perform a first amount of downsampling processing on the target image using a first seal processing model to obtain a first processed image.
[0052] The downsampling processing module 22 can use the first seal processing model to perform multiple downsampling processes on the target image acquired by the acquisition module 21. For example, in the embodiment of the application, the first seal processing model can be a Unet model. And before each downsampling process, the downsampled image can be processed using a variable convolution algorithm to obtain the probability that each pixel in the image belongs to a text feature, and the first weight value of each pixel is determined based on the difference between the probability of each pixel and a preset threshold. For example, in the embodiment of the present application, the characteristic value of each pixel can be calculated for the target image using a variable convolution, and the probability that each pixel within a predetermined range is a text feature is determined based on the characteristic value. Then the probability of each pixel calculated in this way can be compared with a preset threshold. If the probability of a certain pixel is greater than the preset threshold, the pixel may be a text feature, and if the difference between the probability and the preset threshold is larger, that is, larger than the preset threshold, the probability that the pixel is a text feature is also greater. On the contrary, if the probability of a pixel in a certain area is less than the preset threshold, the probability that the pixel is a text feature is smaller, that is, it may be noise, and if the difference between the probability and the preset threshold is larger, that is, smaller than the preset threshold, the probability that the pixel is noise is also greater. Therefore, the downsampling processing module 22 can further determine the weight value of each pixel based on the difference between the probability value and the preset threshold, that is, for pixels with a greater probability of belonging to text features, it can be determined to have a larger weight value, and for pixels with a greater probability of being noise, it can be determined to have a smaller weight value. In addition, a convolution calculation can be performed before each downsampling process to determine the weight value of each pixel in the current image.
[0053] The up-sampling processing module 23 may be configured to perform a first amount of up-sampling processing on the first processed image using the first seal processing model to obtain a second processed image.
[0054] The up-sampling processing module 23 may further use the first seal processing model to perform multiple up-sampling processes on the first processed image obtained after the down-sampling processing module 22 performs multiple down-sampling processes using the first seal processing model. In the embodiment of the present application, the number of up-sampling processes may be the same as the number of down-sampling processes, so that each up-sampling process may correspond to one down-sampling process, and therefore in each up-sampling process, the pixels to be retained may be determined based on the first weight value of the down-sampled image corresponding to the image of the up-sampling process. In the upsampling process, interpolation processing can be performed based on the first weight values of the pixels in the corresponding downsampled image based on each pixel of the upsampled image to obtain a processed image with more pixels. Therefore, by performing multiple upsampling processes, the compressed image after the same number of downsampling processes can be restored to a second processed image with the same size or resolution as the target image. Since the first weight value of the corresponding downsampled image is used in the interpolation process during the upsampling process to determine the pixels to be retained in the second processed image, pixels with a higher probability, that is, pixels closer to text features, can be retained in the final restored upsampled image, so that noise can be removed and text can be retained in the final second processed image.
[0055] In addition, in the embodiment of the present application, after the second processed image is obtained, the noise probability of each pixel in the image belonging to the noise feature can be calculated for the second processed image, and then it can be determined whether the noise probability of each pixel is greater than the first noise threshold. When the number of pixels whose noise probability is greater than the preset noise threshold exceeds the predetermined number threshold, it can mean that the noise processing effect of the second processed image does not meet the preset standard, and therefore the downsampling processing of the downsampling processing module 22 and the upsampling processing of the upsampling processing module 23 can be repeated for the second processed image until the number of pixels whose noise probability is greater than the preset noise threshold is less than the number threshold.
[0056] In addition, in the embodiment of the present application, the text features can also be extracted based on the first seal image extracted or determined in the target image acquired by the acquisition module 21. For example, various text feature extraction algorithms or text feature extraction models can be used to detect and extract text features from the first seal image. While extracting the text features, the position information corresponding to the text features, such as relative position information, can also be determined based on the image information of the target image, such as pixel coordinate information. In the embodiment of the present application, the position information of the text feature can be the relative position of the center point or edge of the text feature relative to the edge of the seal image, or when the specification of the target image is determined, such as when the target image is determined to be A4 paper size, the position information of the text feature can also be the pixel coordinate information of the feature in the A4 paper area. Therefore, in the embodiment of the present application, each text feature extracted from the seal image and the corresponding position information can also be associated with each other as the first feature information. Then the first seal processing model can be modified based on the extracted first feature information. For example, in an embodiment of the present application, the attention module used in the variable convolution processing can be modified based on the various text features contained in the first feature information, so that the parameters in the attention module can reflect these text features, that is, the second seal processing module obtained after the modification can include parameters generated according to the various text features in the first feature information and with reference to the corresponding position information.
[0057] For example, in an embodiment of the present application, the similarity between the position information of each text feature in the first seal image and the position information of the preset seal text feature can be calculated based on the various text features contained in the first feature information and the corresponding position information. When the similarity of the calculated position information is greater than the preset position threshold, the similarity between the text feature corresponding to the position information in the first seal image and the preset seal text feature at the corresponding position is further calculated to determine the text feature whose similarity is greater than the preset image threshold as the text feature information of the first seal image. Then, the attention module in the first seal processing model can be updated based on the determined text feature information, for example, the parameters in the attention module are generated according to the text feature information, thereby generating the second seal processing model.
[0058] In addition, in the embodiment of the present application, the noise threshold can be updated each time after the second processed image is obtained, so that the same preset standard is not always used when performing noise detection after each round of multiple upsampling processes, but the noise threshold used at the time can be updated each time according to the processing results of the previous round, so that the speed of iterative convergence can be accelerated, and it can also be ensured that the noise threshold used each time can more accurately reflect the characteristic distribution characteristics of the seal image processed at the time. For example, after the noise feature information of the seal image generated last time is calculated, the preset text feature information corresponding to the first noise threshold is first obtained, and the similarity between the first feature information and each feature contained in the preset text feature information is calculated, and then the second noise threshold is calculated based on the similarity and the first noise threshold, and the second noise threshold is used as the first noise threshold used to determine whether the noise value of the seal image meets the requirements at the time.
[0059] In addition, in the embodiment of the present application, the first processing model can be trained in advance. For example, a first group of seal images can be obtained first. Such seal images can be seal images that have been manually screened in advance, or can also be seal images that have been noise-processed and obtained through the Internet. For example, each seal image in the first group of seal images can contain its own seal image and does not contain noise features. In the embodiment of the present application, the seal image obtained in this way can also contain noise features with characteristic values lower than a predetermined standard, that is, it can be a seal image containing a small amount of noise features. Then, a preset noise generation algorithm can be used to generate noise to be superimposed based on the text features of the seal image, and a noise image can be generated based on the generated noise to be superimposed. Then, the noise image is superimposed with the corresponding seal image to generate a noisy seal image. Thus, a seal image in which the noise features are known can be obtained. Therefore, the noisy seal image and the corresponding seal image can be used as training data to train the preset seal processing model to obtain the first seal processing model.
[0060] In addition, when the seal processing model is trained, the noise type information can be further added to the training data obtained in the above manner. For example, the similarity of the standard noise feature corresponding to the preset noise type can be calculated based on the noise feature of the noise to be superimposed, and the noise type of the noise to be superimposed can be determined based on the similarity. Therefore, the seal processing model can be optimized for different types of noise, so that the trained seal processing model can identify noise more accurately.
[0061] According to the seal image processing device of the embodiment of the present application, a target image is obtained; the target image is subjected to a first number of downsampling processes using a first seal processing model to obtain a first processed image, wherein before each downsampling process, the downsampled image is first processed using a variable convolution algorithm to obtain the probability that each pixel in the image belongs to a text feature, and the first weight value of each pixel is determined based on the difference between the probability of each pixel and a preset threshold; the first processed image is subjected to the first number of upsampling processes using the first seal processing model to obtain a second processed image, wherein in each upsampling process, the pixels to be retained are determined based on the first weight value of the downsampled image corresponding to the image subjected to the upsampling process. Therefore, using the seal image processing device according to the embodiment of the present application, a variable convolution process can be performed first when the target image is subjected to downsampling process, in which the weight value of the pixel with the text feature can be enhanced in each downsampling process by making the pixel with a larger probability of belonging to the text feature have a larger weight, and the pixels to be retained are determined based on the weight value obtained in the corresponding downsampling process in the upsampling process, so that more pixels with text features can be retained in the processed image, thereby improving the effect of noise removal.
[0062] Embodiment 3
[0063] The internal functions and structure of the seal image processing device are described above. The device can be implemented as an electronic device. Figure 3 This is a schematic diagram of the structure of an electronic device embodiment provided by this application. Figure 3 As shown, the electronic device includes a memory 31 and a processor 32 .
[0064] The memory 31 is used to store programs. In addition to the above programs, the memory 31 can also be configured to store various other data to support operations on the electronic device. Examples of such data include instructions for any application or method operating on the electronic device, contact data, phone book data, messages, pictures, videos, etc.
[0065] The memory 31 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0066] The processor 32 is not limited to a central processing unit (CPU), but may also be a processing chip such as a graphics processing unit (GPU), a field programmable gate array (FPGA), an embedded neural network processor (NPU) or an artificial intelligence (AI) chip. The processor 32 is coupled to the memory 31 to execute a program stored in the memory 31. When the program is executed, the seal image processing method of the first embodiment is executed.
[0067] Further, if Figure 3 As shown, the electronic device may also include: a communication component 33, a power component 34, an audio component 35, a display 36 and other components. Figure 3 Only some components are shown schematically, which does not mean that the electronic device only includes Figure 3 Components shown.
[0068] The communication component 33 is configured to facilitate wired or wireless communication between the electronic device and other devices. The electronic device can access a wireless network based on a communication standard, such as WiFi, 3G, 4G or 5G, or a combination thereof. In an exemplary embodiment, the communication component 33 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 33 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0069] The power supply component 34 provides power to various components of the electronic device. The power supply component 34 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device.
[0070] The audio component 35 is configured to output and / or input audio signals. For example, the audio component 35 includes a microphone (MIC), and when the electronic device is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 31 or sent via the communication component 33. In some embodiments, the audio component 35 also includes a speaker for outputting audio signals.
[0071] The display 36 includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may detect not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation.
[0072] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0073] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A seal image processing method, characterized in that: include: Get the target image; Performing a first number of downsampling processes on the target image using a first seal processing model to obtain a first processed image, wherein before each downsampling process, the downsampled image is first processed using a variable convolution algorithm to obtain a probability that each pixel in the image belongs to a text feature, and determining a first weight value of each pixel based on a difference between the probability of each pixel and a preset threshold; The first processed image is subjected to the first amount of upsampling processing using the first seal processing model to obtain a second processed image, wherein in each upsampling processing, pixels to be retained are determined based on a first weight value of a downsampled image corresponding to the image subjected to the upsampling processing.
2. The seal image processing method according to claim 1, characterized in that: The seal processing model is a Unet network model.
3. The seal image processing method according to claim 2, characterized in that: The method further comprises: For the second processed image, calculating the noise probability that each pixel in the image belongs to a noise feature; Determine whether the noise probability of each pixel is greater than a first noise threshold, and when the number of pixels whose probability is greater than a preset noise threshold exceeds a predetermined number threshold, repeat the downsampling process and the upsampling process for the second processed image.
4. The seal image processing method according to claim 1, characterized in that: The method further comprises: Obtaining a first seal image contained in a target image; extracting first feature information from the first seal image; The first seal processing model is modified based on the first characteristic information to obtain a second seal processing model including a first update parameter generated according to the first various information, and The performing a first amount of downsampling processing on the target image using a first seal processing model to obtain a first processed image comprises: Performing a first amount of downsampling processing on the target image using the second seal processing model to obtain a first processed image, The performing the first amount of upsampling processing on the first processed image using the first seal processing model comprises: The first amount of upsampling processing is performed on the first processed image using the second seal processing model.
5. The seal image processing method according to claim 4, characterized in that: The modifying the first seal processing model based on the first characteristic information to obtain a second seal processing model including a first update parameter generated according to the first characteristic information comprises: Based on each text feature and the corresponding position information included in the first feature information, the similarity between the position information of each text feature in the first seal image and the position information of the preset seal text feature is calculated, and when the similarity of the position information is greater than a preset position threshold, the similarity between the text feature corresponding to the position information in the first seal image and the preset seal text feature at the corresponding position is calculated, so as to determine the text feature whose similarity of the text feature is greater than the preset image threshold as the text feature information of the first seal image; Based on the determined text feature information, an attention module in the first seal processing model is updated to generate the second seal processing model, wherein, in the second seal processing model, the weight of the determined text feature information is less than the weight of other text features.
6. The seal image processing method according to claim 3, characterized in that: Before determining whether the noise probability of each pixel is greater than a first noise threshold, the method further includes: Acquire preset noise characteristic information corresponding to the first noise threshold; Calculating the similarity between the feature information of each pixel and each feature included in the preset noise feature information; Calculating a second noise threshold based on the similarity and the first noise threshold; The second noise threshold is used as the first noise threshold.
7. The seal image processing method according to claim 1, characterized in that: The first seal processing model is obtained by training as follows: Acquire a first group of seal images, wherein each seal image in the first group of seal images includes a respective seal image and does not include a noise feature; Using a preset noise generation algorithm to generate noise to be superimposed based on the text features of the seal image; generating a noise image based on the noise to be superimposed; Superimposing the noise image with the corresponding seal image to generate a seal image with noise; The noisy seal image and the corresponding seal image are used as training data to train a preset seal processing model to obtain a first seal processing model.
8. The seal image processing method according to claim 7, characterized in that: Before generating a noise image based on the noise to be superimposed, the method further includes: Calculating the similarity between the noise feature of the noise to be superimposed and the standard noise feature corresponding to the preset noise type; determining the noise type of the noise to be superimposed based on the similarity, and The step of using the noisy seal image and the corresponding seal image as training data to train a preset seal processing model to obtain a first seal processing model includes: The noisy seal image, the corresponding seal image and the determined noise type are used as training data to train a preset seal processing model to obtain a first seal processing model.
9. A seal image processing device, characterized in that: include: An acquisition module, used for acquiring a target image; A downsampling processing module, used for performing a first number of downsampling processes on the target image using a first seal processing model to obtain a first processed image, wherein before each downsampling process, the downsampled image is first processed using a variable convolution algorithm to obtain a probability that each pixel in the image belongs to a text feature, and a first weight value of each pixel is determined based on a difference between the probability of each pixel and a preset threshold; An upsampling processing module is used to perform the first amount of upsampling processing on the first processed image using the first seal processing model to obtain a second processed image, wherein in each upsampling processing, the pixels that need to be retained are determined based on the first weight value of the downsampled image corresponding to the image of the upsampling processing.
10. An electronic device, characterized in that: include: Memory, used to store programs; A processor is used to run the program stored in the memory to execute the seal image processing method according to any one of claims 1 to 8.