A seal image denoising method and system based on content extraction

Through the seal image noise reduction method under content extraction, image segmentation and feature extraction are used to generate reverse images. Combined with multiple noise reduction and image repair algorithms, the problem of loss of text covered by the seal is solved and the accuracy and completeness of text extraction are improved. sex.

CN118552961BActive Publication Date: 2024-10-01贵州中汇科技发展有限公司 +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411026170.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2024-10-01
Estimated Expiration
2044-07-30

AI Technical Summary

Technical Problem

When the existing technology removes the seal area in legal documents, it is easy to cause the text content to be lost and affect the recognition effect.

Method used

The seal image denoising method under content extraction is used to restore the text content covered by the seal through image segmentation, feature extraction, reverse image generation, multiple noise reduction and image repair algorithms.

Benefits of technology

Effectively offset seal interference, restore text content to the greatest extent, improve the accuracy of optical character recognition, and ensure the integrity and accuracy of text extraction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118552961B_ABST
    Figure CN118552961B_ABST
Patent Text Reader

Abstract

The present invention discloses a seal image denoising method and system under content extraction. The method comprises: obtaining a legal document image to be processed; using an image segmentation algorithm to detect the seal area of ​​the legal document image; extracting the features of the seal area; generating a reverse image according to the features of the seal area, the reverse image being an image fused from a reverse color image, a reverse texture image and a reverse shape image; superimposing the reverse image on the seal area of ​​the legal document image to offset the interference of the seal, and obtaining a first denoised image; using an image erasing algorithm to erase the residual seal noise in the first denoised image, and obtaining a second denoised image; applying an image restoration algorithm to restore the text covered by the seal in the second denoised image; after successful restoration, using optical character recognition (OCR) technology to extract the text content under the seal. The present invention can effectively remove the interference of the seal on the legal document image and improve the recognition rate of the text content.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, and in particular to a seal image denoising method and system under content extraction. Background Art

[0002] When using a large language model to identify and analyze the content of legal document images, the seal area in the legal document will interfere with the extraction of text content. Most existing seal removal methods directly remove the seal area as noise. When the seal covers a lot of text, part of the text content will be lost, affecting the recognition effect. Summary of the invention

[0003] In view of this, the present invention provides a seal image denoising method and system under content extraction, which solves the problem of seal covering leading to loss of text content in the prior art.

[0004] The embodiment of the present application provides a seal image denoising method under content extraction, comprising:

[0005] Obtain images of legal documents to be processed;

[0006] Detecting the seal area of ​​the legal document image using an image segmentation algorithm;

[0007] Extracting features of the seal area;

[0008] Generate a reverse image according to the characteristics of the seal area, wherein the reverse image is a fusion image of the reverse color image, the reverse texture image and the reverse shape image;

[0009] superimposing the reverse image onto the seal area of ​​the legal document image to offset the interference of the seal, thereby obtaining a first noise reduction image;

[0010] Using an image erasing algorithm to erase the seal residual noise in the first denoised image to obtain a second denoised image;

[0011] Applying an image restoration algorithm to restore the text covered by the seal in the second denoised image;

[0012] After successful recovery, optical character recognition (OCR) technology is used to extract the text content under the seal.

[0013] Optionally, using an image segmentation algorithm to detect the seal area of ​​the legal document image includes:

[0014] Preprocessing the legal document image;

[0015] Using Otsu threshold method to determine the best segmentation threshold so as to separate the stamp area from the background;

[0016] Using morphological opening operation to remove some noise points in the stamp area;

[0017] Filling some holes in the stamp area using a morphological closing operation;

[0018] The seal area is extracted using a connected component labeling algorithm.

[0019] Optionally, extracting features of the seal area includes:

[0020] Calculating a color histogram of the seal area to obtain color distribution information, and normalizing the color distribution information to obtain a standardized color feature vector;

[0021] Using local binary pattern LBP to describe the texture information of the seal, calculating the LBP histogram, obtaining the texture feature distribution, normalizing the texture features, and obtaining a standardized texture feature vector;

[0022] The shape information of the seal area is extracted using Hu moment, and the shape feature vector is obtained by calculating Hu moment and then logarithmic transformation is performed.

[0023] Optionally, a reverse image is generated according to the features of the seal area, wherein the reverse image is a fusion image of a reverse color image, a reverse texture image and a reverse shape image, and includes:

[0024] Performing color inversion processing on the color feature vector, applying the inverted color feature to the stamp area, and generating a reverse color image;

[0025] Generating a texture feature opposite to the texture feature vector, applying the reverse texture feature to the stamp area, and generating a reverse texture image;

[0026] generating a shape opposite to the shape feature vector, applying the reverse shape to the stamp area, and generating a reverse shape image;

[0027] The reverse color image, the reverse texture image and the reverse shape image are fused to generate the final reverse image.

[0028] Optionally, using an image erasing algorithm to erase the seal residual noise in the first denoised image to obtain a second denoised image includes:

[0029] Performing local image enhancement on the first denoised image to highlight the text portion covered by the seal;

[0030] The residual noise of the seal in the first denoised image is further erased using a median filter or a convolution operation.

[0031] Optionally, using a median filter to further erase the residual noise of the seal in the first denoised image comprises:

[0032] Performing grayscale processing on the image subjected to the first noise reduction;

[0033] Set the filter window size;

[0034] Processing each pixel in the first denoised image using a median filter with the set filter window size;

[0035] Calculate the median of all pixel values ​​within the filter window and replace the central pixel value with the median;

[0036] The filtered image is edge-preserved or sharpened to enhance image details.

[0037] Optionally, applying an image restoration algorithm to restore the text covered by the seal in the second denoised image includes:

[0038] Build a convolutional neural network CNN model;

[0039] Acquire a training data set, and use the training data set to perform model training on the second denoised image;

[0040] The trained CNN model is used to restore the text covered by the seal in the second denoised image.

[0041] Optionally, applying an image restoration algorithm to restore the text covered by the seal in the second denoised image includes:

[0042] Performing grayscale processing on the image subjected to the second noise reduction;

[0043] Based on the principle of object self-similarity, a recursive hierarchical model is constructed;

[0044] Analyzing the similarity between the stamp-covered area and the surrounding text area in the second denoised image by using the recursive hierarchical model;

[0045] Select the convolutional neural network (CNN) architecture U-Net suitable for self-similarity modeling;

[0046] The U-Net architecture is used to perform recursive hierarchical processing to extract and fuse the global and local features of the image, thereby repairing the text covered by the seal.

[0047] Optionally, the U-Net architecture is used to perform recursive hierarchical processing to extract and fuse the global and local features of the second denoised image to achieve restoration of the text covered by the seal, including:

[0048] Use the U-Net encoder to perform multi-level downsampling on the input document image with seal;

[0049] Extracting global features of the second denoised image through continuous convolution and pooling operations;

[0050] Apply sliding window technology on each layer of feature map to extract the features of local image blocks;

[0051] Using skip connections to pass the features extracted from the encoder to the corresponding decoder layer;

[0052] During decoding, the image is upsampled layer by layer, and the features of the encoder are fused with the features of the decoder;

[0053] In the last layer of the decoder, a convolutional layer is used to restore the fused feature map to an image of the same size as the input image;

[0054] Generate a repaired image and restore the text covered by the stamp.

[0055] The embodiment of the present application also provides a seal image denoising system under content extraction, comprising:

[0056] An acquisition module, used for acquiring the legal document image to be processed;

[0057] A detection module, used for detecting the seal area of ​​the legal document image using an image segmentation algorithm;

[0058] An extraction module, used for extracting features of the seal area;

[0059] A generating module, used for generating a reverse image according to the characteristics of the seal area, wherein the reverse image is a fusion image of a reverse color image, a reverse texture image and a reverse shape image;

[0060] A superposition module, used for superimposing the reverse image onto the seal area of ​​the legal document image to offset the interference of the seal and obtain a first noise reduction image;

[0061] An erasing module, used for erasing the residual seal noise in the first denoised image by using an image erasing algorithm to obtain a second denoised image;

[0062] A restoration module, used for restoring the text covered by the seal in the second denoised image by applying an image restoration algorithm;

[0063] The recognition module is used to extract the text content under the seal using optical character recognition (OCR) technology after successful recovery.

[0064] The present application also provides a computer device, the computer device comprising:

[0065] at least one processor; and,

[0066] a memory communicatively connected to the at least one processor; wherein,

[0067] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the seal image denoising method under the above-mentioned content extraction.

[0068] An embodiment of the present application also provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute the seal image denoising method under the above-mentioned content extraction.

[0069] An embodiment of the present application also provides a computer program product, including computer instructions, characterized in that when the computer instructions are executed by a processor, the steps of the seal image denoising method under the above-mentioned content extraction are implemented.

[0070] The present application provides a seal image denoising method and system under content extraction. By generating a reverse image of the seal area and superimposing it on the original image, the interference of the seal on the legal document image can be effectively offset; in addition, multiple denoising and image restoration algorithms are used to restore the text content covered by the seal to the greatest extent, thereby improving the accuracy of OCR recognition; finally, the method has good robustness, can adapt to seals of different types and colors, and has wide practicality. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] In order to more clearly illustrate the disclosed embodiments in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.

[0072] Figure 1 A flow chart of a seal image denoising method under content extraction provided in an embodiment of the present application;

[0073] Figure 2 is a detailed flow chart of S3 in one embodiment;

[0074] Figure 3 is a detailed flow chart of S4 in one embodiment;

[0075] Figure 4 A schematic diagram of the architecture of a seal image denoising system under content extraction provided by an embodiment;

[0076] Figure 5 A schematic diagram of the architecture of a computer device provided by an embodiment. DETAILED DESCRIPTION

[0077] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.

