从扫描的文档opencv python中提取行表 [英] Extract lined table from scanned document opencv python

查看:353
本文介绍了从扫描的文档opencv python中提取行表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从扫描表中提取信息并将其存储为csv.现在,我的表提取算法执行以下步骤.

I want to extract the information from a scanned table and store it a csv. Right now my table extraction algorithm does the following steps.

  1. 应用偏斜校正
  2. 应用高斯滤波器进行降噪.
  3. 使用Otsu阈值进行二值化
  4. 做一个形态学的开口.
  5. 发现小伙子们
  6. 进行霍夫变换以获得表格行.
  7. 删除重复的行(同一行在10像素范围内)
  8. 使用线的斜率过滤水平线和垂直线(水平线和垂直线的斜率应小于+/- 5度).

对于数字出生的pdf和大多数扫描的文档,此算法运行良好.但是,有些文档的表很嘈杂,因此无法正确识别行.

This algorithm is working fine for digital born pdfs and most of the scanned documents. But, Some of the documents have a noisy table and thus its not identifying the lines correctly.

这是示例算法失败的示例图像.

Here is a sample image in which my algorithm fails.

这些是我正在此表上执行的操作. 1.高斯模糊

These are the operations I am doing on this table. 1.Gaussian blur

2.大津阈值

3.形态学开放

4.Canny边缘检测

4.Canny edge detection

5.过滤的行,如您所见,显然没有识别出行 正确地.

5.filtered lines,as you can see the lines are clearly not identified correctly.

任何人都可以建议从这种质量较低的扫描中提取水平线和垂直线的更好方法.

Can anyone please suggest better method for extracting horizontal and vertical lines from this kind of less quality scans.

提前谢谢!

推荐答案

我在此博客中找到了一个完美的解决方案. https://medium.com/coinmonks/一个用于任何包含图像的盒子的盒子检测算法756c15d7ed26

I found a perfect solution in this blog. https://medium.com/coinmonks/a-box-detection-algorithm-for-any-image-containing-boxes-756c15d7ed26

在这里,我们使用垂直核检测垂直线,水平核检测水平线,然后将它们组合以获得所有必需的线,从而进行形态转换.

Here,We are doing morphological transformations using a vertical kernel to detect vetical lines and horizontal kernel to detect horizontal lines and then combining them to get all the required lines.

垂直线

水平线

必需的输出

这篇关于从扫描的文档opencv python中提取行表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