Document restoration processing method, device, computer storage medium and terminal

By extracting pixels that conform to the range of the color component set to form a binary image, and separating text and seal parts, the problem of poor restoration quality of the seal area in the existing technology is solved, and more accurate document restoration is achieved.

CN113312982BActive Publication Date: 2024-09-17ZHUHAI KINGSOFT OFFICE SOFTWARE +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110496989.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-07
Publication Date
2024-09-17
Estimated Expiration
2041-05-07

AI Technical Summary

Technical Problem

When restoring an original image into an editable document using the existing technology, the restoration quality of the seal area is poor, especially when the seal and text overlap or are not aligned, which affects the recognition accuracy of the text.

Method used

By acquiring the image to be processed, pixels that conform to the range of the color component set are extracted to form a binary image, and the text and seal parts are separated, thereby accurately restoring the seal area and text in the new document.

Benefits of technology

It improves the restoration quality of the seal area, avoids the interference of text recognition, and improves the processing effect of the seal area during the document restoration process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113312982B
    Figure CN113312982B
Patent Text Reader

Abstract

This article discloses a document restoration processing method, device, computer storage medium and terminal. The embodiment of the present invention obtains an image to be processed; extracts pixel points in the image to be processed that fall within a preset color component set range to form a first binary image corresponding to the image of the text part in the image to be processed; extracts a second binary image of the image to be processed; and restores the seal image and text in the seal area to be detected to a new document according to the image to be processed, the first binary image and the second binary image. By restoring the text and seal image in the seal area to be detected, the restoration quality of the seal area in the process of restoring the editable document is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This article relates to but is not limited to document restoration technology, and in particular refers to a document restoration processing method, device, computer storage medium and terminal. Background Art

[0002] Currently, some documents are stored in the form of images. In order to edit and store the text contained in the image, the original image containing the document needs to be restored to an editable document.

[0003] When restoring an original image to an editable document, if the original image contains a stamp, the relevant technology mainly includes the following two processing methods: 1. Determine the stamp area contained in the original image, cut out the stamp area, and directly paste it into the document restored from the original image; 2. Directly perform content recognition on the original image; Figure 1 Schematic diagram of a document obtained by pasting a stamp area in the related art, such as Figure 1 As shown, when the seal area cannot be aligned with other parts of the document, the image of the seal area will affect the display of some text; in the document obtained by content recognition, there is an overlapping part between the seal and the text, and some text on the seal will be recognized as ordinary text. The seal restoration effect is poor, and the seal on the text is recognized as text, affecting the accuracy of text recognition.

[0004] With respect to the problem that the document restoration quality of the seal area obtained by pasting or content recognition in the prior art is poor, no solution has been proposed yet. Summary of the invention

[0005] The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.

[0006] The embodiments of the present invention provide a document restoration processing method, device, computer storage medium and terminal, which can improve the restoration quality of a seal area in the process of restoring an editable document.

[0007] An embodiment of the present invention provides a document restoration processing method, comprising:

[0008] Acquire an image to be processed, wherein the image to be processed is an image of a seal area to be detected in an original document;

[0009] Extracting pixel points in the image to be processed that fall within the range of the color component set according to the color component set to form a first binary image, wherein the first binary image is a binary image of an image corresponding to a text portion in the image to be processed;

[0010] Extracting a second binary image corresponding to the image to be processed, wherein the second binary image includes a binary image of the text portion and a binary image of the seal image portion;

[0011] The seal image and text of the seal area to be detected are restored to a new document according to the image to be processed, the first binary image and the second binary image.

[0012] On the other hand, an embodiment of the present invention further provides a computer storage medium, wherein the computer storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned document restoration processing method is implemented.

[0013] In another aspect, an embodiment of the present invention further provides a terminal, comprising: a memory and a processor, wherein the memory stores a computer program; wherein:

[0014] The processor is configured to execute the computer program in the memory;

[0015] When the computer program is executed by the processor, the document restoration processing method described above is implemented.

[0016] In another aspect, an embodiment of the present invention further provides a document restoration processing device, comprising: an acquisition unit, a composition unit, an extraction unit and a restoration unit; wherein:

[0017] The acquisition unit is used to: acquire an image to be processed, wherein the image to be processed is an image of a seal area to be detected in an original document;

[0018] The composition unit is used to: extract pixel points in the image to be processed that fall within the range of the color component set according to the color component set to form a first binary image, wherein the first binary image is a binary image of an image corresponding to a text portion in the image to be processed;

[0019] The extraction unit is used to: extract a second binary image corresponding to the image to be processed, wherein the second binary image is a binary image including the text part and the seal image part;

[0020] The restoration unit is used to restore the seal image and text of the seal area to be detected into a new document according to the image to be processed, the first binary image and the second binary image.

[0021] The embodiment of the present invention obtains an image to be processed; extracts pixel points in the image to be processed that fall within a preset color component set range to form a first binary image of an image corresponding to a text portion in the image to be processed; extracts a second binary image of the image to be processed; and restores the seal image and text in the seal area to be detected to a new document according to the image to be processed, the first binary image, and the second binary image. By restoring the text and seal image in the seal area to be detected, the restoration quality of the seal area in the process of restoring the editable document is improved.

[0022] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The accompanying drawings are used to provide a further understanding of the technical solution of the present invention and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present invention and do not constitute a limitation on the technical solution of the present invention.

[0024] Figure 1 A schematic diagram of a document obtained by pasting a stamp area in the related art;

[0025] Figure 2 A flowchart of a document restoration processing method according to an embodiment of the present invention;

[0026] Figure 3 It is a structural block diagram of a document restoration processing device according to an embodiment of the present invention;

[0027] Figure 4 A method flow chart for an example of application of the present invention;

[0028] Figure 5 A schematic diagram of an original image of an application example of the present invention;

[0029] Figure 6 A schematic diagram of determining the area where a seal is located according to an embodiment of the present invention;

[0030] Figure 7 A schematic diagram of an image to be processed obtained by cropping according to an embodiment of the present invention;

[0031] Figure 8 A schematic diagram of a second binary image of an application example of the present invention;

[0032] Fig. 9 A schematic diagram of a first binary image of an application example of the present invention;

[0033] Fig.10 A schematic diagram of a third binary image of an application example of the present invention;

[0034] Fig.11 A schematic diagram of a seal image obtained as an application example of the present invention;

[0035] Fig.12 A schematic diagram of an image of text in an image to be processed as an example of the application of the present invention;

