使用 OpenCV 将图像文档转换为黑白
我是 OpenCV 和图像处理的新手,我不知道如何解决我的问题。 我有一张用 iPhone 制作的文档照片,我想将该文档转换为黑白。我尝试使用阈值,但文本不太好(有点模糊且难以阅读)。我希望文本看起来与原始图像相同,只有黑色,背景为白色。我能做些什么? PS 当我对文档的一部分进行拍照时,文本很大,然后结果就可以了。
我将不胜感激任何帮助。
这是我使用的示例图像和结果:
I'm new to OpenCV and image processing and I'M not sure how to solve my problem.
I have a photo of document made in iPhone and I want to convert that document to black and white. I tried to use threshold but the text was not so good (a little blurry and unreadable). I'd like to text looks same as on the original image, only black, and background will be white. What can I do?
P.S. When I made a photo of part of the document, where text is quite big, then result is ok.
I will be grateful for any help.
Here are the example image I use and the result:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的尝试,也许比你的更具可读性:
My attemp, maybe a little more readable than yours:
阈值图像用于不同的目的。
如果您只想将其转换为黑白图像,只需执行此操作即可。使用 openCV 2.2,
第二个参数 0 告诉将彩色图像读取为黑白图像。
如果你想保存为 ab/w 图像文件。
编码这个
Threshold image is used for different purposes.
If u just want to convert it to b/w image just do this. USing openCV 2.2
the second parameter 0 tells to read a color image as b/w image.
And if you want to save as a b/w image file.
code this
在这里使用自适应高斯阈值是一个好主意。这也将提高图像中写入文本的质量。
您只需发出命令即可做到这一点:
Using Adaptive Gaussian Thresholding is a good idea here. This will also enhance the quality of text written in the image.
You can do that by simply giving the command: