如何根据内容裁剪图像(Python 和 OpenCV)? [英] How to crop image based on contents (Python & OpenCV)?

查看:61
本文介绍了如何根据内容裁剪图像(Python 和 OpenCV)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在从事一个个人项目,即在从商​​店目录中获取的扫描图像中识别产品.

Well currently I'm working on a personal project which is the identification of products in a scanned image taken from a store catalog.

正如您在图片中看到的,产品之间没有线分隔,因此使用霍夫线来定位产品并不能真正解决问题!

As you may see in the image there's no lines separation between products, so using Hough lines to locate the products won't really solve the problem!

使用 Tesseract 提取图像内容真的很棒,我面临的唯一问题是自动查找图像产品,我的意思是不手动裁剪图像但我想检测产品,使用文字描述和价格裁剪它们,然后使用 OCR 提取内容.

Using Tesseract is really amazing to extract the image content, the only problem that I'm facing is finding the image products automatically, I mean not cropping the image manually but I want to detect the products, cropping them with their text description and price and then extract content using OCR.

我尝试了许多图像处理技术,但仍然一无所获(我使用的是 Python 和 OpenCV).提前致谢:)

I have tried many image processing techniques but still nothing (I'm using Python and OpenCV). Thanks in advance :)

推荐答案

您遇到的问题通常称为背景去除,或者前景提取.在这个例子中,它实际上可能相对容易,因为背景大多采用相同颜色的阴影 - 我的建议是查看此处描述的 GrabCut 算法:https://docs.opencv.org/3.4.3/d8/d83/tutorial_py_grabcut.html

The problem you have is usually called background removal, or alternatively foreground extraction. In this example, it might actually be relatively easy, as the background is mostly in shades of the same color - my recommendation would be to look at the GrabCut algorithm which is described here: https://docs.opencv.org/3.4.3/d8/d83/tutorial_py_grabcut.html

这篇关于如何根据内容裁剪图像(Python 和 OpenCV)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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