[0036] Fig.13 A schematic diagram of pasting an image of text into a new document as an application example of the present invention;

[0037] Fig.14 A schematic diagram of an example text detection application of the present invention. DETAILED DESCRIPTION

[0038] In order to make the purpose, technical solution and advantages of the present invention more clear, the embodiments of the present invention will be described in detail with reference to the accompanying drawings. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other arbitrarily without conflict.

[0039] The steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions. Also, although a logical sequence is shown in the flowchart, in some cases, the steps shown or described can be performed in a sequence different from that shown here.

[0040] Figure 2 Flow chart of the document restoration processing method according to an embodiment of the present invention. Figure 2 As shown, including:

[0041] Step 201, obtaining an image to be processed, wherein the image to be processed is an image of a seal area to be detected in an original document;

[0042] Step 202: extracting pixels in the image to be processed that fall within the range of the color component set according to the color component set to form a first binary image, wherein the first binary image is a binary image of an image corresponding to a text portion in the image to be processed;

[0043] Step 203, extracting a second binary image corresponding to the image to be processed, wherein the second binary image includes a binary image of the text part and a binary image of the seal image part, that is, the second binary image is a binary image composed of the text and the seal image part in the image to be processed;

[0044] The second binary image in the embodiment of the present invention may be obtained by performing a binarization process on the image to be processed, including but not limited to: performing a binarization process on the image to be processed by using an adaptive threshold binarization algorithm.

[0045] Step 204 : restore the seal image and text of the seal area to be detected to a new document according to the image to be processed, the first binary image and the second binary image.

[0046] In an optional example embodiment, the color component set of an embodiment of the present invention includes: a color component set of font colors of text written in one or more pre-stored documents; wherein the one or more documents include one or any combination of the following: a standard PDF file, a PDF scan, a PDF file obtained by taking a photo, and a PDF file converted from an editable document; the font color includes one or more font colors in different formats.

[0047] The color component set in the embodiment of the present invention includes a color component set range of pixels corresponding to the text part, and there is at least one color component set range, wherein the color component set range is a set composed of HSV values ​​of pixels of the text part in the image to be processed; the range of the color component set is different for different processing scenarios and different sources of PDF; for example, PDF scans, PDF standard parts, PDFs generated by taking photos, and PDFs converted by other software such as Word or PPT all correspond to different color component set ranges; in addition, the boldness, depth, dots per inch (DPI), and resolution of the font all correspond to different color component set ranges, and different color component set ranges may overlap. Through the above-mentioned color component set range, accurate screening of the text part included in the image to be processed can be achieved.

[0048] Based on the above color component set, the embodiment of the present invention can realize the recognition of the pixels of the text contained in different types of original documents. The embodiment of the present invention can select a color component set for effectively recognizing the pixels of the text part in the original document according to the different original documents. The documents in the embodiment of the present invention include but are not limited to: WORD format documents, PDF documents, text documents and PPT documents, etc.;

[0049] The embodiment of the present invention extracts pixels in the image to be processed that fall within a preset color component set range to form a first binary image corresponding to the image of the text part in the image to be processed; extracts a second binary image of the image to be processed; and restores the seal image and text in the seal area to be detected to a new document based on the image to be processed, the first binary image and the second binary image; the embodiment of the present invention realizes the recognition of the text part in the image to be processed by forming the first binary image of the image corresponding to the text part in the image to be processed by pixels in the color component set range; through the differentiated recognition of the text part, when processing the seal in the image to be processed, the interference of the text part on the seal restoration is avoided, and based on the improvement of the seal image restoration quality, the restoration quality of the seal area in the process of restoring the editable document is improved.

[0050] In an optional example, step 201 of acquiring the image to be processed in the embodiment of the present invention includes: determining the area where the seal is located in the original document; and cropping the original document according to the determined area in the original document to obtain the image to be processed.

[0051] The above process is described below through an optional embodiment. Determining the area where the seal is located in the original document may include: obtaining a seal detection model through training a multi-target detection algorithm based on deep learning; detecting the original document through the seal detection model obtained through training to determine the area where the seal is located; in an exemplary instance, the area where the seal is located may be a rectangular area containing the seal. In an exemplary instance, cropping the original document according to the determined area in the original document may include: cropping the area where the seal is located in the original document according to the coordinates of the area where the seal is located, referring to relevant technologies.

[0052] Based on the above processing, the embodiment of the present invention realizes the determination and cutting of the seal area to be detected, and provides a basis for independently restoring the seal area to be detected.

[0053] In an optional example, the color component set in the implementation of the present invention includes the range of pixels corresponding to the text portion, the range of the color component set is at least one, and the color component set includes: a hue, saturation and value (HSV) color component set.

[0054] In an optional example, step 202 of the embodiment of the present invention extracts pixel points in the image to be processed that fall within the range of the color component set according to the color component set to form a first binary image, including: generating an HSV image of the image to be processed; determining the pixel points of the text contained in the image to be processed by taking the pixel points in the generated HSV image whose HSV values ​​fall within the range of the color component set, wherein the color component set includes: an HSV color component set, and the HSV value is the value of the three-channel hue, saturation and brightness of the image; and forming the determined pixel points of the text contained in the image to be processed into a first binary image.

[0055] The following is an example of how to generate an HSV image. Generating an HSV image of an image to be processed includes: converting the image to be processed from red, green, and blue (RGB) to HSV to obtain the above-mentioned HSV image, wherein the HSV image can also be called an HSV color model.

[0056] The processing of the first binary image in the embodiment of the present invention obtains the pixel information of the text contained in the image to be processed, which provides a basis for restoring the text part of the seal area to be detected.

[0057] In an optional example, the embodiment of the present invention forms a first binary image from the determined pixel points of the text contained in the image to be processed, including: determining the positions of the pixel points of the text part contained in the image to be processed; setting the pixels of the positions of the pixel points of the text part in the second binary image to 255, and setting the pixels of the positions of other pixel points except the positions of the pixel points of the text part to 0, to obtain the first binary image. Fig. 9By setting the pixels in the positions of the pixel points of the text in the second binary image to 255, the pixel points of the text are displayed as white pixels, and setting the pixels in other positions except the pixel points of the text to 0, the pixels other than the text are displayed as black, a binary image that displays the text with white pixels is obtained.

