python OCR : ignore signatures in documents

标签 python opencv image-processing machine-learning ocr

我正在尝试对其中包含手写签名的扫描文档进行 OCR。请参见下图。

enter image description here

我的问题很简单,有没有办法在忽略签名的情况下仍然使用 OCR 提取人员的姓名?当我运行 Tesseract OCR 时,它无法检索名称。我尝试使用下面的代码进行灰度/模糊/阈值处理,但没有成功。有什么建议吗?

image = cv2.imread(file_path)
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
image = cv2.GaussianBlur(image, (5, 5), 0)
image = cv2.threshold(image, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1]

最佳答案

您可以使用 scikit-image 的高斯滤波器首先模糊细线(使用适当的 sigma),然后对图像进行二值化(例如,使用一些 thresholding 函数),然后通过形态学操作(例如 remove_small_objects 或使用一些适当的 structureopening),去除签名,然后尝试使用滑动窗口对数字进行分类(假设已经用测试图像中的一些模糊字符进行了训练)。下面是一个例子。

from skimage.morphology import binary_opening, square
from skimage.filters import threshold_minimum
from skimage.io import imread
from skimage.color import rgb2gray
from skimage.filters import gaussian

im = gaussian(rgb2gray(imread('lettersig.jpg')), sigma=2)
thresh = threshold_minimum(im)
im = im > thresh
im = im.astype(np.bool)
plt.figure(figsize=(20,20))
im1 = binary_opening(im, square(3))
plt.imshow(im1)
plt.axis('off')
plt.show()    

enter image description here

[编辑]:使用深度学习模型

另一种选择是将问题作为对象检测问题提出,其中字母表是对象。我们可以使用深度学习:CNN/RNN/Fast RNN模型(带tensorflow/keras)进行物体检测或Yolo模型(引用this article进行汽车检测使用 yolo 模型)。

关于 python OCR : ignore signatures in documents,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52020536/

相关文章:

Python 相当于在 Matlab 中分配给一个数组(在 for 循环内)

python - 使用 Python 和 OpenCV 在图像中查找红色

c++ - OpenCV 中 meanShiftFiltering 和 meanShiftSegmentation 的区别

Python3模块将字符串复制到系统剪贴板

python - defaultdict的含义(lambda : defaultdict(dict))

opencv - 为什么转换为灰度opencv?

android - 适用于 Android 的 openCV - 不是 opencv-android-sdk

.net - 在ASP.NET中生成图像缩略图?

python - 使用 Python 进行 Excel

python - 如何检测连接图像上元素的角 "joints"?