[0078] It should be clear that the following embodiments of the present disclosure are described by specific specific examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. The present disclosure can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that the following embodiments and features in the embodiments can be combined with each other in the absence of conflict. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.

[0079] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.

[0080] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present disclosure. The drawings only show components related to the present disclosure rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0081] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects described may be practiced without these specific details.

[0082] This application embodiment is mainly used in scenarios where content recognition and analysis of legal document images are performed. Legal documents usually contain a large amount of text information and seals, and the seal area often covers part of the text, causing interference with text content extraction. This solution aims to remove the influence of seals on text recognition and improve the accuracy of text extraction.

[0083] In addition to legal documents, this scheme can also be applied to other scenarios with seals and text extraction, such as contract documents, official documents, etc. At the same time, the idea of ​​reverse image superposition and recursive layering based on object self-similarity can also be extended to general image watermark removal, image restoration and other tasks.

[0084] This solution solves the problem of seal interference in text recognition and extraction in legal document images. Through reverse image denoising, multiple erasure residues and CNN restoration, it can remove seal noise to the greatest extent while restoring the text covered by the seal, ensuring the integrity and accuracy of text extraction, providing high-quality image input for subsequent legal document content recognition and analysis, and has practical value. At the same time, the reverse image idea and recursive layering method proposed in this solution provide new ideas for seal removal and image restoration technology.

[0085] The following are explanations of technical terms appearing in the embodiments of this application:

[0086] Reverse image: Generate an image opposite to the characteristics of the seal area (such as color, texture, shape) to offset the interference of the seal on the text.

[0087] Object self-similarity: Objects in an image have similar structures and features at different scales. Using this feature, text restoration can be performed by analyzing the similarity between the stamp-covered area and the surrounding text area.

[0088] Recursive hierarchical model: A method to model image structure through recursive decomposition and hierarchical processing based on object self-similarity.

[0089] Otsu threshold method: an adaptive image binarization algorithm that finds the optimal threshold by maximizing the inter-class variance and divides the image into foreground and background. It is often used for the segmentation and extraction of seal areas.

[0090] Morphological processing: An image processing method based on morphological operations (such as erosion, dilation, opening and closing operations, etc.), which can be used to remove image noise, fill holes, extract contours, etc.

[0091] LBP (Local Binary Pattern): An algorithm used for texture feature extraction. It generates binary codes by comparing the size relationship between pixels and their neighboring pixels, and counts their histograms as texture features.

[0092] Hu moment: A moment invariant that describes the geometric features of an image, which remains invariant to translation, rotation, and scaling of the image. Seven Hu moments are commonly used as shape features.

[0093] Convolutional Neural Network (CNN): A deep learning model widely used in image recognition and processing. It can automatically learn the hierarchical feature representation of images through feature extraction by convolutional layers, dimensionality reduction by pooling layers, and classification by fully connected layers.

[0094] U-Net: A CNN model used for image segmentation and image restoration. It consists of an encoder and a decoder. The encoder's feature map is passed to the decoder through a jump connection, realizing the fusion of global and local features. It is often used in medical image segmentation and image restoration tasks.

[0095] Embodiment 1

[0096] like Figure 1 As shown, the embodiment of the present application provides a method for reducing the noise of a seal image under content extraction, comprising:

[0097] S1: Obtain the legal document image to be processed;

[0098] S2: using an image segmentation algorithm to detect the seal area of ​​the legal document image;

[0099] Use an image segmentation algorithm (such as Otsu thresholding method) to detect the stamp area in the image, including steps 2.1-2.5:

[0100] S2.1: Preprocessing the legal document image;

[0101] Specifically, S2.1 includes:

[0102] (1) Convert the original color legal document image to a grayscale image. The conversion formula is: Gray = R0.299 + G0.587 + B*0.114, where R, G, and B are the red, green, and blue components of the pixel, respectively.

[0103] (2) Use Gaussian filtering to smooth and denoise the grayscale image. Gaussian filtering is a linear smoothing filter that uses a convolution kernel that follows a Gaussian distribution to perform a convolution operation on the image. Gaussian filtering can remove high-frequency noise in the image and make the image smoother. The standard deviation parameter of the Gaussian filter can control the degree of smoothing and is usually between 1 and 3.

[0104] (3) Perform histogram equalization on the smoothed grayscale image to enhance the image contrast. Histogram equalization stretches the pixel intensity distribution range to make the image pixel intensity distribution more uniform, thereby enhancing the overall image contrast.

[0105] S2.2: using the Otsu threshold method to determine the optimal segmentation threshold so as to separate the seal area from the background;

[0106] In S2.2, this method can automatically determine the optimal threshold to separate the stamp area from the background.

[0107] Among them, the Otsu threshold method is an image segmentation method that determines the optimal segmentation threshold by maximizing the inter-class variance.

[0108] Specifically, in S2.2, by calculating the histogram and probability distribution of the image, by traversing all possible thresholds, calculating the inter-class variance, and selecting the threshold corresponding to the maximum inter-class variance as the optimal threshold.

[0109] Among them, the specific steps of Otsu threshold method are as follows:

[0110] (1) Calculate the grayscale histogram of the image, that is, the number of pixels corresponding to each grayscale level.

[0111] (2) Traverse all possible thresholds t (0~255) and divide the image into two parts: the foreground less than or equal to t (assumed to be the seal area) and the background greater than t.

[0112] (3) For each t, ​​calculate the number, mean and variance of foreground and background pixels.

[0113] (4) Calculate the inter-class variance, that is, the variance between the foreground and the background. The larger the inter-class variance, the better the separation of the foreground and the background.

[0114] (5) Find the threshold t corresponding to the maximum inter-class variance as the optimal segmentation threshold.

[0115] (6) Use the optimal threshold t to binarize the image. Pixels less than or equal to t are set to 0 (black), representing the stamp area; pixels greater than t are set to 255 (white), representing the background area.

[0116] Sample code such as:

[0117] ```Python

[0118] import cv2

[0119] import numpy as np

[0120] def otsu_thresholding(image):

[0121] Reading grayscale images

[0122] gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

[0123] Gaussian filter denoising

[0124] blurred = cv2.GaussianBlur(gray_image, (5, 5), 0)

[0125] Segmentation using Otsu thresholding

[0126] ret, thresholded = cv2.threshold(blurred, 0, 255, cv2.THRESH_BINARY +cv2.THRESH_OTSU)

[0127] return thresholded

[0128] ```

[0129] S2.3: using morphological opening operation to remove some noise points in the seal area;

[0130] The purpose of morphological operations is to post-process the segmentation results and remove noise and small areas.

[0131] Use morphological opening operations (erosion followed by dilation) to remove small noise points, including:

[0132] (1) Perform an erosion operation on the binary image. The erosion operation changes the white pixels in the image to black and can remove some small white noise. The commonly used structural elements are 3x3 rectangles or diamonds.

[0133] (2) Perform a dilation operation on the eroded image. The dilation operation changes the black pixels in the image to white, which can restore the eroded stamp area. The same structural element is used as in the erosion operation.

[0134] (3) The effect of the opening operation is that the stamp area remains basically unchanged, and some small white noise points are removed.

[0135] S2.4: Filling some holes in the stamp area using morphological closing operation;

[0136] Use morphological closing operation (dilation followed by erosion) to fill small holes in the stamp area.

[0137] The steps of morphological closing operation are as follows:

[0138] (1) Perform dilation on the binary image after the opening operation. Dilation can fill some black holes in the stamp area.

[0139] (2) Performing an erosion operation on the expanded image. The edge of the stamp area that has been over-expanded can be restored by performing an erosion operation on the expanded image.

[0140] (3) The effect of the closing operation is that the integrity of the seal area is improved and some small holes inside are filled.

[0141] Sample code such as:

[0142] ```Python

[0143] def morphological_operations(thresholded_image):

[0144] Defining structural elements

[0145] kernel = np.ones((3, 3), np.uint8)

[0146] Open Operation

[0147] opened = cv2.morphologyEx(thresholded_image, cv2.MORPH_OPEN, kernel, iterations=2)

[0148] Closing operation

[0149] closed = cv2.morphologyEx(opened, cv2.MORPH_CLOSE, kernel, iterations=2)

[0150] return closed

[0151] ```

[0152] S2.5: Extract the seal area using a connected component labeling algorithm.

[0153] The steps of the Connected Component Labeling algorithm are as follows:

[0154] (1) Scan each pixel of the binary image and, for each white pixel (pixel value 255), determine whether its adjacent pixels above and to the left are also white pixels.

[0155] (2) If there is no white pixel above or to the left, mark the current white pixel as a new connected component and assign a new label value.

[0156] (3) If there is a white pixel above or to the left, update the label value of the current point to the same label value.

[0157] (4) If the label values ​​of the white pixels above and to the left are different, merge the two connected components and update them to the same label value.

[0158] (5) After scanning all pixels, the image is marked as multiple connected components, each of which has a unique label value.

[0159] (6) Analyze the geometric features of each connected component, such as size, aspect ratio, and circularity, filter out components that obviously deviate from the seal features, and retain the components that are most likely to be the seal area.

[0160] The sample code for extracting the stamp area using the connected component labeling algorithm is as follows:

[0161] ```Python

[0162] def extract_stamp_region(processed_image):

[0163] Connected component labeling

[0164] num_labels, labels, stats, centroids = cv2.connectedComponentsWithStats(processed_image, connectivity=8)

[0165] Extract stamp area

[0166] stamp_regions = []

[0167] for i in range(1, num_labels):

[0168] x, y, w, h, area = stats[i]

[0169] if area>500: filter out small areas

[0170] stamp_regions.append((x, y, w, h))

[0171] return stamp_regions

[0172] ```

[0173] For example, there is currently an image of a legal document containing a red seal. The following is the complete seal area detection process:

[0174] ```Python

[0175] import cv2

[0176] import numpy as np

[0177] import matplotlib.pyplot as plt

[0178] Reading input image

[0179] image = cv2.imread('law_document_with_stamp.jpg')

[0180] Image preprocessing

[0181] gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

[0182] blurred = cv2.GaussianBlur(gray_image, (5, 5), 0)

[0183] Otsu Threshold Method

[0184] ret, thresholded = cv2.threshold(blurred, 0, 255, cv2.THRESH_BINARY +cv2.THRESH_OTSU)

[0185] Morphological operations

[0186] kernel = np.ones((3, 3), np.uint8)

[0187] opened = cv2.morphologyEx(thresholded, cv2.MORPH_OPEN, kernel, iterations=2)

[0188] closed = cv2.morphologyEx(opened, cv2.MORPH_CLOSE, kernel, iterations=2)

[0189] Seal area extraction

[0190] num_labels, labels, stats, centroids = cv2.connectedComponentsWithStats(closed, connectivity=8)

[0191] stamp_regions = [(x, y, w, h) for x, y, w, h, area in stats[1:] ifarea>500]

[0192] Display results

[0193] for (x, y, w, h) in stamp_regions:

[0194] cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)

[0195] plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))

[0196] plt.show()

[0197] ```

[0198] Through the above steps, the seal area in the image can be effectively detected, providing a basis for subsequent reverse noise cancellation and noise erasure.

[0199] In another embodiment, seal area recognition may be performed by other means, for example, using local geometry-aware neural surface representation for seal area detection.

[0200] Local geometry-aware neural surface representation is a neural network-based technology that represents and processes image surface information by perceiving local geometric features. It is widely used in computer vision and image processing. The local geometry-aware neural surface representation technology is applied to improve the accuracy and robustness of seal area detection.

[0201] Considering the following difficulties of image segmentation algorithm:

[0202] Problem 1: Existing image segmentation algorithms (such as the Otsu threshold method) have low detection accuracy when dealing with complex backgrounds or blurred seal edges.

[0203] Problem 2: Traditional detection methods are easily affected by noise and lighting changes, resulting in false detections and missed detections.

[0204] Then, by using local geometry perception neural surface representation technology, the above problems can be solved by learning the local geometric features of the image, greatly enhancing the detection effect of the seal area. The specific implementation steps are as follows:

[0205] Step 2.1.1: Image preprocessing

[0206] Prepare image data and enhance features of the stamp area.

[0207] Convert the input document image to grayscale.

[0208] Use Gaussian filtering to remove noise and improve image quality.

[0209] Step 2.1.2: Local geometric feature extraction

[0210] Extract local geometric features of the image to enhance the saliency of the stamp area. Specifically: Build a local geometry-aware neural network (e.g., a geometry feature extraction module based on a convolutional neural network). Use a neural network to extract local geometric features of the image, including edge, texture, shape, and other information.

[0211] Specifically include:

[0212] Step 2.1.2.1: Constructing a geometric feature extraction network

[0213] Design and build a convolutional neural network (CNN) suitable for geometric feature extraction. Specifically, you can choose an appropriate CNN architecture (such as ResNet, VGG, etc.) for feature extraction. Define the input and output form of the network, with the input being the preprocessed image and the output being the local geometric feature map.

[0214] Step 2.1.2.2: Train the Neural Network

[0215] The neural network is trained with large-scale data to effectively extract geometric features. A large number of image datasets containing stamps and background areas are collected and annotated. The annotated dataset is used to train the geometric feature extraction network and optimize the loss function.

[0216] Step 2.1.2.3: Apply geometric feature extraction network

[0217] Use the trained neural network to extract the geometric features of the input image. Input the preprocessed image into the trained geometric feature extraction network to obtain the geometric feature map. Extract edge, texture and shape features through the convolution layer.

[0218] Take the ResNet architecture as an example:

[0219] 1. Constructing a geometric feature extraction network

[0220] The ResNet architecture is selected as the basis of the geometric feature extraction network. ResNet has a deeper network layer and is suitable for extracting complex features.

[0221] Define the input and output form of the network, the input is the preprocessed grayscale image, and the output is the geometric feature map.

[0222] 2. Training the Neural Network

[0223] Collect and annotate a dataset containing a large number of images with stamp and background regions.

[0224] Use labeled datasets for training and optimize loss functions such as cross entropy loss or mean squared error (MSE).

[0225] Use data enhancement techniques (such as rotation, scaling, flipping, etc.) to improve the generalization ability of the network.

[0226] 3. Applying geometric feature extraction network

[0227] The preprocessed grayscale image is input into the trained ResNet network to obtain the geometric feature map.

[0228] In feature maps, edge features appear as high-frequency variations, texture features appear as repetitive patterns, and shape features appear as geometric structures.

[0229] Let's take a specific example to illustrate:

[0230] 1. Constructing a geometric feature extraction network

[0231] ResNet-50 is selected as the basic architecture of the geometric feature extraction network. ResNet-50 has 50 convolutional layers and can extract complex geometric features.

[0232] The input is a 256x256 grayscale image and the output is a 64x64 geometric feature map.

[0233] 2. Training the Neural Network

[0234] Collect and annotate image datasets containing stamp and background areas.

[0235] Use the labeled dataset to train the ResNet-50 network and optimize the cross entropy loss.

[0236] Perform data augmentation, such as random rotation, scaling, and flipping, to improve the robustness of the network.

[0237] 3. Applying geometric feature extraction network

[0238] The grayscale and denoised document image is input into the trained ResNet-50 network.

[0239] Output 64x64 geometric feature map, including edge, texture and shape features.

[0240] In the feature map, the edge features of the seal will appear as significant high-frequency changes, and the texture features inside the seal will appear as regular repeating patterns.

[0241] Through the above steps, the local geometry-aware neural network can be used to effectively extract the geometric features of the image, enhance the saliency of the seal area, and provide reliable feature support for subsequent seal area detection.

[0242] Step 2.1.3: Geometric feature fusion

[0243] Integrate multi-level geometric features to improve the detection accuracy of the seal area.

[0244] The extracted geometric features are fused at multiple levels to construct a multi-scale feature map. The feature map is weighted using the attention mechanism to highlight the saliency of the stamp area.

[0245] Step 2.1.4: Stamp area detection

[0246] Based on the fused geometric feature map, the seal area is detected.

[0247] The fused feature map is classified using a convolutional neural network to identify the stamp area. The detection results are post-processed, including morphological operations to remove small noise areas.

[0248] The following is an example of the detailed stamp area detection process:

[0249] 1. Image Preprocessing

[0250] The input document image is grayed out to reduce the interference of color information.

[0251] Use Gaussian filtering to remove noise from images and enhance image quality.

[0252] 2. Local geometric feature extraction

[0253] Construct a local geometric feature extraction module based on convolutional neural network.

[0254] Use this module to process images and extract geometric features including edges, textures, and shapes.

[0255] 3. Geometric feature fusion

[0256] The extracted geometric features are fused at multiple levels to construct a multi-scale feature map.

[0257] The attention mechanism is used to weight the feature map to highlight the saliency of the stamp area.

[0258] The attention mechanism is applied on the feature map to highlight the stamp area and suppress background noise through weighted calculation.

[0259] 4. Seal area detection

[0260] A convolutional neural network is used to classify the fused feature map and identify the seal area.

[0261] Morphological operations, such as opening and closing operations, are performed on the detection results to remove small noise areas and retain the main seal area.

[0262] A convolutional neural network is used to perform binary classification on the feature map, dividing the image into seal area and non-seal area, and then morphological processing is performed to remove noise.

[0263] Through the above steps, the local geometry-aware neural surface representation technology can be used to effectively improve the accuracy and robustness of seal area detection and overcome the shortcomings of traditional methods.

[0264] S3: extracting features of the seal area;

[0265] Extract the features of the stamp area, including color, texture and other information, to prepare for the subsequent generation of the reverse image, such as Figure 2 As shown, including steps 3.1-3.3:

[0266] S3.1: Calculate the color histogram of the seal area to obtain color distribution information, normalize the color distribution information to obtain a standardized color feature vector;

[0267] S3.2: using the local binary pattern LBP to describe the texture information of the seal, calculating the LBP histogram, obtaining the texture feature distribution, normalizing the texture features, and obtaining a standardized texture feature vector;

[0268] S3.3: Use Hu moment to extract the shape information of the seal area, calculate Hu moment to obtain the shape feature vector, and perform logarithmic transformation.

[0269] Specifically,

[0270] S3.1: Calculate the color histogram of the stamp area, obtain the color distribution information, normalize the color distribution information, and obtain the standardized color feature vector. The specific steps are as follows: (1) Convert the extracted stamp area from the RGB color space to the HSV color space. The HSV space is more in line with the human eye's perception of color. H (Hue) represents the degree of color, S (Saturation) represents the saturation of color, and V (Value) represents the brightness of color. (2) Calculate the color histogram for the H and S channels of the HSV space respectively. The value range of the H channel is 0-360 degrees, which can be divided into n bins (such as n=18, one bin every 20 degrees). The value range of the S channel is 0-1, which can also be divided into m bins (such as m=5, one bin every 0.2). The change of the V channel has little effect on the color and can be ignored. (3) Concatenate the histograms of the H and S channels into an (n+m)-dimensional color feature vector. This feature vector represents the color distribution of the stamp area. (4) Perform L2 normalization on the color feature vector, that is, divide it by the L2 norm of the vector so that the L2 norm of the vector is 1. The normalized feature vector is more robust to changes in light intensity.

