I want to do some image OCR with PyTesseract, and I've seen that OpenCV's erode and dilate functions are very useful for noise removal pre-processing.
Since PyTesseract already requires PIL/Pillow, I'd like to do the noise removal in PIL, rather than get another library. Is there an equivalent to erode/dilate in PIL? (My research seems to suggest that MaxFilter and MinFilter could be used this way, but it's not fully clear to me if that's really true.)
Thanks!
The best option is to use OpenCV python bindings. However, if you want to use PIL/Pillow, there is the ImageFilter Module: 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))
The number 3 in the example is the mask size;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With