A method, apparatus, and storage medium for restoring images from a PDF document.

CN115953796BActive Publication Date: 2026-08-14ZHONGKE FANYU TECH
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-28
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

然而,现有大多数文档还原系统通常会忽略这些图片信息,或者图片提取错误,从而造成内容的缺失

Benefits of technology

[0022] Compared with existing technologies, the beneficial effects of this invention include: the PDFMiner parsing system and the parsing system integrating image detection and OCR technologies respectively extract the coordinate information of the first image and the coordinate information of the second image from the document; the coordinate information of the first image and the coordinate information of the second image are internally compared and then compared with each other to remove images with overlapping coordinates; the coordinate information of the image processed in step S2 is compared with the coordinate information of non-image content in the document to remove images whose coordinate information overlaps with the coordinate information of non-image content; the image is extracted from the document based on the coordinate information of the image processed in step S3 and inserted into the corresponding position in the document; the PDF element information extracted by PDFMiner and the image information detected by the parsing system integrating image detection and OCR technologies are used to extract the image content in the PDF and the images, so that the image content in the rearranged document has a higher degree of restoration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115953796B_ABST
    Figure CN115953796B_ABST
Patent Text Reader

Abstract

This invention discloses a method, apparatus, and storage medium for restoring images from PDF documents, belonging to the field of image restoration technology. The method for restoring images from PDF documents includes the following steps: S1, a PDFMiner parsing system and a parsing system integrating image detection and OCR technologies respectively extract the coordinate information of a first image and a second image from the document; S2, internally compare and mutually compare the coordinate information of the first and second images, removing images with overlapping coordinates; S3, compare the coordinate information of the images processed in step S2 with the coordinate information of non-image content in the document, removing images whose coordinate information overlaps with the coordinate information of non-image content; S4, extract the image from the document based on the coordinate information of the images processed in step S3 and insert it into the corresponding position in the document. This method can effectively extract and restore image content from PDF documents.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image restoration technology, specifically to a method, apparatus, and storage medium for restoring images from a PDF document. Background Technology

[0002] PDF is one of the most widely used document formats, primarily for document exchange and printing, and cannot interact with other computer programs. With the widespread application of PDFs in finance, scientific research, education, and other fields, automatically recognizing PDF documents, extracting useful data, and reconstructing them into easily editable documents has become a significant challenge. PDF documents mainly consist of text, images, tables, formulas, etc. Among these, image recognition and extraction, as a highly efficient data organization and presentation method, is a problem that urgently needs to be solved. Furthermore, for scanned PDFs and image documents, the image content plays a crucial role in document reconstruction. However, most existing document reconstruction systems often ignore this image information or extract images incorrectly, resulting in missing content. Therefore, effectively extracting and reconstructing image content from PDF documents remains a challenge for current technology. Summary of the Invention

[0003] The purpose of this invention is to overcome the above-mentioned technical deficiencies and provide a method, apparatus and storage medium for restoring images in PDF documents, thereby solving the problem of how to effectively extract and restore image content in PDF documents in the prior art.

[0004] To achieve the above-mentioned technical objectives, the present invention provides a method for restoring images from a PDF document, comprising the following steps:

[0005] S 1. The PDFMiner parsing system and the parsing system that integrates image detection and OCR technology extract the coordinate information of the first image and the second image from the document, respectively;

[0006] S2. Compare the coordinate information of the first image and the coordinate information of the second image internally and then compare them with each other to remove images with overlapping coordinates.

[0007] S3. Compare the coordinate information of the image processed in step S2 with the coordinate information of non-image content in the document, and remove images whose coordinate information overlaps with the coordinate information of non-image content.

[0008] S4. Extract the image from the document based on the coordinate information of the image processed in step S3 and insert it into the corresponding position in the document.

[0009] Furthermore, in step S1, the extracted documents include PDF documents and image documents.

[0010] Further, in step S1, the rule for the PDFMiner parsing system to extract the coordinate information of the first image from the document is as follows: the PDFMiner system extracts all elements in the document, including text data, line data, and image data; if the extracted element is detected to be image data, the corresponding data is extracted to obtain the coordinate data of the first image.