[0271] For example: Assume that the H channel is divided into 18 bins and the S channel is divided into 5 bins, then the color feature vector is a 23-dimensional vector. If the color feature vector is [0.1, 0.2, ..., 0.05, 0.01, 0.02, 0.03], it becomes [0.43, 0.86, ..., 0.22, 0.04, 0.09, 0.13] after normalization.

[0272] S3.2: Use the local binary pattern LBP to describe the texture information of the seal, calculate the LBP histogram, obtain the texture feature distribution, normalize the texture features, and obtain a standardized texture feature vector. The specific steps are as follows: (1) Convert the extracted seal area into a grayscale image. (2) For each pixel, take the 8 pixels in the 3x3 neighborhood around it and arrange them in a clockwise or counterclockwise direction to form an 8-bit binary sequence. The binarization method is that if the grayscale value of the neighborhood pixel is greater than the central pixel, the corresponding position is 1, otherwise it is 0. (3) Convert the 8-bit binary sequence into a decimal number as the LBP value of the pixel. The range of LBP value is 0-255. (4) Calculate the histogram of the LBP value of the entire seal area to obtain a 256-dimensional texture feature vector. This vector represents the texture distribution of the seal area. (5) Perform L1 normalization on the texture feature vector, that is, divide it by the L1 norm of the vector so that the L1 norm of the vector is 1. L1 normalization makes the vector more sparse and highlights significant texture features.

[0273] For example: suppose the grayscale values ​​of the 3x3 neighborhood around a pixel are [7, 15, 13; 11, 10, 14; 9, 12, 8], and the grayscale value of the center pixel is 10. Then the corresponding binary sequence is [0, 1, 1; 1, -, 1; 0,1, 0] (representing the center pixel), which is converted to decimal as 22+23+24+26+27=1+8+16+64+128=217. So the LBP value of the pixel is 217.

[0274] S3.3: Use Hu moments to extract the shape information of the seal area, calculate the Hu moments to obtain the shape feature vector, and perform logarithmic transformation. The specific steps are as follows: (1) Calculate the geometric moments m of the extracted binary seal area image pq , where p,q=0,1,2,3, represents the order of geometric moment. m pq The calculation formula is: pq =Sum(x p * y q * I(x,y)),

[0275] x, y are pixel coordinates, and I(x, y) is the pixel value (0 or 1). (2) According to the geometric moment m pq , calculate the central moments u pq , the calculation formula is: pq = Sum((xx mean ) p * (yy mean ) q * I(x,y)),

[0276] where x mean = m 10 / m 00 , y mean = m 01 / m 00 , represents the geometric center of the image. (3) According to the central moment upq, calculate the normalized central moments nu pq , the calculation formula is:nu pq = u pq / (m 00 r ),

[0277] where r = (p+q) / 2+1.

[0278] Normalization can make the moment invariant to scale changes. (4) According to the normalized central moment nupq, the seven Hu moments are calculated as the shape feature vector of the seal area. The specific calculation formula of the seven Hu moments is relatively complicated and will not be listed here. However, it can be directly calculated using toolkits such as OpenCV. (5) Due to the large difference in the numerical value of the Hu moment, the Hu moment feature vector is logarithmically transformed, that is, sign (hu i ) * log10(|hu i |), can make the eigenvector more balanced.

[0279] For example: Assume that the extracted seal area is a 100x100 binary image, and its geometric moment m is obtained by calculation. 00 =500, m 10 =30000, m 01 =35000, m 20 =2500000, m 11 =3000000, m 02 =3800000, m 30 =250000000, m 21 =320000000, m 12 =380000000, m 03 =510000000. Then calculate the central moment and normalized central moment, and finally get 7 Hu moments to form a 7-dimensional shape feature vector, and then perform logarithmic transformation to get the final shape feature.

[0280] For example, the seal area has been detected in step 2. The following is an example of the detailed feature extraction process:

[0281] 1: Color feature extraction

[0282] Crop the stamp area out of the image.

[0283] Calculate the color histogram of the stamp area and obtain the color distribution information of the three RGB channels.

[0284] The histogram is normalized to obtain a standardized color feature vector.

[0285] 2: Texture feature extraction

[0286] Crop the stamp area from the grayscale image.

[0287] The LBP algorithm is used to describe the texture information of the seal.

[0288] Calculate the LBP histogram and obtain the texture feature distribution.

[0289] The histogram is normalized to obtain a standardized texture feature vector.

[0290] 3: Shape feature extraction

[0291] Crop the stamp area from the grayscale image.

[0292] The shape information of the seal is extracted using Hu moments.

[0293] The shape feature vector is obtained by calculating the Hu moment and then logarithmically transformed.

[0294] Through the above steps, the color, texture and shape features of the seal can be effectively extracted, providing the necessary information for the subsequent reverse image generation and seal denoising. These features will be used to generate reverse images, offset the influence of the seal, and further improve the denoising effect.

[0295] S4: generating a reverse image according to the characteristics of the seal area, wherein the reverse image is a fusion image of the reverse color image, the reverse texture image and the reverse shape image;

[0296] like Figure 3 As shown, S4 includes S4.1-S4.4:

[0297] S4.1: performing color inversion processing on the color feature vector, applying the inverted color feature to the seal area, and generating a reverse color image;

[0298] S4.2: Generate a texture feature opposite to the texture feature vector, apply the reverse texture feature to the stamp area, and generate a reverse texture image;

[0299] S4.3: generating a shape opposite to the shape feature vector, applying the reverse shape to the stamp area, and generating a reverse shape image;

[0300] S4.4: Fusing the reverse color image, reverse texture image and reverse shape image to generate the final reverse image.

[0301] Exemplarily, S4.1-S4.4 will be explained with specific examples:

[0302] 1: Inverse color generation

[0303] According to the extracted color feature vector, color inversion is performed. For example, if the stamp color is red (RGB value is [255, 0, 0]), the inverted color is cyan (RGB value is [0, 255, 255]).

[0304] Applies the inverted color to the stamp area, producing a reverse color image.

[0305] 2: Inverse texture generation

[0306] Using the inverse texture feature, an image texture opposite to the stamp texture is generated. For example, if the stamp texture feature is a local binary pattern (LBP) histogram, the histogram can be inverted.

[0307] Applies the reverse texture to the stamp area, generating a reverse texture image.

[0308] 3: Reverse shape generation

[0309] The inverse shape feature is used to generate an image shape opposite to the stamp shape. For example, if the stamp shape feature is the Hu moment, the Hu moment can be logarithmically inverted.

[0310] Applies the inverse shape to the stamp area, generating an inverse shape image.

[0311] 4: Reverse image fusion

[0312] The inverse color image, the inverse texture image and the inverse shape image are fused. For example, a weighted average method can be used to perform weighted fusion of the three inverse images according to certain weights.

[0313] Adjust the fusion parameters to ensure that the reverse image can effectively offset the influence of the original stamp.

[0314] Through the above steps, a reverse image with the opposite color, texture and shape of the seal can be generated to offset the influence of the original seal, ultimately achieving a better seal noise reduction effect.

[0315] Specifically,

[0316] S4.1: Perform color inversion processing on the color feature vector, apply the inverted color feature to the stamp area, and generate a reverse color image. The specific steps are as follows:

[0317] (1) Perform inversion processing on the normalized color feature vector. Since the color feature vector is calculated on the H and S channels of the HSV space, the inversion processing also needs to be performed on these two channels.

[0318] (2) Invert the features of the H channel. The H channel represents the degree of color, and its value range is 0-360 degrees. The inversion formula is: H_inverse = (H + 180) % 360. This formula can rotate the H value of the original color by 180 degrees to obtain the H value of the reverse color.

[0319] (3) Invert the features of the S channel. The S channel represents the saturation of the color, and its value range is 0-1. The inversion formula is: inverse= 1 S. This formula can reverse the saturation S value of the original color to obtain the S value of the reversed color.

[0320] (4) Regenerate the image in HSV color space based on the inverted H and S features. The specific method is to find the corresponding H for each pixel in the stamp area according to its position information. inverse and S inverse The HSV color value of the pixel is reassigned based on the original V value.

[0321] (5) Convert the regenerated HSV image back to RGB color space to obtain an inverse color image.

[0322] For example: Assume that the original color of a pixel in the stamp area is HSV (60, 0.5, 0.8), where H=60 represents yellow-green, S=0.5 represents medium saturation, and V=0.8 represents high brightness. inverse = (60+180)%360 = 240, corresponding to blue-purple; S inverse = 1-0.5 = 0.5, and the saturation remains unchanged. Then the inverse color of the pixel is HSV (240, 0.5, 0.8), which is a bluish purple when converted to RGB space.

[0323] S4.2: Generate a texture feature opposite to the texture feature vector, apply the reverse texture feature to the stamp area, and generate a reverse texture image. The specific steps are as follows:

[0324] (1) Perform inversion processing on the normalized LBP texture feature vector. Since the LBP feature is a 256-dimensional histogram vector, the inversion process needs to be performed on each bin of the histogram.

[0325] (2) Reverse the value of each bin. The reversal formula is: inverse = 1 bin. This formula can reverse each bin value of the original texture feature to obtain the reverse texture feature.

[0326] (3) Regenerate the grayscale image based on the inverted LBP feature. The specific method is to find the corresponding LBP value for each pixel in the stamp area according to its position information, and then reassign the grayscale value of the pixel according to the bin_inverse corresponding to the LBP value in the inverse texture feature.

[0327] (4) The regenerated grayscale image is used as the inverse texture image.

[0328] For example: Assume that the original LBP value of a pixel in the stamp area is 200. When searching the LBP histogram, the value is located in the 200th bin, and its corresponding original bin value is 0.05. inverse = 1-0.05 =0.95. Then when regenerating the grayscale image, the grayscale value of the pixel should be 0.95*255=242.