[0058] The above steps are performed by setting the pixels at the positions of the pixel points of the text in the second binary image to 255, and setting the pixels at other positions except the positions of the pixel points of the text to 0, so that only white pixels with a pixel value of 255 are displayed in the binary image, thereby obtaining a binary image of the text part contained in the image to be processed.

[0059] In an optional example, step 204 of the embodiment of the present invention includes: determining the seal attribute classification according to the number of white pixels in the first binary image and the second binary image, wherein the seal attribute classification is the classification of the seal contained in the image to be processed; and processing the image to be processed, the first binary image, and the second binary image according to the judgment result of the seal attribute classification in the image to be processed. The white pixels in the second binary image refer to the pixels with a pixel value of 255.

[0060] The embodiment of the present invention processes seals of different attribute classifications contained in the image to be processed in corresponding ways respectively, thereby improving the processing quality of the text and seal images contained in the image to be processed.

[0061] In an optional example, the embodiment of the present invention determines the stamp attribute classification in the image to be processed according to the number of white pixels in the first binary image and the second binary image, including:

[0062] The ratio of the number of white pixels in the first binary image to the number of white pixels in the second binary image is calculated; when the ratio is greater than a preset threshold, the seal attribute classification of the image to be processed is determined to be a black and white seal image category; when the ratio is less than or equal to the preset threshold, the seal attribute classification of the image to be processed is determined to be a color seal image category. The preset threshold in the embodiment of the present invention may be a percentage threshold.

[0063] The above-mentioned preset threshold in the embodiment of the present invention can be set by a person skilled in the art based on experience after calculating the ratio of the number of white pixels in the first binary image and the second binary image of the color seal and the black and white seal, for example, the preset threshold can be a value within 0.7 to 0.8. The above-mentioned preset threshold is set based on the difference in the number of white pixels in the first binary image and the second binary image of the color seal and the black and white seal, so as to realize the determination of the seal attribute classification in the image to be processed.

[0064] In an optional example, an embodiment of the present invention processes the image to be processed, the first binary image and the second binary image according to the result of determining the seal attribute classification, including: when the judgment result is that the seal attribute classification is a color seal image, the part of the first binary image in the second binary image is removed to obtain a third binary image, wherein the third binary image is the binary image corresponding to the seal image part in the image to be processed; an image of a new text part is obtained according to the correspondence between the image to be processed and the first binary image; wherein the correspondence is a one-to-one correspondence between pixels at the same position; and a seal map of the seal image part is obtained according to the correspondence between the image to be processed and the third binary image, wherein the seal map of the seal image part is an image in which the part other than the seal image part is transparent.

[0065] In the above processing, the corresponding relationship is a one-to-one correspondence between pixels of each group of the same pixel coordinates after the image to be processed, the first binary image and the third binary image are defined using the same pixel coordinates; removing part of the first binary image from the second binary image to obtain the third binary image includes: subtracting the second binary image from the first binary image to obtain the third binary image, wherein the subtraction of the second binary image from the first binary image includes: subtracting pixels at the same position in the second binary image and the first binary image.

[0066] The above processing, for the image to be processed whose seal attributes are classified as a color seal image, separately identifies and processes the text part and the seal part contained in the image, so as to avoid the text part content interfering with the restoration processing of the seal part content, and also avoid the seal part content affecting the restoration of the text part. By restoring the text part and the seal part separately, a seal image with a transparent background can be obtained, thereby improving the processing quality of the image to be processed.