[0011] Further, in step S1, the rule for the parsing system that integrates image detection and OCR technology to extract the coordinate information of the second image from the document is as follows: detect the images in the document and then return the coordinate information of the detected images; at the same time, recognize the characters in the document, then return all the characters and their corresponding coordinate information, and then extract the coordinate information of the images to obtain the coordinate information of the second image.

[0012] Furthermore, in step S3, the coordinate information of the non-image content includes the coordinate information of text, the coordinate information of tables, and the coordinate information of formulas.

[0013] Furthermore, before step S4, the images processed in step S3 are arranged horizontally and vertically according to their coordinate information. This ensures that the relative positions of the images in the resulting file are as consistent as possible with the original file.

[0014] Furthermore, in step S4, the inserted document is a WORD document.

[0015] Furthermore, the present invention also proposes a device for restoring images from a PDF document, comprising:

[0016] PDFMiner is a parsing system used to extract the coordinate information of the first image from a document.

[0017] A parsing system that integrates image detection and OCR technologies is used to extract the coordinate information of a second image from a document;

[0018] The first comparison unit is used to internally compare the coordinate information of the first image and the coordinate information of the second image, and to compare them with each other to remove images with overlapping coordinates.

[0019] The second comparison unit is used to compare the coordinate information of the image with the coordinate information of the non-image content in the document, and remove images whose coordinate information overlaps with the coordinate information of the non-image content.

[0020] The insertion unit is used to extract the image based on the coordinate information of the processed image and insert it into the corresponding position in the document.

[0021] Furthermore, the present invention also proposes a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the above-described method for restoring images from PDF documents.

[0022] Compared with existing technologies, the beneficial effects of this invention include: the PDFMiner parsing system and the parsing system integrating image detection and OCR technologies respectively extract the coordinate information of the first image and the coordinate information of the second image from the document; the coordinate information of the first image and the coordinate information of the second image are internally compared and then compared with each other to remove images with overlapping coordinates; the coordinate information of the image processed in step S2 is compared with the coordinate information of non-image content in the document to remove images whose coordinate information overlaps with the coordinate information of non-image content; the image is extracted from the document based on the coordinate information of the image processed in step S3 and inserted into the corresponding position in the document; the PDF element information extracted by PDFMiner and the image information detected by the parsing system integrating image detection and OCR technologies are used to extract the image content in the PDF and the images, so that the image content in the rearranged document has a higher degree of restoration. Attached Figure Description

[0023] Figure 1 This is a flowchart of a method for restoring images from a PDF document according to this specific embodiment of the invention;

[0024] Figure 2 This is a structural block diagram of a PDF document image restoration device proposed in a specific embodiment of the present invention. Detailed Implementation

[0025] Combination Figure 1 This specific embodiment provides a method for restoring images from a PDF document, including the following steps:

[0026] S1. The PDFMiner parsing system and the parsing system that integrates image detection and OCR technology respectively extract the coordinate information of the first image and the second image from the document; the extracted document includes PDF documents and image documents; in step S1, the PDFMiner system also determines whether the file is a parsable PDF document; for parsable PDF documents, the PDFMiner system parses the content in the document to extract all PDF documents; for documents that are not parsable PDFs, the PDFMiner system does not process them; the PDFMiner system parses the PDF file to extract all the content in the file; if text or line information can be parsed from the corresponding page, then the document is a parsable PDF document;

[0027] The rule for the PDFMiner parsing system to extract the coordinate information of the first image from the document is as follows: the PDFMiner system extracts all elements in the document, including text data, line data, and image data; if the extracted element is detected to be image data, the corresponding data is extracted to obtain the coordinate data of the first image.

[0028] The rule for the parsing system that integrates image detection and OCR technology to extract the coordinate information of the second image from the document is as follows: detect the images in the document and then return the coordinate information of the detected images; at the same time, recognize the characters in the document and then return all the characters and their corresponding coordinate information, and then extract the coordinate information of the images to obtain the coordinate information of the second image.