[0329] S4.3: Generate a shape opposite to the shape feature vector, apply the reverse shape to the stamp area, and generate a reverse shape image. The specific steps are as follows:

[0330] (1) Invert the Hu rectangular feature vector after logarithmic transformation. Since the Hu moment is a 7-dimensional vector, the inversion process needs to be performed on each dimension.

[0331] (2) Reverse the value of each dimension. The reversal formula is: inverse = -hu. This formula can invert each dimension of the original shape feature to obtain the reverse shape feature.

[0332] (3) Regenerate the binary image based on the inverted Hu moment feature. The specific method is to use the geometric meaning of the Hu moment and find a binary image that is closest to the inverted shape feature through moment matching. This needs to be achieved through an optimization algorithm, such as using the gradient descent method to minimize the Euclidean distance between the original Hu moment and the target Hu moment (i.e., the inverted shape feature).

[0333] (4) The regenerated binary image is used as the inverse shape image.

[0334] The difficulty of this step is how to regenerate a shape image based on the inverse shape features. Since the Hu moment is an abstract representation of the image shape, it is impossible to directly reconstruct the image and needs to be approximated with the help of an optimization algorithm. The common practice is to first generate a random noise image and then use an optimization algorithm to gradually make its Hu moment features approach the inverse shape features of the target.

[0335] S4.4: Fuse the reverse color image, reverse texture image and reverse shape image to generate the final reverse image. The specific steps are as follows:

[0336] (1) The three inverse images are normalized to make their pixel value range consistent. The inverse color image and the inverse texture image can be directly converted to the range of [0,1], and the inverse shape image itself is a binary image.

[0337] (2) Perform weighted fusion on the three normalized inverse images. The fusion formula is: Inverse = w1*InverseColor + w2*InverseTexture + w3*InverseShape. Among them, w1, w2, and w3 are the weight coefficients of the three inverse images, which can be adjusted according to actual conditions. The weight coefficients satisfy w1+w2+w3=1.

[0338] (3) Binarization is performed on the fused reverse image. The binarization can be performed using a global threshold method, such as the Otsu algorithm, or an adaptive threshold method, such as an adaptive Gaussian threshold. The binarized image is convenient for subsequent stamp area extraction.

[0339] For example: Assume that the reverse color image, reverse texture image and reverse shape image are C, T and S respectively, and they are all normalized image matrices. Given the weight coefficients w1=0.4, w2=0.35, w3=0.25, the fused reverse image is:

[0340] Inverse = 0.4C + 0.35T + 0.25S

[0341] Then Inverse is binarized to obtain the final binary inverse image, in which the pixel value within the seal area is 1 and the pixel value outside the seal area is 0.

[0342] By generating reverse images from three angles, namely color, texture and shape, and then fusing them, a comprehensive reverse image can be obtained. The reverse image not only has a significant contrast in color with the original seal area, but also has the opposite texture and shape, so it can effectively offset the interference of the original seal area. This is the principle of reverse image to remove seal interference.

[0343] S5: superimposing the reverse image onto the seal area of ​​the legal document image to offset the interference of the seal, thereby obtaining a first noise reduction image;

[0344] The specific steps of S5 are as follows:

[0345] (1) Align the reverse image with the original legal document image. Since the reverse image is extracted from the seal area, its size and position are consistent with the seal area in the original image. However, in order to ensure accurate superposition, a registration operation is required. Registration can be performed using feature point-based methods such as SIFT and SURF to find the correspondence between the reverse image and the original image and calculate the transformation matrix.

[0346] (2) Based on the registered transformation matrix, the reverse image is superimposed on the seal area of ​​the original image. Specifically, for each seal area pixel in the original image, the corresponding position in the reverse image is calculated based on its coordinates, and then the pixel value of this position in the reverse image is superimposed on the original image.

[0347] (3) The superposition method can adopt the strategy of image fusion, the most common of which are weighted superposition and multiplicative superposition.

[0348] Weighted overlay: Let the original image be I, the inverse image be I_inverse, and the overlaid image be I_overlay, then the weighted overlay formula is:

[0349] I_overlay = w * I + (1-w) * I_inverse

[0350] Where w is the weight coefficient of the original image, 1-w is the weight coefficient of the reverse image, and the value range of w is [0,1]. The larger w is, the more components of the original image are, and vice versa. The value of w can be adjusted adaptively according to the transparency of the stamp area. The higher the transparency, the larger the value of w.

[0351] Multiplicative superposition: The formula for multiplicative superposition is:

[0352] I_overlay = I * (1 I_inverse)

[0353] Both I and I_inverse need to be normalized to the range of [0,1] in advance. This superposition method can better preserve the details of the original image.

[0354] (4) Post-process the superimposed image, mainly smoothing and denoising operations to eliminate noise and mutations that may occur during the superposition process. Methods such as Gaussian filtering and median filtering can be used.

[0355] (5) Output the superimposed and post-processed image as the result of the first denoising.

[0356] For example: Assume that the original legal document image is I, and the pixel value range of its seal area is [0,255]. The inverse image is I_inverse, which has been normalized to the range [0,1]. The two images have been registered. Now they are multiplicatively superimposed:

[0357] I_overlay = I / 255 * (1 I_inverse)

[0358] The obtained I_overlay is still in the range of [0,1] and needs to be multiplied by 255 to restore it to the range of [0,255].

[0359] Then, Gaussian filtering is performed on I_overlay, and the size of the filter kernel is set to 3x3 and the standard deviation is 1. Finally, the filtered image is output as the result of the first denoising.

[0360] It can be seen that the purpose of superimposing the reverse image is to offset the interference of the stamp area. Since the reverse image is opposite to the original stamp area in color, texture, and shape, superimposing them together can achieve the effect of "positive and negative offset", so that the interference of the stamp area is weakened, while the original text information is retained. The advantages of this method are simple and intuitive, and strong interpretability.

[0361] S6: using an image erasing algorithm to erase the seal residual noise in the first denoised image to obtain a second denoised image;

[0362] S6.1: performing local image enhancement on the first denoised image to highlight the text portion covered by the seal;

[0363] The first denoised image is processed with Local Adaptive Histogram Equalization (LAHE). LAHE is a local image enhancement method that can perform histogram equalization independently in different local areas to enhance local contrast.

[0364] The specific steps of LAHE are: first, divide the image into multiple non-overlapping tiles, such as 8x8 or 16x16; then perform histogram equalization on the pixel values ​​in each tile; then perform bilinear interpolation on adjacent tiles to eliminate the step effect at the tile boundaries; finally, splice all the processed tiles together to obtain the LAHE result of the entire image.

[0365] After LAHE processing, the parts of the text covered by the seal will become clearer and more prominent because their local contrast is enhanced. However, LAHE may also amplify noise and require further processing.

[0366] For example: Assuming that the image size of the first denoising is 1024x1024, and the size of the segmented small blocks is 8x8, there are a total of (1024 / 8)x(1024 / 8)=16384 small blocks. The histogram of the pixel values ​​in each small block is calculated, and then equalization is performed. The purpose of equalization is to make the distribution of the histogram more uniform, thereby enhancing the local contrast. For example, if the pixel values ​​in the small block are concentrated between 100-200, the pixel values ​​after equalization may be distributed between 50-250. After processing all the small blocks, bilinear interpolation is performed to make the transition between adjacent small blocks smoother. Finally, all the small blocks are spliced ​​into a complete image as the output of LAHE.

[0367] S6.2: using a median filter or a convolution operation to further erase the residual noise of the seal in the first denoised image;

[0368] Among them, S6.2 takes median filtering as an example, and uses median filtering to further erase the residual noise of the seal in the image of the first denoising, specifically including steps A1-A5:

[0369] A1: grayscale processing the image obtained by the first noise reduction;

[0370] A2: Set the filter window size;

[0371] A3: processing each pixel in the first denoised image using a median filter with the set filter window size;

[0372] A4: Calculate the median value of all pixel values ​​within the filter window and replace the central pixel value with the median value;

[0373] A5: Perform edge preservation or sharpening on the filtered image to enhance image details.

[0374] Specifically,

[0375] A1: Perform grayscale processing on the image after the first noise reduction. The purpose of grayscale is to convert the color image into a grayscale image to simplify the subsequent filtering operation. Common grayscale methods include component method, maximum value method, average value method, weighted average method, etc. The simplest method is to take the average value of the three RGB channels as the grayscale value.

[0376] A2: Set the filter window size. The window size of the median filter is a key parameter that determines the range of pixels involved in the median calculation. The larger the window, the stronger the filtering effect, but the less detail is retained; the smaller the window, the weaker the filtering effect, but the more detail is retained. Commonly used window sizes include 3x3, 5x5, 7x7 and other odd sizes. The choice of window size needs to be weighed according to the characteristics of the noise and the resolution of the image.

[0377] A3: For each pixel in the first denoised image, use a median filter with a set filter window size to process it. Median filtering is a nonlinear filtering method that replaces the value of the central pixel with the median value of all pixel values ​​in the filter window. The median value corresponds to the value in the middle position of the pixel values ​​in the filter window after they are sorted from small to large.

[0378] A4: Calculate the median of all pixel values ​​within the filter window and use the median to replace the central pixel value. The specific steps are:

[0379] (1) Extract all pixel values ​​within the filter window centered on the current pixel;

[0380] (2) Sort these pixel values ​​and take the value in the middle as the median;

[0381] (3) Replace the value of the current center pixel with the calculated median value.

[0382] (4) Slide the filter window and repeat the above steps for each pixel of the image until the entire image is traversed.

[0383] For example: Assuming the current pixel position is (x, y) and the filter window size is 3x3, the pixel position involved in the median calculation is:

[0384] (x-1, y-1), (x-1, y), (x-1, y+1)

[0385] (x, y-1),(x, y),(x, y+1)

