WO2019041526A1 - 文档图表抽取方法、电子设备及计算机可读存储介质 - Google Patents

文档图表抽取方法、电子设备及计算机可读存储介质 Download PDF

Info

Publication number
WO2019041526A1
WO2019041526A1 PCT/CN2017/108809 CN2017108809W WO2019041526A1 WO 2019041526 A1 WO2019041526 A1 WO 2019041526A1 CN 2017108809 W CN2017108809 W CN 2017108809W WO 2019041526 A1 WO2019041526 A1 WO 2019041526A1
Authority
WO
WIPO (PCT)
Prior art keywords
chart
area
text
document
distribution
Prior art date
Application number
PCT/CN2017/108809
Other languages
English (en)
French (fr)
Inventor
王鸿滨
王晓伟
汪伟
苏晓明
肖京
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2019041526A1 publication Critical patent/WO2019041526A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/40Document-oriented image-based pattern recognition
    • G06V30/41Analysis of document content
    • G06V30/413Classification of content, e.g. text, photographs or tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/40Document-oriented image-based pattern recognition
    • G06V30/41Analysis of document content
    • G06V30/414Extracting the geometrical structure, e.g. layout tree; Block segmentation, e.g. bounding boxes for graphics or text

Definitions

  • the present application relates to the field of computer information technology, and in particular, to a document chart extraction method, an electronic device, and a computer readable storage medium.
  • the existing PDF chart extraction tools and programs are mostly based on PDF storage objects. This method can only extract charts stored as separate image objects, and contains more chart information (such as Office charts, etc.) in a PDF document. These charts can visually express some of the information in the document.
  • existing PDF chart extraction tools and programs cannot be correctly extracted for charts composed of multiple parts such as Office charts. Therefore, the design of the document chart extraction method in the prior art is not reasonable enough and needs to be improved.
  • the present application proposes a document chart extraction method, an electronic device, and a computer readable storage medium, which extracts a chart from a PDF document by text density analysis, thereby improving the efficiency and coverage of the chart extraction.
  • the present application provides an electronic device including a memory, a processor, and a document chart extraction system stored on the memory and operable on the processor, the document chart
  • the following steps are implemented when the extraction system is executed by the processor:
  • Analyzing the text distribution information in the specified document determining an area in the specified document with a low distribution density of characters, and/or an area having no text distribution, and the area having a low text distribution density, or/and no text
  • the area of the distribution is marked as a candidate chart area
  • the determining that the area of the specified document has a low density of text distribution comprises: if the length of the line of characters is less than the first threshold, determining that the line of text has a lower density of distribution and cleaning the line of text.
  • the determining that the area of the specified document has no text distribution comprises: scanning each page of the specified document from top to bottom, and if the area exceeding the second threshold width does not scan the text, determining This area is an area with no text distribution.
  • the filtering out the picture containing the chart information from the converted picture comprises: passing Pixel distribution analysis, filter the converted image, and select the image containing the chart information.
  • the filtering the image containing the chart information from the converted image comprises:
  • the number of rows containing the specific content is counted. If the number of rows containing the specific content is greater than or equal to the set threshold, it is determined that the converted image is a picture containing the chart information.
  • the present application further provides a document chart extraction method, which is applied to an electronic device, and the method includes:
  • Analyzing the text distribution information in the specified document determining an area in the specified document with a low distribution density of characters, and/or an area having no text distribution, and the area having a low text distribution density, or/and no text
  • the area of the distribution is marked as a candidate chart area
  • the determining that the area of the specified document has a low density of text distribution comprises: if the length of the line of characters is less than the first threshold, determining that the line of text has a lower density of distribution and cleaning the line of text;
  • the determining that the area of the specified document has no text distribution includes: scanning each page of the specified document from top to bottom, and if the area exceeding the second threshold width does not scan the text, determining that the area is An area without text distribution.
  • the filtering the image including the chart information from the converted image comprises: filtering the converted image by pixel distribution analysis, and selecting a picture including the chart information.
  • the filtering the image containing the chart information from the converted image comprises:
  • the number of rows containing the specific content is counted. If the number of rows containing the specific content is greater than or equal to the set threshold, it is determined that the converted image is a picture containing the chart information.
  • the present application further provides a computer readable storage medium storing a document chart extraction system, the document chart extraction system being executable by at least one processor, such that The at least one processor performs the steps of the document chart extraction method as described above.
  • the electronic device, document chart extraction method and calculation proposed by the present application A machine-readable storage medium that extracts a chart from a PDF document by text density analysis.
  • the method can extract a chart composed of multiple parts such as Office chart information that cannot be extracted by a conventional method. , improve the efficiency and coverage of chart extraction.
  • 1 is a schematic diagram of an optional hardware architecture of an electronic device of the present application
  • FIG. 2 is a schematic diagram of a program module of an embodiment of a document chart extraction system in an electronic device of the present application
  • FIG. 3 is a schematic diagram of an implementation process of an embodiment of a method for extracting a document in the present application.
  • first, second and the like in the present application are for the purpose of description only, and are not to be construed as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. .
  • features defining “first” and “second” may include at least one of the features, either explicitly or implicitly.
  • the technical solutions between the various embodiments may be combined with each other, but must be based on the realization of those skilled in the art, when the combination of technical solutions occurs mutual spears When the shield is not implemented, it should be considered that the combination of such technical solutions does not exist and is not within the scope of protection claimed in this application.
  • FIG. 1 it is a schematic diagram of an optional hardware architecture of the electronic device 2 of the present application.
  • the electronic device 2 may include, but is not limited to, a memory 21, a processor 22, and a network interface 23 that can communicate with each other through a system bus. It is pointed out that FIG. 1 only shows the electronic device 2 with the components 21-23, but it should be understood that not all illustrated components are required to be implemented, and more or fewer components may be implemented instead.
  • the electronic device 2 may be a computing device such as a rack server, a blade server, a tower server, or a rack server.
  • the electronic device 2 may be an independent server or a server cluster composed of multiple servers. .
  • the memory 21 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (eg, SD or DX memory, etc.), a random access memory (RAM), a static Random access memory (SRAM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), programmable read only memory (PROM), magnetic memory, magnetic disk, optical disk, and the like.
  • the memory 21 may be an internal storage unit of the electronic device 2, such as a hard disk or memory of the electronic device 2.
  • the memory 21 may also be an external storage device of the electronic device 2, such as a plug-in hard disk equipped on the electronic device 2, a smart memory card (SMC), and a secure digital device. (Secure Digital, SD) card, flash card, etc.
  • the memory 21 may also include both an internal storage unit of the electronic device 2 and an external storage device thereof.
  • the memory 21 is generally used to store an operating system installed in the electronic device 2 and various types of application software, such as program codes of the document chart extraction system 20, and the like. Further, the memory 21 can also be used to temporarily store various types of data that have been output or are to be output.
  • the processor 22 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments.
  • the processor 22 is typically used to control the overall operation of the electronic device 2, such as performing control and processing related to data interaction or communication with the electronic device 2.
  • the processor 22 is configured to run program code or process data stored in the memory 21, such as running the document chart extraction system 20 and the like.
  • the network interface 23 may include a wireless network interface or a wired network interface, the network interface 23 Typically used to establish a communication connection between the electronic device 2 and other electronic devices.
  • the network interface 23 is configured to connect the electronic device 2 to an external data platform through a network, and establish a data transmission channel and a communication connection between the electronic device 2 and an external data platform.
  • the network may be an intranet, an Internet, a Global System of Mobile communication (GSM), a Wideband Code Division Multiple Access (WCDMA), a 4G network, or a 5G network.
  • Wireless or wired networks such as network, Bluetooth, Wi-Fi, etc.
  • FIG. 2 it is a program module diagram of an embodiment of the document chart extraction system 20 in the electronic device 2 of the present application.
  • the document chart extraction system 20 may be divided into one or more program modules, the one or more program modules being stored in the memory 21 and being processed by one or more processors ( This embodiment is executed by the processor 22) to complete the application.
  • the document chart extraction system 20 can be segmented into an acquisition module 201, an analysis module 202, and an extraction module 203.
  • a program module as referred to in the present application refers to a series of computer program instruction segments capable of performing a specific function, and is more suitable than the program for describing the execution process of the document chart extraction system 20 in the electronic device 2. The function of each program module 201-203 will be described in detail below.
  • the obtaining module 201 is configured to acquire location information of all characters in a specified document (such as a PDF document), and obtain text distribution information in the specified document according to location information of all the characters.
  • a specified document such as a PDF document
  • the position information of the character includes, but is not limited to, a horizontal coordinate, a vertical coordinate, a longitudinal distance from the previous line of characters, and a longitudinal distance from the next line of characters.
  • the text distribution information includes, but is not limited to, coordinates of the upper left corner of each line of text, length and width of the line of characters, and the like.
  • the analyzing module 202 is configured to analyze the text distribution information in the specified document, determine an area in the specified document with a low text distribution density, or/and a non-text distribution area, and lower the text distribution density. The area, or/and the area without the text distribution, are marked as candidate chart areas.
  • the determining that the area of the specified document has a low density of characters includes: if the length of the line of characters is less than the first threshold (eg, 5 characters per unit length), determining the line The text is distributed at a lower density and cleans (deletes) the line of text. The line of text after cleaning becomes an area with no text distribution.
  • the first threshold eg, 5 characters per unit length
  • the determining that the area of the specified document has no text distribution comprises: scanning each page of the specified document from top to bottom, if the second threshold width is exceeded (eg, 2 If the area of the character unit width is not scanned, the area is judged to be an area where no text is distributed.
  • the second threshold width eg, 2 If the area of the character unit width is not scanned, the area is judged to be an area where no text is distributed.
  • the extracting module 203 is configured to convert the marked candidate chart area into a picture, and filter the picture containing the chart information from the converted picture as the extracted figure in the specified document.
  • the marked candidate chart area can be converted to a picture using a specific image processing tool such as the ImageMagick tool.
  • the filtering the picture including the chart information from the converted picture comprises: filtering the converted picture by using pixel distribution analysis (or content richness analysis), and selecting the included chart A picture of information (such as PDF chart information). Since there are two cases in the non-text area: one is a chart, and the other is a blank area of the page. By analyzing the pixel distribution of the picture, it can be determined which of the two cases.
  • pixel distribution analysis or content richness analysis
  • the image including the chart information is filtered from the converted image by pixel distribution analysis, including:
  • each pixel of the picture is represented as 0 or 255. Where 0 is black, which is a pixel with information content in the picture, and 255 is white, which is a blank pixel in the picture.
  • the number of rows containing specific content is counted to determine the richness of the content in the image. The more rows containing the specific content, the richer the content representing the image. If the number of lines containing the specific content is greater than or equal to the set threshold (such as 2 lines), it is determined that the converted picture is rich in content, and is a picture containing the chart information. On the other hand, if the number of rows containing the specific content is less than the set threshold (such as 2 rows), it is determined that the converted image content is not rich enough, and is a blank image that does not contain the chart information.
  • the set threshold such as 2 lines
  • the document chart extraction system 20 proposed by the present application extracts a chart from a PDF document by text density analysis.
  • the method can also extract the traditional method.
  • the present application also proposes a document chart extraction method.
  • FIG. 3 it is a schematic flowchart of an implementation process of an embodiment of a method for extracting a chart of the present application.
  • the order of execution of the steps in the flowchart shown in FIG. 3 may be changed according to different requirements, and some steps may be omitted.
  • Step S31 Acquire location information of all the characters in the specified document (such as a PDF document), and obtain the text distribution information in the specified document according to the location information of all the characters.
  • the location information of the text includes, but is not limited to, text Horizontal coordinate, longitudinal coordinate, vertical distance from the previous line of text, and vertical distance from the next line of text.
  • the text distribution information includes, but is not limited to, coordinates of the upper left corner of each line of text, length and width of the line of characters, and the like.
  • Step S32 analyzing the text distribution information in the specified document, determining an area in the specified document with a low distribution density of characters, and/or an area having no text distribution, and the area where the character distribution density is low, or The area with no text distribution is marked as a candidate chart area.
  • the determining that the area of the specified document has a low density of characters includes: if the length of the line of characters is less than the first threshold (eg, 5 characters per unit length), determining the line The text is distributed at a lower density and cleans (deletes) the line of text. The line of text after cleaning becomes an area with no text distribution.
  • the first threshold eg, 5 characters per unit length
  • the determining that the area of the specified document has no text distribution comprises: scanning each page of the specified document from top to bottom, if the second threshold width is exceeded (eg, 2 If the area of the character unit width is not scanned, the area is judged to be an area where no text is distributed.
  • the second threshold width eg, 2 If the area of the character unit width is not scanned, the area is judged to be an area where no text is distributed.
  • Step S33 converting the marked candidate chart area into a picture, and filtering out the picture containing the chart information from the converted picture as the chart extracted from the specified document.
  • the marked candidate chart area can be converted to a picture using a specific image processing tool such as the ImageMagick tool.
  • the filtering the picture including the chart information from the converted picture comprises: filtering the converted picture by using pixel distribution analysis (or content richness analysis), and selecting the included chart A picture of information (such as PDF chart information). Since there are two cases in the non-text area: one is a chart, and the other is a blank area of the page. By analyzing the pixel distribution of the picture, it can be determined which of the two cases.
  • pixel distribution analysis or content richness analysis
  • the image including the chart information is filtered from the converted image by pixel distribution analysis, including:
  • each pixel of the picture is represented as 0 or 255. Where 0 is black, which is a pixel with information content in the picture, and 255 is white, which is a blank pixel in the picture.
  • the number of rows containing specific content is counted to determine the richness of the content in the image. The more rows containing the specific content, the richer the content representing the image. If the number of rows containing the specific content is greater than or equal to a set threshold (such as 2 rows), it is determined that the converted image is rich in content. Is a picture with chart information. On the other hand, if the number of rows containing the specific content is less than the set threshold (such as 2 rows), it is determined that the converted image content is not rich enough, and is a blank image that does not contain the chart information.
  • a set threshold such as 2 rows
  • the document chart extraction method proposed by the present application extracts a chart from a PDF document by text density analysis, and the method can extract the chart which can be extracted by the traditional method, and can extract the traditional method cannot extract.
  • the present application further provides a computer readable storage medium (such as a ROM/RAM, a magnetic disk, an optical disk), where the computer readable storage medium stores a document chart extraction system 20, the document chart
  • the extraction system 20 can be executed by at least one processor 22 to cause the at least one processor 22 to perform the steps of the document chart extraction method as described above.
  • the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and can also be implemented by hardware, but in many cases, the former is A better implementation.
  • the technical solution of the present application which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk,
  • the optical disc includes a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods described in various embodiments of the present application.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Graphics (AREA)
  • Geometry (AREA)
  • Character Input (AREA)

Abstract

一种文档图表抽取方法,该方法包括步骤:获取指定文档中所有文字的位置信息,并根据所有文字的位置信息获取该指定文档中的文字分布信息(S31);分析该指定文档中的文字分布信息,判断出该指定文档中文字分布密度较低的区域、或/及无文字分布的区域,并将所述文字分布密度较低的区域、或/及无文字分布的区域标记为候选图表区域(S32);将所述标记的候选图表区域转换为图片,并从转换后的图片中筛选出包含图表信息的图片,作为该指定文档中抽取出的图表(S33)。本方法可以提升图表抽取的效率和覆盖面。

Description

文档图表抽取方法、电子设备及计算机可读存储介质
本专利申请以2017年8月31日提交的申请号为201710776352.X,名称为“文档图表抽取方法、电子设备及计算机可读存储介质”的中国发明专利申请为基础,并要求其优先权。
技术领域
本申请涉及计算机信息技术领域,尤其涉及一种文档图表抽取方法、电子设备及计算机可读存储介质。
背景技术
现有的PDF图表抽取工具及程序大多是基于PDF存储对象的,这种方式仅能抽取作为单独图片对象存储的图表,而在一个PDF文档中,含有较多的图表信息(如Office图表等),这些图表都能直观地表达出文档中的部分信息。然而,现有的PDF图表抽取工具及程序对于Office图表等由多个部分组成的图表则无法正确抽取。故,现有技术中的文档图表抽取方法设计不够合理,亟需改进。
发明内容
有鉴于此,本申请提出一种文档图表抽取方法、电子设备及计算机可读存储介质,通过文本密度分析从PDF文档中抽取图表,提升了图表抽取的效率和覆盖面。
首先,为实现上述目的,本申请提出一种电子设备,所述电子设备包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的文档图表抽取***,所述文档图表抽取***被所述处理器执行时实现如下步骤:
获取指定文档中所有文字的位置信息,并根据所有文字的位置信息获取该指定文档中的文字分布信息;
分析该指定文档中的文字分布信息,判断出该指定文档中文字分布密度较低的区域、或/及无文字分布的区域,并将所述文字分布密度较低的区域、或/及无文字分布的区域标记为候选图表区域;及
将所述标记的候选图表区域转换为图片,并从转换后的图片中筛选出包含图表信息的图片,作为该指定文档中抽取出的图表。
优选地,所述判断出该指定文档中文字分布密度较低的区域包括:若一行文字的长度小于第一阀值,则判断出该行文字分布密度较低,并清洗该行文字。
优选地,所述判断出该指定文档中无文字分布的区域包括:对该指定文档中每一页从上到下进行扫描,若超过第二阀值宽度的区域没有扫描到文字,则判断出该区域为无文字分布的区域。
优选地,所述从转换后的图片中筛选出包含图表信息的图片包括:通过 像素分布分析,对转换后的图片进行筛选,选择出包含图表信息的图片。
优选地,所述从转换后的图片中筛选出包含图表信息的图片包括:
对该转换后的图片进行灰度处理,将该转换后的图片转换为灰度图;
按行统计该灰度图中黑色像素点的数量和比例,若一行中黑色像素点的数量和比例超过指定阈值,则判定该行包含有具体内容;及
统计包含有具体内容的行的数量,若包含有具体内容的行数大于或等于设定阈值,则判定该转换后的图片为一张包含图表信息的图片。
此外,为实现上述目的,本申请还提供一种文档图表抽取方法,该方法应用于电子设备,所述方法包括:
获取指定文档中所有文字的位置信息,并根据所有文字的位置信息获取该指定文档中的文字分布信息;
分析该指定文档中的文字分布信息,判断出该指定文档中文字分布密度较低的区域、或/及无文字分布的区域,并将所述文字分布密度较低的区域、或/及无文字分布的区域标记为候选图表区域;及
将所述标记的候选图表区域转换为图片,并从转换后的图片中筛选出包含图表信息的图片,作为该指定文档中抽取出的图表。
优选地,所述判断出该指定文档中文字分布密度较低的区域包括:若一行文字的长度小于第一阀值,则判断出该行文字分布密度较低,并清洗该行文字;及
所述判断出该指定文档中无文字分布的区域包括:对该指定文档中每一页从上到下进行扫描,若超过第二阀值宽度的区域没有扫描到文字,则判断出该区域为无文字分布的区域。
优选地,所述从转换后的图片中筛选出包含图表信息的图片包括:通过像素分布分析,对转换后的图片进行筛选,选择出包含图表信息的图片。
优选地,所述从转换后的图片中筛选出包含图表信息的图片包括:
对该转换后的图片进行灰度处理,将该转换后的图片转换为灰度图;
按行统计该灰度图中黑色像素点的数量和比例,若一行中黑色像素点的数量和比例超过指定阈值,则判定该行包含有具体内容;及
统计包含有具体内容的行的数量,若包含有具体内容的行数大于或等于设定阈值,则判定该转换后的图片为一张包含图表信息的图片。
进一步地,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质存储有文档图表抽取***,所述文档图表抽取***可被至少一个处理器执行,以使所述至少一个处理器执行如上述的文档图表抽取方法的步骤。
相较于现有技术,本申请所提出的电子设备、文档图表抽取方法及计算 机可读存储介质,通过文本密度分析从PDF文档中抽取图表,该方法除了能提取传统方法能抽取的图表外,还能提取出传统方法无法提取的Office图表信息等由多个部分组成的图表,提升了图表抽取的效率和覆盖面。
附图说明
图1是本申请电子设备一可选的硬件架构的示意图;
图2是本申请电子设备中文档图表抽取***一实施例的程序模块示意图;
图3为本申请文档图表抽取方法一实施例的实施流程示意图。
附图标记:
电子设备 2
存储器 21
处理器 22
网络接口 23
文档图表抽取*** 20
获取模块 201
分析模块 202
抽取模块 203
流程步骤 S31-S33
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
需要说明的是,在本申请中涉及“第一”、“第二”等的描述仅用于描述目的,而不能理解为指示或暗示其相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。另外,各个实施例之间的技术方案可以相互结合,但是必须是以本领域普通技术人员能够实现为基础,当技术方案的结合出现相互矛 盾或无法实现时应当认为这种技术方案的结合不存在,也不在本申请要求的保护范围之内。
进一步需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。
首先,本申请提出一种电子设备2。
参阅图1所示,是本申请电子设备2一可选的硬件架构的示意图。本实施例中,所述电子设备2可包括,但不限于,可通过***总线相互通信连接存储器21、处理器22、网络接口23。需要指出的是,图1仅示出了具有组件21-23的电子设备2,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。
其中,所述电子设备2可以是机架式服务器、刀片式服务器、塔式服务器或机柜式服务器等计算设备,该电子设备2可以是独立的服务器,也可以是多个服务器所组成的服务器集群。
所述存储器21至少包括一种类型的可读存储介质,所述可读存储介质包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘等。在一些实施例中,所述存储器21可以是所述电子设备2的内部存储单元,例如该电子设备2的硬盘或内存。在另一些实施例中,所述存储器21也可以是所述电子设备2的外部存储设备,例如该电子设备2上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。当然,所述存储器21还可以既包括所述电子设备2的内部存储单元也包括其外部存储设备。本实施例中,所述存储器21通常用于存储安装于所述电子设备2的操作***和各类应用软件,例如所述文档图表抽取***20的程序代码等。此外,所述存储器21还可以用于暂时地存储已经输出或者将要输出的各类数据。
所述处理器22在一些实施例中可以是中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器、或其他数据处理芯片。该处理器22通常用于控制所述电子设备2的总体操作,例如执行与所述电子设备2进行数据交互或者通信相关的控制和处理等。本实施例中,所述处理器22用于运行所述存储器21中存储的程序代码或者处理数据,例如运行所述的文档图表抽取***20等。
所述网络接口23可包括无线网络接口或有线网络接口,该网络接口23 通常用于在所述电子设备2与其他电子设备之间建立通信连接。例如,所述网络接口23用于通过网络将所述电子设备2与外部数据平台相连,在所述电子设备2与外部数据平台之间的建立数据传输通道和通信连接。所述网络可以是企业内部网(Intranet)、互联网(Internet)、全球移动通讯***(Global System of Mobile communication,GSM)、宽带码分多址(Wideband Code Division Multiple Access,WCDMA)、4G网络、5G网络、蓝牙(Bluetooth)、Wi-Fi等无线或有线网络。
至此,己经详细介绍了本申请各个实施例的应用环境和相关设备的硬件结构和功能。下面,将基于上述应用环境和相关设备,提出本申请的各个实施例。
参阅图2所示,是本申请电子设备2中文档图表抽取***20一实施例的程序模块图。本实施例中,所述的文档图表抽取***20可以被分割成一个或多个程序模块,所述一个或者多个程序模块被存储于所述存储器21中,并由一个或多个处理器(本实施例中为所述处理器22)所执行,以完成本申请。例如,在图2中,所述的文档图表抽取***20可以被分割成获取模块201、分析模块202、以及抽取模块203。本申请所称的程序模块是指能够完成特定功能的一系列计算机程序指令段,比程序更适合于描述所述文档图表抽取***20在所述电子设备2中的执行过程。以下将就各程序模块201-203的功能进行详细描述。
所述获取模块201,用于获取指定文档(如PDF文档)中所有文字的位置信息,并根据所有文字的位置信息获取该指定文档中的文字分布信息。
优选地,在本实施例中,所述文字的位置信息包括,但不限于,文字的横向坐标、纵向坐标、与上一行文字的纵向距离、及与下一行文字的纵向距离等。所述文字分布信息包括,但不限于,每一行文字的左上角坐标,该行文字的长度和宽度等。
所述分析模块202,用于分析该指定文档中的文字分布信息,判断出该指定文档中文字分布密度较低的区域、或/及无文字分布的区域,并将所述文字分布密度较低的区域、或/及无文字分布的区域标记为候选图表区域。
优选地,在本实施例中,所述判断出该指定文档中文字分布密度较低的区域包括:若一行文字的长度小于第一阀值(如5个字符单位长度),则判断出该行文字分布密度较低,并清洗(删除)该行文字。清洗后的该行文字变成了一个无文字分布的区域。
优选地,在本实施例中,所述判断出该指定文档中无文字分布的区域包括:对该指定文档中每一页从上到下进行扫描,若超过第二阀值宽度(如2个字符单位宽度)的区域没有扫描到文字,则判断出该区域为无文字分布的区域。
所述抽取模块203,用于将所述标记的候选图表区域转换为图片,并从转换后的图片中筛选出包含图表信息的图片,作为该指定文档中抽取出的图表。在本实施例中,可以使用特定的图片处理工具(如ImageMagick工具)将所述标记的候选图表区域转换为图片。
优选地,在本实施例中,所述从转换后的图片中筛选出包含图表信息的图片包括:通过像素分布分析(或内容丰富程度分析),对转换后的图片进行筛选,选择出包含图表信息(如PDF图表信息)的图片。由于无文字区域有两种情况:一种是图表,一种是页面的空白区域,通过对图片的像素分布分析,可以判断出是这两种情况中的哪一种。
具体而言,通过像素分布分析从转换后的图片中筛选出包含图表信息的图片包括:
(1)对该转换后的图片进行灰度处理(如通过应用程序Python中的Opencv模块进行灰度处理),将该转换后的图片转换为灰度图。在该灰度图中,图片的每个像素点都被表示为0或255。其中,0代表黑色,为图片中有信息内容的像素点,255代表白色,为图片中空白的像素点。
(2)按行统计该灰度图中黑色像素点的数量和比例,若一行中黑色像素点的数量和比例超过指定阈值(如数量超过5,比例超过50%),则判定该行包含有具体内容。
(3)统计包含有具体内容的行的数量,以此来判定图片中内容的丰富程度,包含有具体内容的行越多,则代表该图片的内容越丰富。若包含有具体内容的行数大于或等于设定阈值(如2行),则判定该转换后的图片内容丰富,是一张包含图表信息的图片。反之,若包含有具体内容的行数小于该设定阈值(如2行),则判定该转换后的图片内容不够丰富,是一张没有包含图表信息的空白图片。
通过上述程序模块201-203,本申请所提出的文档图表抽取***20,通过文本密度分析从PDF文档中抽取图表,该方法除了能提取传统方法能抽取的图表外,还能提取出传统方法无法提取的Office图表信息等由多个部分组成的图表,提升了图表抽取的效率和覆盖面。
此外,本申请还提出一种文档图表抽取方法。
参阅图3所示,是本申请文档图表抽取方法一实施例的实施流程示意图。在本实施例中,根据不同的需求,图3所示的流程图中的步骤的执行顺序可以改变,某些步骤可以省略。
步骤S31,获取指定文档(如PDF文档)中所有文字的位置信息,并根据所有文字的位置信息获取该指定文档中的文字分布信息。
优选地,在本实施例中,所述文字的位置信息包括,但不限于,文字的 横向坐标、纵向坐标、与上一行文字的纵向距离、及与下一行文字的纵向距离等。所述文字分布信息包括,但不限于,每一行文字的左上角坐标,该行文字的长度和宽度等。
步骤S32,分析该指定文档中的文字分布信息,判断出该指定文档中文字分布密度较低的区域、或/及无文字分布的区域,并将所述文字分布密度较低的区域、或/及无文字分布的区域标记为候选图表区域。
优选地,在本实施例中,所述判断出该指定文档中文字分布密度较低的区域包括:若一行文字的长度小于第一阀值(如5个字符单位长度),则判断出该行文字分布密度较低,并清洗(删除)该行文字。清洗后的该行文字变成了一个无文字分布的区域。
优选地,在本实施例中,所述判断出该指定文档中无文字分布的区域包括:对该指定文档中每一页从上到下进行扫描,若超过第二阀值宽度(如2个字符单位宽度)的区域没有扫描到文字,则判断出该区域为无文字分布的区域。
步骤S33,将所述标记的候选图表区域转换为图片,并从转换后的图片中筛选出包含图表信息的图片,作为该指定文档中抽取出的图表。在本实施例中,可以使用特定的图片处理工具(如ImageMagick工具)将所述标记的候选图表区域转换为图片。
优选地,在本实施例中,所述从转换后的图片中筛选出包含图表信息的图片包括:通过像素分布分析(或内容丰富程度分析),对转换后的图片进行筛选,选择出包含图表信息(如PDF图表信息)的图片。由于无文字区域有两种情况:一种是图表,一种是页面的空白区域,通过对图片的像素分布分析,可以判断出是这两种情况中的哪一种。
具体而言,通过像素分布分析从转换后的图片中筛选出包含图表信息的图片包括:
(1)对该转换后的图片进行灰度处理(如通过应用程序Python中的Opencv模块进行灰度处理),将该转换后的图片转换为灰度图。在该灰度图中,图片的每个像素点都被表示为0或255。其中,0代表黑色,为图片中有信息内容的像素点,255代表白色,为图片中空白的像素点。
(2)按行统计该灰度图中黑色像素点的数量和比例,若一行中黑色像素点的数量和比例超过指定阈值(如数量超过5,比例超过50%),则判定该行包含有具体内容。
(3)统计包含有具体内容的行的数量,以此来判定图片中内容的丰富程度,包含有具体内容的行越多,则代表该图片的内容越丰富。若包含有具体内容的行数大于或等于设定阈值(如2行),则判定该转换后的图片内容丰富, 是一张包含图表信息的图片。反之,若包含有具体内容的行数小于该设定阈值(如2行),则判定该转换后的图片内容不够丰富,是一张没有包含图表信息的空白图片。
通过上述步骤S31-S33,本申请所提出的文档图表抽取方法,通过文本密度分析从PDF文档中抽取图表,该方法除了能提取传统方法能抽取的图表外,还能提取出传统方法无法提取的Office图表信息等由多个部分组成的图表,提升了图表抽取的效率和覆盖面。
进一步地,为实现上述目的,本申请还提供一种计算机可读存储介质(如ROM/RAM、磁碟、光盘),所述计算机可读存储介质存储有文档图表抽取***20,所述文档图表抽取***20可被至少一个处理器22执行,以使所述至少一个处理器22执行如上所述的文档图表抽取方法的步骤。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件来实现,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。
以上参照附图说明了本申请的优选实施例,并非因此局限本申请的权利范围。上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。另外,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。
本领域技术人员不脱离本申请的范围和实质,可以有多种变型方案实现本申请,比如作为一个实施例的特征可用于另一实施例而得到又一实施例。凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (20)

  1. 一种电子设备,其特征在于,所述电子设备包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的文档图表抽取***,所述文档图表抽取***被所述处理器执行时实现如下步骤:
    获取指定文档中所有文字的位置信息,并根据所有文字的位置信息获取该指定文档中的文字分布信息;
    分析该指定文档中的文字分布信息,判断出该指定文档中文字分布密度较低的区域、或/及无文字分布的区域,并将所述文字分布密度较低的区域、或/及无文字分布的区域标记为候选图表区域;及
    将所述标记的候选图表区域转换为图片,并从转换后的图片中筛选出包含图表信息的图片,作为该指定文档中抽取出的图表。
  2. 如权利要求1所述的电子设备,其特征在于,所述判断出该指定文档中文字分布密度较低的区域包括:若一行文字的长度小于第一阀值,则判断出该行文字分布密度较低,并清洗该行文字。
  3. 如权利要求2所述的电子设备,其特征在于,所述判断出该指定文档中无文字分布的区域包括:对该指定文档中每一页从上到下进行扫描,若超过第二阀值宽度的区域没有扫描到文字,则判断出该区域为无文字分布的区域。
  4. 如权利要求3所述的电子设备,其特征在于,所述从转换后的图片中筛选出包含图表信息的图片包括:通过像素分布分析,对转换后的图片进行筛选,选择出包含图表信息的图片。
  5. 如权利要求4所述的电子设备,其特征在于,所述从转换后的图片中筛选出包含图表信息的图片包括:
    对该转换后的图片进行灰度处理,将该转换后的图片转换为灰度图;
    按行统计该灰度图中黑色像素点的数量和比例,若一行中黑色像素点的数量和比例超过指定阈值,则判定该行包含有具体内容;及
    统计包含有具体内容的行的数量,若包含有具体内容的行数大于或等于设定阈值,则判定该转换后的图片为一张包含图表信息的图片。
  6. 一种文档图表抽取方法,应用于电子设备,其特征在于,所述方法包括:
    获取指定文档中所有文字的位置信息,并根据所有文字的位置信息获取该指定文档中的文字分布信息;
    分析该指定文档中的文字分布信息,判断出该指定文档中文字分布密度 较低的区域、或/及无文字分布的区域,并将所述文字分布密度较低的区域、或/及无文字分布的区域标记为候选图表区域;及
    将所述标记的候选图表区域转换为图片,并从转换后的图片中筛选出包含图表信息的图片,作为该指定文档中抽取出的图表。
  7. 如权利要求6所述的文档图表抽取方法,其特征在于,所述判断出该指定文档中文字分布密度较低的区域包括:若一行文字的长度小于第一阀值,则判断出该行文字分布密度较低,并清洗该行文字。
  8. 如权利要求7所述的文档图表抽取方法,其特征在于,所述判断出该指定文档中无文字分布的区域包括:对该指定文档中每一页从上到下进行扫描,若超过第二阀值宽度的区域没有扫描到文字,则判断出该区域为无文字分布的区域。
  9. 如权利要求8所述的文档图表抽取方法,其特征在于,所述从转换后的图片中筛选出包含图表信息的图片包括:通过像素分布分析,对转换后的图片进行筛选,选择出包含图表信息的图片。
  10. 如权利要求9所述的文档图表抽取方法,其特征在于,所述从转换后的图片中筛选出包含图表信息的图片包括:
    对该转换后的图片进行灰度处理,将该转换后的图片转换为灰度图;
    按行统计该灰度图中黑色像素点的数量和比例,若一行中黑色像素点的数量和比例超过指定阈值,则判定该行包含有具体内容;及
    统计包含有具体内容的行的数量,若包含有具体内容的行数大于或等于设定阈值,则判定该转换后的图片为一张包含图表信息的图片。
  11. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有文档图表抽取***,所述文档图表抽取***可被至少一个处理器执行,以使所述至少一个处理器执行如下步骤:
    获取指定文档中所有文字的位置信息,并根据所有文字的位置信息获取该指定文档中的文字分布信息;
    分析该指定文档中的文字分布信息,判断出该指定文档中文字分布密度较低的区域、或/及无文字分布的区域,并将所述文字分布密度较低的区域、或/及无文字分布的区域标记为候选图表区域;及
    将所述标记的候选图表区域转换为图片,并从转换后的图片中筛选出包含图表信息的图片,作为该指定文档中抽取出的图表。
  12. 如权利要求11所述的计算机可读存储介质,其特征在于,所述判断出该指定文档中文字分布密度较低的区域包括:若一行文字的长度小于第一 阀值,则判断出该行文字分布密度较低,并清洗该行文字。
  13. 如权利要求12所述的计算机可读存储介质,其特征在于,所述判断出该指定文档中无文字分布的区域包括:对该指定文档中每一页从上到下进行扫描,若超过第二阀值宽度的区域没有扫描到文字,则判断出该区域为无文字分布的区域。
  14. 如权利要求13所述的计算机可读存储介质,其特征在于,所述从转换后的图片中筛选出包含图表信息的图片包括:通过像素分布分析,对转换后的图片进行筛选,选择出包含图表信息的图片。
  15. 如权利要求14所述的计算机可读存储介质,其特征在于,所述从转换后的图片中筛选出包含图表信息的图片包括:
    对该转换后的图片进行灰度处理,将该转换后的图片转换为灰度图;
    按行统计该灰度图中黑色像素点的数量和比例,若一行中黑色像素点的数量和比例超过指定阈值,则判定该行包含有具体内容;及
    统计包含有具体内容的行的数量,若包含有具体内容的行数大于或等于设定阈值,则判定该转换后的图片为一张包含图表信息的图片。
  16. 一种文档图表抽取***,其特征在于,所述文档图表抽取***可被至少一个处理器执行,以使所述至少一个处理器执行如下步骤:
    获取指定文档中所有文字的位置信息,并根据所有文字的位置信息获取该指定文档中的文字分布信息;
    分析该指定文档中的文字分布信息,判断出该指定文档中文字分布密度较低的区域、或/及无文字分布的区域,并将所述文字分布密度较低的区域、或/及无文字分布的区域标记为候选图表区域;及
    将所述标记的候选图表区域转换为图片,并从转换后的图片中筛选出包含图表信息的图片,作为该指定文档中抽取出的图表。
  17. 如权利要求16所述的文档图表抽取***,其特征在于,所述判断出该指定文档中文字分布密度较低的区域包括:若一行文字的长度小于第一阀值,则判断出该行文字分布密度较低,并清洗该行文字。
  18. 如权利要求17所述的文档图表抽取***,其特征在于,所述判断出该指定文档中无文字分布的区域包括:对该指定文档中每一页从上到下进行扫描,若超过第二阀值宽度的区域没有扫描到文字,则判断出该区域为无文字分布的区域。
  19. 如权利要求18所述的文档图表抽取***,其特征在于,所述从转换 后的图片中筛选出包含图表信息的图片包括:通过像素分布分析,对转换后的图片进行筛选,选择出包含图表信息的图片。
  20. 如权利要求19所述的文档图表抽取***,其特征在于,所述从转换后的图片中筛选出包含图表信息的图片包括:
    对该转换后的图片进行灰度处理,将该转换后的图片转换为灰度图;
    按行统计该灰度图中黑色像素点的数量和比例,若一行中黑色像素点的数量和比例超过指定阈值,则判定该行包含有具体内容;及
    统计包含有具体内容的行的数量,若包含有具体内容的行数大于或等于设定阈值,则判定该转换后的图片为一张包含图表信息的图片。
PCT/CN2017/108809 2017-08-31 2017-10-31 文档图表抽取方法、电子设备及计算机可读存储介质 WO2019041526A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710776352.X 2017-08-31
CN201710776352.XA CN107688788B (zh) 2017-08-31 2017-08-31 文档图表抽取方法、电子设备及计算机可读存储介质

Publications (1)

Publication Number Publication Date
WO2019041526A1 true WO2019041526A1 (zh) 2019-03-07

Family

ID=61155960

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/108809 WO2019041526A1 (zh) 2017-08-31 2017-10-31 文档图表抽取方法、电子设备及计算机可读存储介质

Country Status (2)

Country Link
CN (1) CN107688788B (zh)
WO (1) WO2019041526A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112115111A (zh) * 2019-06-20 2020-12-22 上海怀若智能科技有限公司 一种基于ocr的文档版本管理方法和***

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111752424B (zh) * 2019-03-26 2022-05-03 珠海金山办公软件有限公司 一种图表保存的方法、装置、电子设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5680479A (en) * 1992-04-24 1997-10-21 Canon Kabushiki Kaisha Method and apparatus for character recognition
CN1967567A (zh) * 2005-11-18 2007-05-23 三星电子株式会社 自动创建索引的图像形成装置及其方法
CN101004792A (zh) * 2006-01-18 2007-07-25 株式会社理光 图像处理装置和方法,图像形成装置以及计算机程序产品
CN101008960A (zh) * 2006-01-26 2007-08-01 株式会社理光 信息处理设备,信息处理方法,以及计算机程序产品
CN107133566A (zh) * 2017-03-31 2017-09-05 常诚 一种识别pdf文档中图表的方法

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7466875B1 (en) * 2004-03-01 2008-12-16 Amazon Technologies, Inc. Method and system for determining the legibility of text in an image
CN101833664A (zh) * 2010-04-21 2010-09-15 中国科学院自动化研究所 基于稀疏表达的视频图像文字检测方法
CN106156691B (zh) * 2015-03-25 2019-12-06 中测高科(北京)测绘工程技术有限责任公司 复杂背景图像的处理方法及其装置
CN106407969A (zh) * 2016-08-30 2017-02-15 杭州电子科技大学 一种健壮的复杂背景视频文本定位和抽取方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5680479A (en) * 1992-04-24 1997-10-21 Canon Kabushiki Kaisha Method and apparatus for character recognition
CN1967567A (zh) * 2005-11-18 2007-05-23 三星电子株式会社 自动创建索引的图像形成装置及其方法
CN101004792A (zh) * 2006-01-18 2007-07-25 株式会社理光 图像处理装置和方法,图像形成装置以及计算机程序产品
CN101008960A (zh) * 2006-01-26 2007-08-01 株式会社理光 信息处理设备,信息处理方法,以及计算机程序产品
CN107133566A (zh) * 2017-03-31 2017-09-05 常诚 一种识别pdf文档中图表的方法

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112115111A (zh) * 2019-06-20 2020-12-22 上海怀若智能科技有限公司 一种基于ocr的文档版本管理方法和***

Also Published As

Publication number Publication date
CN107688788A (zh) 2018-02-13
CN107688788B (zh) 2021-01-08

Similar Documents

Publication Publication Date Title
CN107688789B (zh) 文档图表抽取方法、电子设备及计算机可读存储介质
CN107689070B (zh) 图表数据结构化提取方法、电子设备及计算机可读存储介质
CN107093172B (zh) 文字检测方法及***
US10679089B2 (en) Systems and methods for optical character recognition
US9524559B2 (en) Image processing device and method
CN104298982A (zh) 一种文字识别方法及装置
US20090185752A1 (en) Method and apparatus for cropping images
CN110675940A (zh) 病理图像标注方法、装置、计算机设备及存储介质
CN102855232A (zh) 一种表格分析编改加工方法
US10417516B2 (en) System and method for preprocessing images to improve OCR efficacy
CN101833546A (zh) 从可移植电子文档中提取表格的方法和装置
CN114005126A (zh) 表格重构方法、装置、计算机设备及可读存储介质
WO2019041526A1 (zh) 文档图表抽取方法、电子设备及计算机可读存储介质
CN105551044A (zh) 一种图片对比方法和装置
US10740638B1 (en) Data element profiles and overrides for dynamic optical character recognition based data extraction
CN114049540A (zh) 基于人工智能的标注图像检测方法、装置、设备及介质
CN111008987B (zh) 基于灰色背景中边缘图像提取方法、装置及可读存储介质
CN110363092B (zh) 柱状图识别方法、装置、设备及计算机可读存储介质
CN110287988B (zh) 数据增强方法、装置及计算机可读存储介质
JP4967045B2 (ja) 背景判別装置、方法及びプログラム
CN105512100B (zh) 一种版面分析方法及装置
CN113850265A (zh) Pdf文档的解析方法、装置、电子设备及存储介质
CN111160193B (zh) 关键信息提取方法、装置及存储介质
JP5169648B2 (ja) 原画像探索装置及び原画像探索プログラム
US20150139548A1 (en) Methods and systems for recognizing handwriting in handwritten documents

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17923391

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS (EPO FORM 1205A DATED 23.09.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 17923391

Country of ref document: EP

Kind code of ref document: A1