[0067] In an optional example, the embodiment of the present invention obtains the seal map of the seal image part according to the correspondence between the image to be processed and the third binary image, including: converting the third binary image into a second four-channel image; for the second four-channel image obtained by the conversion, setting the alpha channel of the pixel points with a pixel value of 0 in the second binary image to 255 to obtain the seal map of the seal image part of the color seal. Fig.10 and Fig.11 , after converting the third binary image to the second four-channel image, Fig.10 The second binary image shown in FIG. 1 is obtained by setting the pixel to 0 (black pixel, in Fig.10 The alpha channel of the second four-channel image (the black part) is 255, and the background part except the color stamp in the second four-channel image is processed as transparent, so as to obtain the stamp map of the stamp image part whose background is the transparent color stamp.

[0068] In the embodiment of the present invention, the four-channel image (RGBA) is a color space representing red, green, blue and alpha; it actually adds extra information to the RGB model. The alpha channel is generally used as an opacity parameter. If the alpha channel value of a pixel is 0%, it is completely transparent (that is, invisible), and a value of 100% means a completely opaque pixel (traditional digital image). The alpha channel value can be expressed as a percentage, an integer, or a real number from 0 to 1 like the RGB parameter.

[0069] The embodiment of the present invention sets the pixel at the same position as the pixel 0 in the first binary image in the image to be processed to 255; Figure 7 , Fig. 9 and Fig.12 As a schematic diagram, in the embodiment of the present invention, in the image to be processed 7, Fig. 9 The pixel corresponding to the pixel point with a pixel value of 0 (black pixel) in the first binary image is set to 255 (set to white loudness), and Figure 7 The stamp part in the image is set to white, and the stamp part is removed, thus obtaining Fig.12 The image shown contains only the text part of the image to be processed. The third binary image corresponding to the seal part in the image to be processed is converted into a second four-channel image, and the alpha channel of the pixel points with a pixel value of 0 in the second binary image is set to 255, and the pixels except the color seal part are processed as transparent, so as to obtain a color seal with a transparent background.

[0070] In an optional example, the embodiment of the present invention obtains a new image of the text portion according to the correspondence between the image to be processed and the first binary image, including: retaining the pixels at the same position in the image to be processed as the pixels in the first binary image where the pixel is 255, and setting the pixels at the same position in the image to be processed as the pixels in the first binary image where the pixel is 0 to 255, thereby obtaining a new image of the text portion. Figure 7 , Fig. 9 and Fig.12 As a schematic diagram, the pixels at the same position as the pixel 255 in the first binary image in the image to be processed are retained, that is, according to Fig. 9 The position of the text part (white pixels) is preserved Figure 7 The pixels in the Chinese character part; the pixels at the same position as the pixels in the first binary image where the pixels are 0 are set to 255, that is, Fig. 9 The position of the non-text part (black pixels) will be Figure 7 Zhongyu Fig. 9 The pixel at the position of the black pixel in is set to 255, and we get Fig.12 The text portion of the image.

[0071] The embodiment of the present invention processes the image to be processed and the first binary image to obtain an image of the text portion of the image to be processed containing a color seal.

[0072] In an optional example, the processing of the image to be processed, the first binary image and the second binary image according to the judgment result of the seal attribute classification in the image to be processed includes: when the judgment result is that the seal attribute classification is a black seal image, obtaining a seal map including the text part and the seal image part of the seal area to be detected according to the second binary image, wherein the seal map is an image in which all parts except the black pixel part are transparent; see Figure 7 For the image to be processed, in the embodiment of the present invention, for the black seal image, except for the black pixel portion of the seal image shown in the figure, the other portions are transparent.

[0073] The embodiment of the present invention classifies the image to be processed as a black seal image by obtaining the image except the text and seal ( Figure 7 The other parts of the black pixel part in the image to be processed are transparent images, and a seal map containing the text part and the seal image part of the seal area to be detected is obtained, that is, an image containing text and black seal is obtained while obtaining a transparent background.

[0074] In an optional example embodiment, an embodiment of the present invention restores the seal image and text of the seal area to be detected to a new document based on the image to be processed, the first binary image and the second binary image, including: according to the position of the image to be processed, pasting the image of the new text part in the restored image to be processed and the seal map of the obtained seal image part into the new document.

[0075] The embodiment of the present invention classifies the seal attribute as a color seal image when the judgment result is that the seal attribute is a color seal image. According to the position of the image to be processed, the image of the new text part in the restored image to be processed and the seal map of the seal image part of the color seal are pasted into a new document, thereby realizing the restoration processing of the image to be processed containing the color seal.

[0076] In an optional example embodiment, an embodiment of the present invention restores the seal image and text of the seal area to be detected to a new document based on the image to be processed, the first binary image and the second binary image, including: according to the position of the image to be processed, pasting the restored seal map containing the text part and the seal image part of the seal area to be detected into the new document.

[0077] The embodiment of the present invention judges that the seal attribute is classified as a black seal image, and pastes the seal map of the text part and the seal image part of the restored image to be processed containing the seal area to be detected into a new document according to the position of the image to be processed, thereby realizing the restoration processing of the image to be processed containing the black seal.

[0078] The embodiment of the present invention restores the text and seal image contained in the processed image to a new document according to the position of the image to be processed, thereby realizing the restoration of the text and seal contained in the part of the image to be processed in the new document. When the restored seal map containing the text in the seal area to be detected, the text in the image to be processed and the obtained seal map are pasted into the new document, the restored position is determined according to the image analysis method in the related art, which will not be described in detail here.

[0079] In an optional implementation manner, the color component set of the embodiment of the present invention includes one or any combination of the following: the color component range is: H value is less than or equal to 180; S value is less than or equal to 155; V value is less than or equal to 146; the color component range is: H value is less than or equal to 180; S value is less than or equal to 93; V value is greater than or equal to 36 and less than or equal to 100; the color component range is: H value is less than or equal to 180; S value is greater than or equal to 53 and less than or equal to 124; V value is greater than or equal to 53 and less than or equal to 224; the color component range is: H value is less than or equal to 180; S value is greater than or equal to 83 and less than or equal to 94; V value is greater than or equal to 45 and less than or equal to 71; the color component range is: H value is less than or equal to 180; S value is greater than or equal to 73 and less than or equal to 154; V value is greater than or equal to 53 and less than or equal to 150; the color component range is: H value is less than or equal to 180; S value is greater than or equal to 43 and less than or equal to 124; V value is greater than or equal to 35 and less than or equal to 45.

[0080] The color component set in the above embodiment is only a color component set determined according to a conventional document in the embodiment of the present invention. Based on the above color component set, effective recognition of pixel points of text in the conventional document can be achieved.

[0081] The embodiment of the present invention further provides a computer storage medium, in which a computer program is stored. When the computer program is executed by a processor, the above-mentioned document restoration processing method is implemented.

[0082] The embodiment of the present invention further provides a terminal, comprising: a memory and a processor, wherein a computer program is stored in the memory; wherein:

[0083] The processor is configured to execute the computer program in the memory;

[0084] When the computer program is executed by the processor, the document restoration processing method as described above is implemented.

[0085] Figure 3 FIG. 1 is a structural block diagram of a document restoration processing device according to an embodiment of the present invention. Figure 3 As shown, it includes: an acquisition unit, a composition unit, an extraction unit and a restoration unit; wherein,

[0086] The acquisition unit is used to: acquire the image to be processed, wherein the image to be processed is an image of the seal area to be detected in the original document;

[0087] The composition unit is used to: extract pixel points that fall within the range of the color component set in the image to be processed according to the color component set to form a first binary image, wherein the first binary image is a binary image of an image corresponding to a text portion in the image to be processed;

[0088] The extraction unit is used to: extract a second binary image corresponding to the image to be processed, wherein the second binary image is a binary image including a text portion and a seal image portion;

[0089] The restoration unit is used to restore the seal image and text of the seal area to be detected to a new document according to the image to be processed, the first binary image and the second binary image.

[0090] The embodiment of the present invention obtains an image to be processed, wherein the image to be processed is an image of a seal area to be detected in an original document; a first binary image of an image corresponding to a text part in the image to be processed is formed by extracting pixel points in the image to be processed that fall within a preset color component set range; a second binary image of the image to be processed is extracted; and the seal image and text in the seal area to be detected are restored to a new document according to the image to be processed, the first binary image, and the second binary image. By restoring the text and seal image in the seal area to be detected, the restoration quality of the seal area in the process of restoring the editable document is improved.

[0091] In an optional implementation, the acquisition unit is specifically used to: determine the area where the seal is located in the original document; and crop the original document according to the determined area in the original document to obtain the image to be processed.

[0092] In an optional example, the color component set in the implementation of the present invention includes a range of pixel points corresponding to the text portion, and the range of the color component set is at least one, wherein the color component set includes: an HSV color component set.

[0093] In an optional embodiment, the composition unit is specifically used to: generate an HSV image of the image to be processed; determine the pixel points of the text contained in the image to be processed by taking the pixel points whose HSV values ​​in the generated HSV image fall within the range of the color component set; and compose the determined pixel points of the text contained in the image to be processed into a first binary image.

[0094] In an optional embodiment, the composition unit is used to form a first binary image from the pixels of the text contained in the determined image to be processed, including: determining the positions of the pixel points of the text contained in the image to be processed; setting the pixels in the positions of the pixel points of the text in the second binary image to 255, and setting the pixels in the positions of other pixel points except the pixel points of the text to 0, to obtain a first binary image.

[0095] In an optional implementation, the document restoration processing device of the embodiment of the present invention also includes: a judgment unit and a processing unit; wherein the judgment unit is used to: judge the seal attribute classification in the image to be processed, wherein the seal attribute classification is the classification to which the seal contained in the image to be processed belongs; the processing unit is used to: process the image to be processed, the first binary image and the second binary image according to the judgment result of the seal attribute classification in the image to be processed.

[0096] In an optional embodiment, the processing unit of the embodiment of the present invention is used to: when the judgment result is that the seal attribute is classified as a color seal image category, remove part of the first binary image from the second binary image to obtain a third binary image, wherein the third binary image is the binary image corresponding to the seal part in the image to be processed; obtain an image of a new text part based on the correspondence between the image to be processed and the first binary image; obtain a seal map of the seal image part based on the correspondence between the image to be processed and the third binary image, wherein the seal map is an image in which parts other than the seal part are transparent.

[0097] In an optional embodiment, the processing unit of the embodiment of the present invention is used to: when the judgment result is that the seal attribute is classified as a black seal image, obtain a seal map containing the text in the seal area to be detected according to the second binary image, wherein the seal map is an image in which all parts except the black pixel part are transparent.

[0098] In an optional implementation manner, the restoration unit of the embodiment of the present invention is specifically used to paste the restored image of the text portion in the image to be processed and the obtained seal image into a new document according to the position of the image to be processed.

[0099] In an optional implementation manner, the restoration unit of the embodiment of the present invention is specifically used to paste the restored seal image containing the text in the seal area to be detected into the new document according to the position of the image to be processed.

[0100] In an optional implementation manner, the judgment unit in the embodiment of the present invention is specifically used to determine the stamp attribute classification in the image to be processed according to the number of white pixels in the first binary image and the second binary image.

[0101] In an optional embodiment, the judgment unit of the embodiment of the present invention is specifically used to: calculate the ratio of the number of white pixels in the first binary image and the second binary image; when the ratio of the number of white pixels in the first binary image and the second binary image is greater than a preset threshold, determine that the seal attribute classification of the image to be processed is a black and white seal image category; when the ratio of the number of white pixels in the first binary image and the second binary image is less than or equal to a preset threshold, determine that the seal attribute classification of the image to be processed is a color seal image category.

[0102] In an optional embodiment, the processing unit of the embodiment of the present invention is used to: when the judgment result is that the seal attribute classification is a black seal image, obtain a seal map containing the text in the seal area to be detected according to the second binary image, including: when the judgment result is that the seal attribute classification is a black seal image, convert the second binary image into a first four-channel image; for the first four-channel image obtained by the conversion, set the alpha channel of the pixel points with pixels of 0 in the second binary image to 255, and then obtain a seal map containing the text in the seal area to be detected.

[0103] In an optional embodiment, the processing unit of the embodiment of the present invention is used to obtain a seal map of the seal image part according to the correspondence between the image to be processed and the third binary image, including: converting the third binary image into a second four-channel image; for the second four-channel image obtained by the conversion, setting the alpha channel of the pixel points with a pixel value of 0 in the second binary image to 255 to obtain a color seal.

[0104] In an optional embodiment, the processing unit of the embodiment of the present invention is used to obtain an image of a new text part based on the correspondence between the image to be processed and the first binary image, including: retaining the pixels in the image to be processed at the same position as the pixel 255 in the first binary image, and setting the pixels in the same position as the pixel 0 in the first binary image to 255, so as to obtain an image of a new text part.

[0105] In an optional implementation, the color component set in the embodiment of the present invention includes: a color component set of font colors of text written in one or more pre-stored documents; wherein the one or more documents include one or any combination of the following: a standard PDF file, a PDF scan, a PDF file obtained by taking a photo, a PDF file converted from an editable document; the font color includes one or more font colors in different formats.

[0106] In an optional implementation, the color component set in the embodiment of the present invention includes one or any combination of the following: the color component range is: H value is less than or equal to 180; S value is less than or equal to 155; V value is less than or equal to 146; the color component range is: H value is less than or equal to 180; S value is less than or equal to 93; V value is greater than or equal to 36 and less than or equal to 100; the color component range is: H value is less than or equal to 180; S value is greater than or equal to 53 and less than or equal to 124; V value is greater than or equal to 53 and less than or equal to 100. greater than or equal to 224; the color component range is: H value is less than or equal to 180; S value is greater than or equal to 83 and less than or equal to 94; V value is greater than or equal to 45 and less than or equal to 71; the color component range is: H value is less than or equal to 180; S value is greater than or equal to 73 and less than or equal to 154; V value is greater than or equal to 53 and less than or equal to 150; the color component range is: H value is less than or equal to 180; S value is greater than or equal to 43 and less than or equal to 124; V value is greater than or equal to 35 and less than or equal to 45.

[0107] The following briefly describes the embodiments of the present invention through application examples. The application examples are only used to illustrate the present invention and are not used to limit the protection scope of the present invention.

[0108] Application Example 1

[0109] Figure 4 A method flow chart of an example of application of the present invention is shown in FIG. Figure 4 As shown, including:

[0110] Step 401, determining the area where the seal is located in the original image (original document); this application example can use a multi-target detection algorithm based on deep learning to train a seal detection model, detect the original image, and obtain a rectangular area of ​​the seal;

[0111] Figure 5 Schematic diagram of an original image for application example of the present invention, such as Figure 5 As shown, the seal is included in the lower right corner of the document; Figure 6 The schematic diagram of determining the area where the seal is located is an example of the application of the present invention, as shown in FIG. Figure 6 As shown, the area where the seal is located in the original document is determined by the rectangular frame mark.

[0112] Step 402, cropping the original image according to the determined area where the seal is located in the original document to obtain an image to be processed, wherein the image to be processed is an image of the seal area to be detected in the original image; that is, cropping the seal rectangular area image image.

[0113] Figure 7 FIG. 1 is a schematic diagram of an image to be processed obtained by cropping according to an embodiment of the present invention, such as Figure 7As shown, the image to be processed obtained by cropping the rectangular area containing the seal contains, in addition to the seal, text located within the area of the seal to be detected.

[0114] Step 403: Generate the HSV image of the image to be processed; that is, generate the HSV (hue, saturation, and value) image (image_hsv); convert the original image of the seal area into an HSV image through the method of converting RGB to HSV.

[0115] Step 404: Perform binarization processing on the image to be processed to obtain the second binary image; in the embodiment of the present invention, the original image of the seal area (the original document of the area where the seal is located) is binarized through an adaptive threshold binarization algorithm. Figure 8 This is a schematic diagram of the second binary image in the application example of the present invention. As Figure 8 shown, after binarization processing, the area containing color is displayed as white, and the blank area is displayed as black.

[0116] Step 405: Extract the pixel points in the image to be processed that fall within the range of a preset color component set to form the first binary image, where the color component set includes: the HSV color component set, and the first binary image is the binary image corresponding to the text part in the image to be processed.

[0117] The above processing statistically analyzes the color component range set, and the color component range set extracts the pixel points in the HSV image within the color component range set; in an exemplary example, one or more color component range sets in this application example can be obtained through the following processing: one or more pre-stored documents; one or more documents include one or any combination of the following: standard PDF files, PDF scans, PDF files obtained by photographing, and PDF files converted from editable documents; convert the one or more pre-stored documents into sample document images; statistically analyze the color component ranges of the text contained in the converted sample document images to obtain the color component range set.

[0118] In an exemplary example, extracting the pixel points in the image to be processed that fall within the range of a preset color component set includes: determining the pixel points of the text as the pixel points in the image to be processed whose HSV values fall within one or more color component range sets, where the color component set includes: the HSV color component set; for example, the HSV value of a certain pixel point in the HSV image of the image to be processed is H = 15, S = 120, and V = 30. Assuming that the color component range set includes: 0 < H < 180, 0 < S < 255, and 0 < V < 46, then through comparison, it can be determined that the HSV value of this pixel point falls within the color component range set. Therefore, this pixel point is a pixel point of the text.

[0119] The present invention uses the statistical calculation of the color component range of common document text to extract the pixels of text or noise close to the text, excluding the noise that is greatly different from the text, and extracts the text pixels in the color classification concentration to obtain a binary image of the text pixel area (text part), thereby making the cutout clearer; (The present invention uses the statistical color component range set to extract the image_hsv pixel points in the color set according to the color component set; through a large number of statistics, the HSV value range of the HSV of the text pixel points in the common document image is calculated, and the range set of the text HSV value in different scenes is divided into mutually exclusive HSV values. V color range, combined into the text HSV color component set), in the HSV image, according to the pixel points that satisfy the color component set, a binary image of the text pixel area is obtained (the pixels that satisfy the color component set in the binary mask image are set to 255, and the pixels that do not satisfy the color component set are set to 0); this application example extracts the pixel points in the image to be processed that fall into the preset color component set range to form a first binary image, including: determining the text pixel positions of the pixel points of the text contained in the image to be processed; setting the pixels in the positions of the pixel points of the text in the second binary image to 255, and setting the pixels in other positions except the positions of the pixel points of the text to 0, to obtain the first binary image. Fig. 9 Schematic diagram of the first binary image of the present invention application example, such as Fig. 9 As shown, by setting the pixels in the positions of the pixel points of the text in the second binary image to 255, the pixel points of the text are displayed as white pixels, and setting the pixels in other positions except the positions of the pixel points of the text to 0, the pixels other than the text are displayed as black, and a binary image in which the text is displayed as white pixels is obtained. Through the above arrangement, this application example sets the pixels that meet the color component set to 255 and those that do not meet the color component set to 0, and obtains a binary image in which the text is displayed as white pixels (pixels are 255).

[0120] Step 406: Determine the stamp attribute classification in the image to be processed according to the number of white pixels in the first binary image and the second binary image, wherein the stamp attribute classification is the classification to which the stamp contained in the image to be processed belongs; this application example calculates the ratio of the total number of white pixels in the second binary image to the total number of white pixels in the first binary image; if the ratio is greater than 0.7 (empirical value), it is determined that the stamp in the image to be processed is a black stamp; otherwise, it is determined that the stamp in the image to be processed is a color stamp, which may be a stamp of various colors such as red and blue;

[0121] Step 407: Classify and restore the seal image according to the determined seal attributes.

[0122] In an exemplary example, this application example performs seal restoration according to the determined classification of the seal, including: when the seal contained in the seal area image is a black seal, converting the first binary image into a first four-channel image; for the first four-channel image obtained by the conversion, setting the alpha channel of the pixel points with a pixel of 0 in the second binary image to 255, and obtaining a seal map of a black seal containing text in the seal area to be detected. Through the above processing, this application example can obtain a seal map of a black seal with a transparent background.

[0123] In an illustrative example, when this application example processes a black seal, the pixels of the seal area are set to [255, 255, 255] (white fill), and a seal map is obtained by filling the black seal area with white, thereby avoiding text detection and text recognition on the black seal, which affects the document restoration effect due to the low accuracy of text detection and text recognition.

[0124] After obtaining the stamp map of the black stamp, this application example can paste the restored stamp map into a new document restored from the original document according to the position of the image to be processed in the original document.

[0125] In an exemplary embodiment, the application example restores the seal image according to the determined seal attribute classification, including: if the judgment result is that the seal attribute is classified as a color seal image, remove the part of the first binary image from the second binary image to obtain a third binary image, wherein the third binary image is the binary image corresponding to the seal part in the image to be processed; obtain the text in the image to be processed according to the first binary image; obtain the seal map of the seal image part according to the correspondence between the image to be processed and the third binary image, wherein the seal map is an image in which the other parts except the seal part are transparent. Figure 7 and Fig.10 , Fig.10 The white pixels in the middle are the position distribution of the color stamp image. Figure 7 The location containing the color stamp image is Fig.10 The white pixel position corresponds to Fig.10 The position of the white pixel can be determined Figure 7 The location of the color stamp image.

[0126] In an exemplary embodiment, this application example obtains a seal map of the seal image part according to the correspondence between the image to be processed and the third binary image, including: converting the third binary image into a second four-channel image; for the second four-channel image obtained by the conversion, setting the alpha channel of the pixel points with a pixel value of 0 in the second binary image to 255 to obtain the seal map of the seal image part of the color seal.

[0127] Fig.10 Schematic diagram of the third binary graph of the application example of the present invention, such as Fig.10 As shown, the text portion in the third binary image disappears through the subtraction process, and the third binary image only contains the seal displayed in white pixels. Fig.11 Schematic diagram of the seal image obtained by the application example of the present invention, such as Fig.11 As shown, after converting the third binary image into the second four-channel image, by setting the alpha channel of the pixel points with a pixel value of 0 in the second binary image to 255, the background part of the second four-channel image except the color seal is processed to be transparent, and a seal map of the seal image part with a transparent color seal as the background is obtained. When the seal map of the color seal is pasted to the document, the background color of the document will not be affected, and the display quality of the restored document is improved. In an exemplary embodiment, when the seal contained in the seal area image is a color seal, this application example obtains the text in the image to be processed according to the first binary image, including: performing text recognition on the first binary image to obtain the text contained in the first binary image.

[0128] In an exemplary embodiment, the application example obtains text in the image to be processed according to the first binary image, including: retaining the pixel at the same position as the pixel 255 in the first binary image, and setting the pixel at the same position as the pixel 0 in the first binary image to 255, to obtain an image containing only the text in the image to be processed. Assuming that the pixel at the first position in the first binary image is 255 and the pixel at the second position is 0, the application example of the present invention retains the pixel at the first position in the image to be processed, and sets the pixel at the second position in the image to be processed to 255; Fig.12 The schematic diagram of obtaining an image of text in an image to be processed is an application example of the present invention, as shown in FIG. Fig.12 As shown, after the seal part in the first binary image is eliminated, only the text part is left. In an exemplary embodiment, this application example uses the image to be processed (image) and the first binary image (mask_word), and retains the pixels in the corresponding image with a pixel value of 255 in mask_word, that is, retains the pixel point information of the text area, thereby restoring the text within the seal range to the original image for text detection and text recognition), and sets the pixels in the corresponding image with a pixel value of 0 in mask_word to 255, and obtains the image after deducting the seal, that is, obtains the image containing the text after deducting the seal.

[0129] In an exemplary embodiment, after obtaining the text contained in the second binary image or the image containing only text, the application example method also includes: obtaining the text contained in the first binary image or the image containing only text and pasting it into a new document restored from the original document. Fig.13 This is a schematic diagram of an application example of the present invention in which an image of text is pasted into a document, such as Fig.13As shown, in the new document restored from the original document, an image containing only text is displayed, and the image of the text and the image of the seal are separated from each other and do not affect each other.

[0130] In an application example of the present invention, the part of the original document other than the processed image of the seal to be detected is processed by using the existing text recognition method in the relevant technology; the text recognition process includes: determining text coordinates and recognizing text content. Fig.14 This is a schematic diagram of an example text detection application of the present invention, such as Fig.14 As shown, the recognition of text content other than the image to be processed is achieved through relevant technologies.

[0131] An application example of the present invention is to restore the text content and the content of the seal map in the image to be processed respectively, and then restore each part of the content to a document of a preset format according to the text coordinates and the position of the image to be processed to obtain a new document, which includes but is not limited to documents in WORD format, PDF documents, text documents, PPT documents, etc.

[0132] Application Example 2

[0133] The following is an explanation of the document restoration process after distinguishing between black stamps and color stamps.

[0134] 1) Black seal:

[0135] Using mask( Figure 8 ) Generate a seal transparent image, including: converting image into an RGBA four-channel image image_rgba, and for the converted image_rgba, setting the alpha channel of the pixel corresponding to the pixel whose mask pixel is 0 in image_rgba to 255; and keeping the pixel whose mask pixel is 255 in image_rgba unchanged; and obtaining the seal transparent image;

[0136] The seal transparent image is obtained by the above method. When the document is restored, the seal transparent image is pasted back into the converted PDF or Docx document to ensure the integrity of the restored document.

[0137] For the original image, the pixels of the stamp area are set to [255, 255, 255], that is, the black stamp area is filled with white, and no text detection and recognition is performed; this avoids the low accuracy of text detection and text recognition in the black stamp area, which affects the document restoration effect; directly using the method of sticking a stamp transparent image can improve the document restoration quality;

[0138] 2) Color stamp:

[0139] Get stamp area: Figure 8 The binary image (mask) of the stamp area shown is subtracted Fig. 9 The binary image mask_word of the text area shown (subtraction: subtraction of pixels at corresponding positions) is obtained Fig.10 The binary image mask_signet of the stamp pixel area shown;

[0140] use Figure 7 The image and mask_word shown in the figure are used to keep the pixels in the image corresponding to the pixels of 255 in the mask_word (retaining the pixel information of the text area is used to restore the text within the seal range to the original image for text detection and text recognition), and the pixels in the image corresponding to the pixels of 0 in the mask_word are set to 255, and the result is Fig.12 The image after deducting the stamp is shown; then it is copied to the corresponding area of ​​the original image;