[0029] S2. Compare the coordinate information of the first image and the coordinate information of the second image internally and then compare them with each other to remove images with overlapping coordinates.

[0030] S3. Compare the coordinate information of the image processed in step S2 with the coordinate information of the non-image content in the document, and remove images whose coordinate information overlaps with the coordinate information of the non-image content; the coordinate information of the non-image content includes the coordinate information of text, tables and formulas; arrange the processed images horizontally and vertically according to the coordinate information of the images.

[0031] S4. Extract the image from the document based on the coordinate information of the image processed in step S3 and insert it into the corresponding position in the document.

[0032] It should be noted that a parsable PDF refers to a PDF file from which text content can be directly copied and pasted. These files can be parsed using Python or Java libraries to extract text, tables, and images. A scanned PDF, on the other hand, is an image-based PDF file where the entire content is presented as an image. OCR is required to recognize the content within the PDF in order to extract the information.

[0033] Combination Figure 2 This specific embodiment also proposes a device for restoring images from a PDF document, comprising:

[0034] PDFMiner is a parsing system used to extract the coordinate information of the first image from a document.

[0035] A parsing system that integrates image detection and OCR technologies is used to extract the coordinate information of a second image from a document;

[0036] The first comparison unit is used to internally compare the coordinate information of the first image and the coordinate information of the second image, and to compare them with each other to remove images with overlapping coordinates.

[0037] The second comparison unit is used to compare the coordinate information of the image with the coordinate information of the non-image content in the document, and remove images whose coordinate information overlaps with the coordinate information of the non-image content.

[0038] The insertion unit is used to extract the image based on the coordinate information of the processed image and insert it into the corresponding position in the document.

[0039] This specific embodiment also proposes a storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described method for restoring images from PDF documents.

[0040] This invention identifies image content in a document based on elements extracted by the PDFMiner system and image information detected by a parsing system that integrates image detection and OCR technology. Then, it extracts the image content from the document and inserts it into the target document, thereby making the reconstructed content more consistent with the original document.

[0041] To make the objectives, technical solutions, and advantages of this invention clearer, the method of this invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0042] Example 1

[0043] This embodiment proposes a method for restoring images from a PDF document, including the following steps:

[0044] S1. The PDFMiner parsing system and the parsing system that integrates image detection and OCR technology respectively extract the coordinate information of the first image and the second image from the document; the extracted document includes PDF documents and image documents; the PDF document includes parsable PDF documents and PDF scans; the PDFMiner system determines whether the file is a parsable PDF document; for parsable PDF documents, the PDFMiner system parses the content in the document to extract all PDF documents; for documents that are not parsable PDF documents, the PDFMiner system does not process them;

[0045] It should be noted that the PDFMiner parsing system is a PDF file parsing system based on the PDFMiner library;

[0046] The rule for the PDFMiner parsing system to extract the coordinate information of the first image from the document is as follows: the PDFMiner system extracts all elements in the document, including text data, line data, and image data; if the extracted element is detected to be image data, the corresponding data is extracted to obtain the coordinate data of the first image.

[0047] The rule for the parsing system that integrates image detection and OCR technology to extract the coordinate information of the second image from the document is as follows: detect the images in the document and then return the coordinate information of the detected images; at the same time, recognize the characters in the document and then return all the characters and their corresponding coordinate information, and then extract the coordinate information of the images to obtain the coordinate information of the second image.

[0048] S2. After obtaining the coordinate information of the first and second images in the document using step S1, we perform a fusion and deduplication operation on all the image content in this step. This operation directly compares whether the coordinates of all detected images are basically overlapping. If the coordinates of the images are basically overlapping, then the two images are considered duplicate images, and one of them is deleted. Specifically, the coordinate information of the first image and the coordinate information of the second image are internally compared and then compared with each other to remove images with overlapping coordinates.