[0386] (x+1, y-1), (x+1, y), (x+1, y+1)

[0387] Extract the pixel values ​​of these 9 positions, sort them, take the value of the middle position (the 5th) as the median, and replace the value of the current pixel (x, y) with the median.

[0388] A5: Perform edge preservation or sharpening on the filtered image to enhance image details. Since median filtering may blur the edges and details of the image, post-processing is required to restore and enhance this information. Common edge preservation and sharpening methods are:

[0389] (1) Laplace operator: It extracts edge information of the image through the second-order derivative and can highlight the details of the image. However, it is sensitive to noise.

[0390] (2) Sobel operator: It extracts edge information of the image through the first-order derivative and is more robust to noise. It can extract edges in the horizontal and vertical directions separately.

[0391] (3) Canny operator: A multi-level edge detection algorithm that can obtain an accurate edge map through Gaussian filtering, gradient calculation, non-maximum suppression, double threshold detection and other steps.

[0392] (4) Unsharp Masking: USM (Unsharp Masking) is a method of sharpening by "reverse blurring". It uses the difference between the original image and the blurred image, and superimposes the difference result back to the original image in a certain proportion, thereby enhancing the details of the image.

[0393] Through the above steps, the residual seal noise in the first denoised image can be further removed, and the text covered by the seal can be enhanced to prepare for subsequent text recognition. Among them, the LAHE processing of S6.1 highlights the text, the median filter of S6.2 removes the residual noise, and the edge sharpening of A5 further enhances the text. The three complement each other and jointly improve the effect of noise reduction.

[0394] S7: applying an image restoration algorithm to restore the text covered by the seal in the second denoised image;

[0395] S7.1: Construct a convolutional neural network (CNN) model. The specific steps are as follows:

[0396] (1) Determine the input and output of the CNN model. The input is the image after the second denoising, and the size can be adjusted according to the actual situation, such as 256x256 or 512x512. The output is the restored image, which has the same size as the input.

[0397] (2) Design the network structure of the CNN model. A commonly used structure is the encoder-decoder structure, also known as the U-Net structure. The encoder part consists of several convolutional layers and pooling layers, which are used to extract image features; the decoder part consists of several deconvolutional layers (or upsampling layers) and convolutional layers, which are used to restore image details. The encoder and decoder transmit information through skip connections to reduce information loss.

[0398] (3) Determine the parameters of each convolution layer, including the size of the convolution kernel, the number of convolution kernels, the step size, the padding method, etc. Common convolution kernel sizes include 3x3, 5x5, 7x7, etc. The number can range from 32 to 512. The step size is usually 1, and the padding method is usually "same" (that is, the output size after padding is the same as the input). The parameters of the pooling layer include the pooling window size, step size, etc. The commonly used one is the maximum pooling with a 2x2 window and a step size of 2.

[0399] (4) Add a skip connection between the encoder and the decoder, that is, concatenate the output of a certain layer of the encoder with the output of the corresponding layer of the decoder as the input of the next layer of the decoder. This allows the features extracted by the encoder to be directly passed to the decoder, reducing information loss.

[0400] (5) Add a 1x1 convolutional layer at the end of the network to map the number of channels of the feature map to the number of channels of the output image (usually 1 or 3).

[0401] (6) Select loss function and optimization algorithm. For image restoration tasks, commonly used loss functions include mean square error (MSE), mean absolute error (MAE), structural similarity (SSIM), etc. Optimization algorithms can be Adam, RMSprop, etc.

[0402] (7) Add regularization techniques to the network, such as L1 / L2 regularization, Dropout, etc., to reduce overfitting.

[0403] S7.2: Obtain a training data set, and use the training data set to train the model on the second denoised image. The specific steps are as follows:

[0404] (1) Collect and annotate training data. The training data should include two parts: the original legal document image and the corresponding image with the seal area covered. A large number of training samples can be generated by artificial synthesis, that is, randomly selecting some legal document images and superimposing some seal images on them to form covered images. To ensure that the synthesized image is as realistic as possible, the position, size, color, transparency, etc. of the seal should be randomly changed.

[0405] (2) Preprocess the synthesized training images, including resizing and normalization, to make them suitable for the input requirements of the CNN model.

[0406] (3) Divide the training data into a training set and a validation set, usually in a ratio of 8:2 or 9:1.

[0407] (4) Set training parameters, such as batch size, learning rate, number of epochs, etc.

[0408] (5) Start training the model, that is, input the training data into the CNN model, calculate the loss function, and update the model's weight parameters through the back-propagation algorithm. After each training iteration, evaluate the model's performance on the validation set. If the performance no longer improves, stop training.

[0409] (6) Save the trained model parameters.

[0410] S7.3: Use the trained CNN model to restore the text covered by the seal in the second denoised image. The specific steps are as follows:

[0411] (1) Input the second denoised image into the trained CNN model.

[0412] (2) The CNN model extracts image features through the encoder and restores image details through the decoder.

[0413] (3) In each layer of the decoder, the upsampled feature map is concatenated with the output of the corresponding layer of the encoder, and then the features are fused through the convolutional layer.

[0414] (4) In the last layer of the network, the feature map is mapped to the restored image through 1x1 convolution.

[0415] (5) Perform post-processing on the restored image, such as binarization and denoising, to obtain the final text restoration result.

[0416] (6) To evaluate the quality of text restoration, you can use OCR technology to recognize text in the restored image and compare it with the text in the original image to calculate the recognition accuracy. If the accuracy meets the requirements, the text restoration is successful; otherwise, you may need to further optimize the model or increase the training data.

[0417] The advantages of using CNN model for text recovery are:

[0418] (1) End-to-end training method: no need to manually design complex algorithm processes and parameters, only the training data needs to be prepared.

[0419] (2) By utilizing the powerful feature extraction and representation capabilities of convolutional neural networks, we can automatically learn the distinguishing features of text and seals in images.

[0420] (3) The restoration quality is high. Even when the seal is severely covered, the original text can be restored well.

[0421] In another embodiment, S7 can also use the recursive hierarchical formula of object self-similarity for text recovery. The recursive hierarchical formula of object self-similarity is a mathematical method for capturing features from global to local in an image. By extracting and fusing features in a recursive hierarchical manner, it is possible to achieve fusion of potential features at the spatial and global levels, and is suitable for complex image restoration tasks. Specifically, it includes steps B1-B5:

[0422] B1: grayscale processing the second denoised image;

[0423] B2: Based on the principle of object self-similarity, a recursive hierarchical model is constructed.

[0424] Object self-similarity means that in an image, different regions within the same object usually have similar texture and structural features. For example, in a text image, different parts of the same character (such as strokes, character legs, etc.) usually have similar grayscale distribution and edge direction. Based on this principle, the image can be regarded as composed of several self-similar sub-regions, each of which can be further decomposed into smaller self-similar regions to form a recursive hierarchical structure. This hierarchical structure can be represented by a tree model, called a recursive hierarchical model. Each node of the model corresponds to a sub-region, and there is self-similarity between the parent node and the child node.

[0425] B3: Using a recursive hierarchical model, the similarity between the seal-covered area and the surrounding text area in the second denoised image is analyzed.

[0426] The specific steps are as follows:

[0427] (1) Divide the image into several initial sub-regions. You can use methods such as uniform grid segmentation and superpixel segmentation.

[0428] (2) For each sub-region, extract its texture and structural features, such as gray-level co-occurrence matrix (GLCM), local binary pattern (LBP), etc.

[0429] (3) To calculate the similarity between different sub-regions, metrics such as Euclidean distance and cosine similarity can be used.

[0430] (4) Based on the similarity measure, similar sub-regions are merged into larger regions to form new parent nodes.

[0431] (5) Repeat steps (2) to (4) for the newly formed parent node until no further merging is possible, thus forming a complete recursive hierarchical model.

[0432] (6) In the model, find the node where the seal coverage area is located and analyze its similarity with the surrounding text area nodes. If the similarity is high, it means that the seal coverage area and the text area may belong to the same character; if the similarity is low, it means that the seal coverage area may be noise or background.

[0433] B4: Select the convolutional neural network CNN architecture U-Net suitable for self-similarity modeling.

[0434] U-Net is a CNN model based on an encoder-decoder structure. It was originally used for medical image segmentation and later widely used in various image-to-image conversion tasks. The characteristics of U-Net are:

[0435] The encoder part consists of several convolutional layers and downsampling layers to extract multi-scale features of the image;

[0436] The decoder part consists of several upsampling layers and convolutional layers to restore the spatial details of the image;

[0437] Use skip connections between the encoder and decoder to concatenate the shallow features of the encoder with the deep features of the decoder to reduce information loss;

[0438] The output layer uses 1x1 convolution to map the number of channels of the feature map to the number of channels of the target image. This structure enables U-Net to simultaneously utilize global and local feature information to finely model and restore the object boundaries and internal textures in the image.

[0439] Therefore, U-Net is very suitable for modeling self-similarity in images and achieving restoration of stamp-covered areas.

[0440] B5: Use the U-Net architecture for recursive hierarchical processing to extract and fuse the global and local features of the image to repair the text covered by the seal.

[0441] Specifically including B5.1 to B5.7:

[0442] B5.1: Use the U-Net encoder to perform multi-level downsampling on the input document image with seal. The specific steps are as follows:

[0443] (1) The input image is passed through a series of convolutional layers and pooling layers to gradually reduce the size of the feature map while increasing the number of channels of the feature map.

[0444] (2) Each convolutional layer consists of several convolution kernels, the size of which is usually 3x3 or 5x5, with a step size of 1 and a padding of "same". The number of convolution kernels can increase according to the network depth, such as 64, 128, 256, 512, etc.

[0445] (3) Each convolutional layer is usually followed by an activation function, such as ReLU, LeakyReLU, etc., which is used to introduce nonlinear transformations and improve the network's expressive power.

[0446] (4) After a certain number of convolutional layers, there will be a pooling layer, usually using maximum pooling, with a pooling kernel size of 2x2 and a step size of 2. The pooling layer can reduce the spatial resolution of the feature map while expanding the receptive field, allowing the network to capture features of larger scales.

[0447] (5) After several convolutions and pooling, the size of the feature map continues to shrink and the number of channels continues to increase, forming a multi-level feature pyramid.

[0448] For example: Assume that the input image size is 256x256, and the U-Net encoder contains 4 downsampling modules, each of which contains 2 convolutional layers and 1 pooling layer. Then the change process of the feature map is:

[0449] Input image (256x256x1) -> Convolution + ReLU (256x256x64) -> Convolution + ReLU (256x256x64) -> Pooling (128x128x64) ->

[0450] Convolution + ReLU (128x128x128) -> Convolution + ReLU (128x128x128) -> Pooling (64x64x128) ->

[0451] Convolution + ReLU (64x64x256) -> Convolution + ReLU (64x64x256) -> Pooling (32x32x256) ->

[0452] Convolution + ReLU (32x32x512) -> Convolution + ReLU (32x32x512) -> Pooling (16x16x512)

[0453] B5.2: Through continuous convolution and pooling operations, the global features of the second denoised image are extracted. Global features refer to large-scale, high-level semantic information in the image, such as the overall shape, structure, and distribution of characters. In the deep layers of the encoder, the feature map has a lower spatial resolution but a larger number of channels, so it can represent more abstract and global features. These features are very important for understanding the content and semantics of the image, and help guide the subsequent text restoration process.

[0454] B5.3: Apply sliding window technology on each layer of feature map to extract features of local image blocks. Local features refer to small-scale, low-level texture information in the image, such as edges, corners, patches, etc. In the shallow layer of the encoder, the spatial resolution of the feature map is higher and the number of channels is smaller, so it can represent more detailed and local features. In order to further extract these local features, the sliding window technology can be used on each layer of feature map to divide the feature map into several overlapping small blocks, and extract features from each small block. Common local feature extraction methods are:

[0455] (1) Convolution kernel: Use a smaller convolution kernel (such as 1x1, 3x3) to convolve the local image block to obtain the local feature vector.

[0456] (2) Pooling: Perform maximum pooling or average pooling on the local image block to obtain the local feature vector.

[0457] (3) Statistics: Calculate the mean, variance, histogram and other statistics of the local image block as the local feature vector.

[0458] The extracted local feature vectors can be concatenated with the original feature maps to form a richer and multi-scale feature representation.

[0459] B5.4: Use skip connections to pass the features extracted from the encoder to the corresponding decoder layer. Skip connections are a key design of U-Net, which can directly pass shallow features in the encoder to the deep layers of the decoder to achieve feature reuse and fusion. Specifically, for each downsampling module in the encoder, there is a corresponding upsampling module that is symmetrical to it. During the upsampling process of the decoder, the output feature map of the encoder downsampling module is concatenated with the output feature map of the decoder upsampling module as the input of the next upsampling module. This cross-layer feature transfer can effectively alleviate the problem of gradient vanishing, and can also combine local and global features to improve the representation ability of features.

[0460] B5.5: During the decoding process, the image is upsampled layer by layer, and the features of the encoder are fused with the features of the decoder. The role of the decoder is to gradually restore the features extracted by the encoder to the size and shape of the original image. Each upsampling module usually contains an upsampling layer and several convolutional layers. The upsampling layer can use transposed convolution (deconvolution) or interpolation methods (such as bilinear interpolation) to double the size of the feature map. The role of the convolutional layer is to further extract and fuse the upsampled features and splice them with the features passed by the encoder. After multiple upsampling and feature fusion, the size of the feature map continues to increase, the number of channels continues to decrease, and finally it is restored to the same size as the input image.

[0461] B5.6: In the last layer of the decoder, a convolutional layer is used to restore the fused feature map to an image of the same size as the input image. This step is equivalent to mapping the feature map back to the original image space to generate the repaired image. Usually a 1x1 convolution kernel is used to reduce the number of channels of the feature map to 1 (grayscale image) or 3 (color image), and an output image of the same size as the input image is obtained. The pixel value of the output image represents the repair result of the text at each position.

[0462] B5.7: Generate a repaired image and restore the text covered by the seal. After the encoder-decoder structure of U-Net, the input document image with the seal is converted into a repaired image, in which the text area covered by the seal is restored and reconstructed. The repaired image has the same size and shape as the original image, but the pixel values ​​of the seal area are updated to the text pixel values ​​predicted by the network. Ideally, in the repaired image, the seal area is visually indistinguishable from the surrounding text area, forming a coherent text structure.

[0463] The U-Net structure extracts multi-scale features through the encoder, the decoder gradually restores image details, and the jump connection realizes feature fusion, and finally generates a high-quality restored image. In the text restoration task, U-Net can effectively utilize the structural and semantic correlations between text regions, and achieve refined restoration of the seal-covered area by learning the feature representation of local texture and global shape. Compared with traditional image processing-based methods, the U-Net-based method can better handle complex and diverse seal noises while retaining the integrity and readability of the text.

[0464] S8: After successful recovery, use optical character recognition (OCR) technology to extract the text content under the seal.

[0465] The specific steps are as follows:

[0466] (1) Preprocess the restored image, including binarization, denoising, tilt correction and other operations, to improve the accuracy of OCR recognition.

[0467] Binarization: Convert the grayscale image to a black and white binary image. You can use a global threshold method (such as the Otsu algorithm) or an adaptive threshold method (such as an adaptive Gaussian threshold). Binarization can separate the text area from the background area, facilitating subsequent text extraction.

[0468] Denoising: Denoising the binarized image can be performed by using morphological operations (such as opening and closing operations) or median filtering to remove isolated noise points and burrs to make the text edges smoother.

[0469] Tilt correction: If the document image is tilted, it needs to be corrected to align the text horizontally. Tilt correction can use algorithms such as Hough transform and least squares method to estimate the tilt angle of the image and then rotate the image.

[0470] (2) Perform layout analysis on the preprocessed image and extract the text line area. The purpose of layout analysis is to divide the image into several text lines and identify each line of text separately. Common text line extraction methods are:

[0471] Projection analysis: Perform pixel projection on the binary image in horizontal and vertical directions, and determine the position and range of the text line based on the peak and valley values ​​of the projection curve.

[0472] Connected domain analysis: Mark the connected domain of the binary image and divide the connected pixels into a region. The text line area can be distinguished by analyzing the size, aspect ratio, spacing and other characteristics of the connected domain.

[0473] Deep learning-based method: Use convolutional neural networks (such as FCN, PSENet, etc.) to classify images at the pixel level and directly predict whether each pixel belongs to a text line or background.

[0474] (3) Perform character segmentation on each line of text, dividing the line of text into individual characters. The character segmentation methods are:

[0475] Vertical projection: Perform pixel projection in the vertical direction on the line text image, and determine the left and right boundaries of each character based on the peaks and troughs of the projection curve. This method is suitable for situations where there is a clear gap between characters.

[0476] Connected domain analysis: Mark the connected domains of the text image, and each connected domain corresponds to a character. This method is suitable for the case where there is no adhesion between characters.

[0477] Image segmentation-based method: Use image segmentation algorithms such as region growing and watershed to segment the text line image into multiple character regions. This method can handle the situation where characters are stuck together.

[0478] (4) Extract and recognize the features of the segmented single character image to obtain the final text content. Commonly used OCR character recognition methods are:

[0479] Template matching-based method: Match the character image with the pre-stored character template to find the character corresponding to the most similar template. Common matching metrics include Euclidean distance, Hamming distance, etc.

[0480] Feature extraction based method: extract a series of features from the character image, such as histogram of oriented gradients (HOG), local binary pattern (LBP), etc., and then use a classifier (such as support vector machine SVM, random forest, etc.) to classify the features to obtain the character category.

[0481] Methods based on deep learning: Use convolutional neural networks (such as LeNet, AlexNet, ResNet, etc.) to perform end-to-end recognition of character images and directly output character categories. Deep learning methods usually require a large number of training samples and computing resources, but have higher recognition accuracy.

[0482] (5) Post-process the recognized character results, including character correction, language model, etc., to improve recognition accuracy and readability.

[0483] Character correction: Correct the recognized characters according to their context information. For example, correct the recognized "o" to "0", correct the recognized "l" to "1", etc.

[0484] Language model: Use natural language processing technology to perform semantic analysis and error correction on the recognized character sequence. For example, use the N-gram language model to estimate the probability of each character appearing based on the relationship between the characters, and replace or delete the characters with low probability.

[0485] OCR technology is an important tool in the field of text recognition. It can convert the text content in the image into a computer-editable text format, which facilitates the storage, retrieval and analysis of documents. After the seal is removed and the text is repaired, the original text content of the seal-covered area can be further extracted using OCR technology, completing the entire image processing and text recognition process.

[0486] Embodiment 2

[0487] like Figure 4 As shown, the embodiment of the present application further provides a seal image denoising system 40 under content extraction, comprising:

[0488] An acquisition module 41 is used to acquire the legal document image to be processed;

[0489] A detection module 42, configured to detect the seal area of ​​the legal document image using an image segmentation algorithm;

[0490] An extraction module 43, used for extracting features of the seal area;

[0491] A generating module 44, for generating a reverse image according to the features of the seal area, wherein the reverse image is a fusion image of a reverse color image, a reverse texture image and a reverse shape image;

[0492] A superposition module 45 is used to superimpose the reverse image onto the seal area of ​​the legal document image to offset the interference of the seal and obtain a first noise reduction image;

[0493] An erasing module 46 is used to use an image erasing algorithm to erase the seal residual noise in the first denoised image to obtain a second denoised image;

[0494] Restoration module 47, used for restoring the text covered by the seal in the second denoised image by applying an image restoration algorithm;

[0495] The recognition module 48 is used to extract the text content under the seal using optical character recognition (OCR) technology after the restoration is successful.

[0496] Embodiment 3

[0497] The present application also provides a computer device, such as Figure 5 As shown, the computer device comprises:

[0498] at least one processor; and,

[0499] a memory communicatively connected to the at least one processor; wherein,

[0500] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the seal image denoising method under the above-mentioned content extraction.

[0501] An embodiment of the present application also provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute the seal image denoising method under the above-mentioned content extraction.

[0502] An embodiment of the present application also provides a computer program product, including computer instructions, characterized in that when the computer instructions are executed by a processor, the steps of the seal image denoising method under the above-mentioned content extraction are implemented.

[0503] Each module in the seal image denoising system under the above content extraction can be implemented in whole or in part by software, hardware and their combination. Each module can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.

[0504] In one embodiment, a computer device is also provided. The computer device is a seal image denoising system under content extraction mentioned in the above method embodiment. Its internal structure diagram can be as follows: Figure 5 As shown. The computer device includes a processor, a memory, an input / output interface (I / O for short) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface.

[0505] Among them, the processor of the computer device is used to provide computing and control capabilities, and can be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, etc., but is not limited thereto. The processor may include one or more processors, for example, one or more central processing units (CPUs). When the processor is a CPU, the CPU may be a single-core CPU or a multi-core CPU. The processor may also include one or more dedicated processors, and the dedicated processor may include a GPU, an FPGA, etc., for accelerated processing. The processor is used to call the program code and data in the memory and execute the steps in the above method embodiment. For details, please refer to the description in the method embodiment, which will not be repeated here.

[0506] The memory of the computer device includes, but is not limited to, non-volatile storage media and internal memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM may be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium.

[0507] The input / output interface of the computer device is used to exchange information between the processor and external devices.

[0508] The communication interface of the computer device is used to communicate with an external terminal via a network connection.

[0509] When the computer program is executed by a processor, a method for seafloor geological imaging is implemented.

[0510] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the division of each unit / module is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The mutual coupling, direct coupling, or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of systems or units, which can be electrical, mechanical or other forms.

[0511] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0512] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable system. The computer instructions can be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a read-only memory (ROM), or a random access memory (RAM), or a magnetic medium, such as a floppy disk, a hard disk, a tape, a disk, or an optical medium, such as a digital versatile disc (DVD), or a semiconductor medium, such as a solid state disk (SSD), etc.

[0513] The system of the embodiments of the present disclosure can execute the method provided by the embodiments of the present disclosure, and the implementation principles are similar. The actions performed by each module in the system of each embodiment of the present disclosure correspond to the steps in the method of each embodiment of the present disclosure. For the detailed functional description of each module of the system, please refer to the description in the corresponding method shown in the previous text, which will not be repeated here.

[0514] The above is only an optional implementation method for some implementation scenarios of the present disclosure. It should be pointed out that for ordinary technicians in this technical field, without departing from the technical concept of the scheme of the present disclosure, other similar implementation methods based on the technical ideas of the present disclosure are also within the protection scope of the embodiments of the present disclosure.

Claims

1. A seal image denoising method under content extraction, characterized in that: include: Obtain images of legal documents to be processed; Detecting the seal area of ​​the legal document image using an image segmentation algorithm; Extracting features of the seal area; Generate a reverse image according to the characteristics of the seal area, wherein the reverse image is a fusion image of the reverse color image, the reverse texture image and the reverse shape image; superimposing the reverse image onto the seal area of ​​the legal document image to offset the interference of the seal, thereby obtaining a first noise reduction image; Using an image erasing algorithm to erase the seal residual noise in the first denoised image to obtain a second denoised image; Applying an image restoration algorithm to restore the text covered by the seal in the second denoised image; After successful recovery, the text content under the seal is extracted using optical character recognition (OCR) technology; The step of extracting the features of the seal area includes: Calculating a color histogram of the seal area to obtain color distribution information, and normalizing the color distribution information to obtain a standardized color feature vector; Using local binary pattern LBP to describe the texture information of the seal, calculating the LBP histogram, obtaining the texture feature distribution, normalizing the texture features, and obtaining a standardized texture feature vector; The shape information of the seal area is extracted using the Hu moment, the shape feature vector is obtained by calculating the Hu moment, and then a logarithmic transformation is performed; Wherein, according to the characteristics of the seal area, a reverse image is generated, and the reverse image is an image fused with a reverse color image, a reverse texture image and a reverse shape image, including: Performing color inversion processing on the color feature vector, applying the inverted color feature to the stamp area, and generating a reverse color image; Generating a texture feature opposite to the texture feature vector, applying the reverse texture feature to the stamp area, and generating a reverse texture image; generating a shape opposite to the shape feature vector, applying the reverse shape to the stamp area, and generating a reverse shape image; The reverse color image, the reverse texture image and the reverse shape image are fused to generate the final reverse image.

2. The method according to claim 1, characterized in that: The seal area of ​​the legal document image is detected using an image segmentation algorithm, including: Preprocessing the legal document image; Using Otsu threshold method to determine the best segmentation threshold so as to separate the stamp area from the background; Using morphological opening operation to remove some noise points in the stamp area; Filling some holes in the stamp area using a morphological closing operation; The seal area is extracted using a connected component labeling algorithm.

3. The method according to claim 1, characterized in that Erasing the seal residual noise in the first denoised image using an image erasing algorithm to obtain a second denoised image, including: Performing local image enhancement on the first denoised image to highlight the text portion covered by the seal; The residual noise of the seal in the first denoised image is further erased using a median filter or a convolution operation.

4. The method according to claim 3, characterized in that Using a median filter to further erase the residual noise of the seal in the first denoised image, including: Performing grayscale processing on the image subjected to the first noise reduction; Set the filter window size; Processing each pixel in the first denoised image using a median filter with the set filter window size; Calculate the median of all pixel values ​​within the filter window and replace the central pixel value with the median; The filtered image is edge-preserved or sharpened to enhance image details.

5. The method according to claim 1, characterized in that Applying an image restoration algorithm to restore the text covered by the seal in the second denoised image includes: Build a convolutional neural network CNN model; Acquire a training data set, and use the training data set to perform model training on the second denoised image; The trained CNN model is used to restore the text covered by the seal in the second denoised image.

6. The method according to claim 1, characterized in that Applying an image restoration algorithm to restore the text covered by the seal in the second denoised image includes: Performing grayscale processing on the image subjected to the second noise reduction; Based on the principle of object self-similarity, a recursive hierarchical model is constructed; Utilizing the recursive hierarchical model, analyzing the similarity between the seal-covered area and the surrounding text area in the second denoised image; Select the convolutional neural network (CNN) architecture U-Net suitable for self-similarity modeling; The U-Net architecture is used to perform recursive hierarchical processing to extract and fuse the global and local features of the image, thereby repairing the text covered by the seal.

7. The method according to claim 6, characterized in that The U-Net architecture is used to perform recursive hierarchical processing, extract and fuse the global and local features of the second denoised image, and restore the text covered by the seal, including: Use the U-Net encoder to perform multi-level downsampling on the input document image with seal; Extracting global features of the second denoised image through continuous convolution and pooling operations; Apply sliding window technology on each layer of feature map to extract the features of local image blocks; Using skip connections to pass the features extracted from the encoder to the corresponding decoder layer; During decoding, the image is upsampled layer by layer, and the features of the encoder are fused with the features of the decoder; In the last layer of the decoder, a convolutional layer is used to restore the fused feature map to an image of the same size as the input image; Generate a repaired image and restore the text covered by the stamp.

8. A seal image denoising system under content extraction, characterized in that: include: An acquisition module, used for acquiring the legal document image to be processed; A detection module, used for detecting the seal area of ​​the legal document image using an image segmentation algorithm; An extraction module, used for extracting features of the seal area; A generating module, used for generating a reverse image according to the characteristics of the seal area, wherein the reverse image is a fusion image of a reverse color image, a reverse texture image and a reverse shape image; A superposition module, used for superimposing the reverse image onto the seal area of ​​the legal document image to offset the interference of the seal and obtain a first noise reduction image; An erasing module, used for erasing the residual seal noise in the first denoised image by using an image erasing algorithm to obtain a second denoised image; A restoration module, used for restoring the text covered by the seal in the second denoised image by applying an image restoration algorithm; A recognition module, used to extract text content under the seal using optical character recognition (OCR) technology after successful recovery; The extraction module is used to extract the features of the seal area, including: Calculating a color histogram of the seal area to obtain color distribution information, and normalizing the color distribution information to obtain a standardized color feature vector; Using local binary pattern LBP to describe the texture information of the seal, calculating the LBP histogram, obtaining the texture feature distribution, normalizing the texture features, and obtaining a standardized texture feature vector; The shape information of the seal area is extracted using the Hu moment, the shape feature vector is obtained by calculating the Hu moment, and then a logarithmic transformation is performed; The generating module is used to generate a reverse image according to the characteristics of the seal area, wherein the reverse image is a fusion image of a reverse color image, a reverse texture image and a reverse shape image, and comprises: Performing color inversion processing on the color feature vector, applying the inverted color feature to the stamp area, and generating a reverse color image; Generating a texture feature opposite to the texture feature vector, applying the reverse texture feature to the stamp area, and generating a reverse texture image; generating a shape opposite to the shape feature vector, applying the reverse shape to the stamp area, and generating a reverse shape image; The reverse color image, the reverse texture image and the reverse shape image are fused to generate the final reverse image.