[0141] Using image and mask_signet, create an RGBA image dst_rgba of the same size as image. For pixels in mask_signet that are 255, assign the RGB values ​​of the pixels corresponding to image to dst_rgba, set the alpha channel to 0 (opaque); set the alpha channel that is not 255 to 255 (transparent), and get Fig.11 The transparent image of the seal is shown; this application example extracts the seal transparent image to avoid the seal image blocking the text in the seal area when the non-transparent image is used to restore the document; in an exemplary instance, the seal transparent image can also ensure consistency with the background when the user changes the document background color.

[0142] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

Claims

1. A document restoration processing method, comprising: Acquire an image to be processed in the original document, wherein the image to be processed is an image of a seal area to be detected, and the image of the seal area to be detected includes a text part and a seal image part; Extracting pixel points in the image to be processed that fall within the range of the color component set according to the color component set to form a first binary image, wherein the first binary image is a binary image of an image corresponding to a text portion in the image to be processed; Extracting a second binary image corresponding to the image to be processed, wherein the second binary image is a binary image including the text portion and the seal image portion; Determining a seal attribute classification according to the number of white pixels in the first binary image and the second binary image, wherein the seal attribute classification is a category to which the seal image portion in the image to be processed belongs, and the category includes a black and white seal image category and a color seal image category; When the judgment result is that the seal attribute is classified as a color seal image, the part of the first binary image is removed from the second binary image to obtain a third binary image, wherein the third binary image is the binary image corresponding to the seal image part in the image to be processed; according to the correspondence between the image to be processed and the first binary image, a new image of the text part is obtained, including: retaining the pixels in the image to be processed at the same position as the pixel 255 in the first binary image, setting the pixels in the same position as the pixel 0 in the first binary image to 255, and obtaining the new An image of a text portion, wherein the correspondence is a one-to-one correspondence between pixels at the same position; obtaining a seal map of a seal image portion according to the correspondence between the image to be processed and the third binary image, comprising: converting the third binary image into a second four-channel image, and for the second four-channel image obtained by the conversion, setting the alpha channel of the pixel points with a pixel value of 0 in the second binary image to 255 to obtain a seal map of a seal image portion of the color seal, wherein the seal map of the seal image portion is an image in which a portion other than the seal image portion is transparent; In the case where the seal attribute classification is a black seal image, obtaining a seal map including the text part and the seal image part of the seal area to be detected according to the second binary image, including: converting the second binary image into a first four-channel image; for the first four-channel image obtained by the conversion, setting the alpha channel of the pixel points with a pixel of 0 in the second binary image to 255 to obtain the seal map including the text part and the seal image part of the seal area to be detected, wherein the seal map is an image in which all parts except the black pixel part are transparent; The seal image and text in the seal area to be detected are restored to a new document.

2. The document restoration processing method according to claim 1, characterized in that: The obtaining of the image to be processed in the original document comprises: Determine the area where the seal is located in the original document; The original document is processed according to the area where the seal is located in the original document to obtain the image to be processed.

3. The document restoration processing method according to claim 1, characterized in that: The color component set includes a color component set range of a pixel point corresponding to the text portion, and the color component set range is at least one, wherein the color component set includes: a hue saturation and lightness HSV color component set.

4. The document restoration processing method according to claim 1, characterized in that: Extracting pixel points in the image to be processed that fall within the range of the color component set according to the color component set to form a first binary image includes: Generate an HSV image corresponding to the image to be processed; Extracting pixel points whose HSV values ​​fall within the range of the color component set in the HSV image, and determining the pixel points of the text part in the image to be processed, wherein the HSV value is the value of the three-channel hue, saturation and brightness of the image; The determined pixel points of the text contained in the image to be processed are used to form the first binary image.

5. The document restoration processing method according to claim 4, characterized in that: The step of determining the pixel points of the text contained in the image to be processed to form the first binary image comprises: Determine the position of the pixel points of the text part in the image to be processed; The pixels at the positions of the pixel points of the text part in the second binary image are set to 255, and the pixels at other positions except the positions of the pixel points of the text part are set to 0, so as to obtain the first binary image.