[0049] S3. To ensure the accuracy of the image content, we will further filter the images in this step. We will compare the coordinate information of the detected images with the coordinate information of non-image content (such as text, tables, formulas, etc.) in the document to check for overlap. If the coordinates overlap, the image content is considered incorrect, and the image is deleted. Specifically, the coordinate information of the images processed in step S2 is compared with the coordinate information of non-image content in the document, and images whose coordinate information overlaps with that of non-image content are removed. The coordinate information of non-image content includes the coordinate information of text, tables, and formulas. The processed images are then arranged horizontally and vertically according to their coordinate information.

[0050] S4. Use the Image library to extract the image content from the input document. During extraction, we extract the corresponding image from the original file according to the image coordinate information obtained during image parsing, thereby extracting all the image content in the document. Based on the image coordinate information processed in step S3, extract the image from the document and insert it into the corresponding position in the document.

[0051] It should be noted that the image detection and OCR technology integration parsing system is a system that integrates image detection technology and OCR recognition technology. For the input document, the system can use the image detection module to detect the image content in the document, thereby returning the coordinate position information of all images; at the same time, the system will also use OCR recognition technology to detect and recognize all text and lines in the document, thereby returning all text, lines and their corresponding coordinate information.

[0052] This invention provides a method for extracting and reconstructing image content in a document. It can automatically detect and extract image content in a document, and then insert the image into the corresponding position in the DOCX file based on the image's coordinate information, so that the layout of the image content in the target document is as consistent as possible with the original document.

[0053] The specific embodiments of the present invention described above do not constitute a limitation on the scope of protection of the present invention. Any other corresponding changes and modifications made in accordance with the technical concept of the present invention should be included within the scope of protection of the claims of the present invention.

Claims

1. A method for restoring images from a PDF document, characterized in that, Includes the following steps: S 1, PDFMiner parsing system and parsing system integrating image detection and OCR technology respectively extract the coordinate information of the first image and the coordinate information of the second image from the document; S2. Compare the coordinate information of the first image and the coordinate information of the second image internally and then compare them with each other to remove images with overlapping coordinates. S3. Compare the coordinate information of the image processed in step S2 with the coordinate information of non-image content in the document, and remove images whose coordinate information overlaps with the coordinate information of non-image content. S4. Extract the image from the document based on the coordinate information of the image processed in step S3 and insert it into the corresponding position in the document; In step S1, the PDFMiner parsing system extracts the coordinate information of the first image from the document according to the following rules: the PDFMiner system extracts all elements in the document, including text data, line data, and image data; if the extracted element is detected to be image data, the corresponding data is extracted to obtain the coordinate data of the first image. In step S1, the rule for the parsing system that integrates image detection and OCR technology to extract the coordinate information of the second image from the document is as follows: detect the images in the document and then return the coordinate information of the detected images; at the same time, recognize the characters in the document and then return all the characters and their corresponding coordinate information, and then extract the coordinate information of the images to obtain the coordinate information of the second image.

2. The method for restoring images from a PDF document according to claim 1, characterized in that, In step S1, the extracted documents include PDF documents and image documents.

3. The method for restoring images from a PDF document according to claim 1, characterized in that, In step S3, the coordinate information of the non-image content includes the coordinate information of the text. The coordinate information of the table and the coordinate information of the formula.

4. The method for restoring images from a PDF document according to claim 1, characterized in that, Before step S4, the image processed in step S3 is arranged horizontally and vertically according to the image's coordinate information.

5. The method for restoring images from a PDF document according to claim 1, characterized in that, In step S4, the inserted document is a WORD document.

6. A device for restoring images from a PDF document, characterized in that, include: PDFMiner is a parsing system used to extract the coordinate information of the first image from a document. A parsing system that integrates image detection and OCR technologies is used to extract the coordinate information of a second image from a document; The first comparison unit is used to internally compare the coordinate information of the first image and the coordinate information of the second image, and to compare them with each other to remove images with overlapping coordinates. The second comparison unit is used to compare the coordinate information of the image with the coordinate information of the non-image content in the document, and remove images whose coordinate information overlaps with the coordinate information of the non-image content. The insertion unit is used to extract the image based on the coordinate information of the processed image and insert it into the corresponding position in the document.

7. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the PDF document image restoration method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • PDF (Portable Document Format) file information analysis method and device

    CN113033164A