gpt4 book ai didi

python-imaging-library - 相当于 OpenCV 在 PIL 中的腐 eclipse 和扩张?

转载 作者:行者123 更新时间:2023-12-04 18:02:05 26 4
gpt4 key购买 nike

我想用 PyTesseract 做一些图像 OCR,我已经看到 OpenCV 的 erode 和 dilate 函数对于去噪预处理非常有用。

由于 PyTesseract 已经需要 PIL/Pillow,我想在 PIL 中去除噪音,而不是获取另一个库。 PIL 中是否有等效于腐 eclipse /扩张的方法? (我的研究似乎表明可以以这种方式使用 MaxFilter 和 MinFilter,但我并不完全清楚这是不是真的。)

谢谢!

最佳答案

最好的选择是使用 OpenCV python 绑定(bind)。但是,如果您想使用 PIL/Pillow,则有 ImageFilter 模块:
http://pillow.readthedocs.io/en/3.1.x/reference/ImageFilter.html

dilation_img = src_img.filter(ImageFilter.MaxFilter(3))
erosion_img = src_img.filter(ImageFilter.MinFilter(3))

示例中的数字 3 是掩码大小;

关于python-imaging-library - 相当于 OpenCV 在 PIL 中的腐 eclipse 和扩张?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44195007/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com