6. The document restoration processing method according to claim 1, characterized in that: Determining the stamp attribute classification according to the number of white pixels in the first binary image and the second binary image comprises: Calculate the ratio of the number of white pixels in the first binary image to the number of white pixels in the second binary image; In the case where the ratio is greater than a preset threshold, determining that the seal attribute classification of the image to be processed is a black and white seal image category; When the ratio is less than or equal to the preset threshold, it is determined that the seal attribute classification of the image to be processed is a color seal image category.

7. The document restoration processing method according to claim 1, characterized in that: Restoring the seal image and text of the seal area to be detected to a new document includes: According to the position of the image to be processed, the restored image of the new text part in the image to be processed and the obtained seal map of the seal image part are pasted into the new document.

8. The document restoration processing method according to claim 1, characterized in that: Restoring the seal image and text of the seal area to be detected to a new document includes: According to the position of the image to be processed, the restored seal map including the text part and the seal image part of the seal area to be detected is pasted into the new document.

9. The document restoration processing method according to any one of claims 1 to 8, characterized in that: The color component set includes: A color component set of font colors of text written in one or more pre-stored documents; Among them, the one or more documents include one or any combination of the following: a standard PDF file, a PDF scan, a PDF file obtained by taking a photo, and a PDF file converted from an editable document; the font color includes one or more font colors in different formats.

10. A computer storage medium, wherein a computer program is stored in the computer storage medium, and when the computer program is executed by a processor, the document restoration processing method according to any one of claims 1 to 9 is implemented.

11. A terminal, comprising: A memory and a processor, wherein the memory stores a computer program; wherein, The processor is configured to execute the computer program in the memory; When the computer program is executed by the processor, the document restoration processing method according to any one of claims 1 to 9 is implemented.

12. A document restoration processing device, comprising: an acquisition unit, a composition unit, an extraction unit, a judgment unit, a processing unit and a restoration unit; wherein, The acquisition unit is used to: acquire an image to be processed, wherein the image to be processed is an image of a seal area to be detected in an original document, and the image of the seal area to be detected includes a text part and a seal image part; The composition unit is used to: extract pixel points in the image to be processed that fall within the range of the color component set according to the color component set to form a first binary image, wherein the first binary image is a binary image of an image corresponding to a text portion in the image to be processed; The extraction unit is used to: extract a second binary image corresponding to the image to be processed, wherein the second binary image is a binary image including the text part and the seal image part; The judging unit is used to determine the seal attribute classification according to the number of white pixels in the first binary image and the second binary image, wherein the seal attribute classification is the category to which the seal image part in the image to be processed belongs, and the category includes a black and white seal image category and a color seal image category; The processing unit is used for: when the judgment result is that the seal attribute is classified as a color seal image, removing the part of the first binary image from the second binary image to obtain a third binary image, wherein the third binary image is the binary image corresponding to the seal image part in the image to be processed; obtaining an image of a new text part according to the correspondence between the image to be processed and the first binary image, including: retaining the pixels in the image to be processed at the same position as the pixel 255 in the first binary image, setting the pixels in the same position as the pixel 0 in the first binary image to 255, and obtaining the The image of the new text part is obtained, wherein the corresponding relationship is a one-to-one corresponding relationship between pixels at the same position; according to the corresponding relationship between the image to be processed and the third binary image, a seal map of the seal image part is obtained, including: converting the third binary image into a second four-channel image, and for the second four-channel image obtained by the conversion, setting the alpha channel of the pixel points with a pixel of 0 in the second binary image to 255 to obtain the seal map of the seal image part of the color seal, wherein the seal map of the seal image part is an image in which the part other than the seal image part is transparent; The processing unit is also used for: when the judgment result is that the seal attribute classification is a black seal image, obtaining a seal map containing the text part and the seal image part of the seal area to be detected according to the second binary image, including: converting the second binary image into a first four-channel image; for the first four-channel image obtained by the conversion, setting the alpha channel of the pixel points with a pixel of 0 in the second binary image to 255 to obtain the seal map containing the text part and the seal image part of the seal area to be detected, wherein the seal map is an image in which all parts except the black pixel part are transparent; The restoration unit is used to restore the seal image and text in the seal area to be detected to a new document.