# OpenCV Image PreProcessing For Pytesseract

**URL:** <https://forum.opencv.org/t/opencv-image-preprocessing-for-pytesseract/7370>\
**Category:** Python\
**Tags:** ocr\
**Created:** [February 1, 2022, 11:04am UTC](https://forum.opencv.org/t/opencv-image-preprocessing-for-pytesseract/7370 "2022-02-01T11:04:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Warren\_Lee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/warren_lee/32/4378_2.png) [@Warren\_Lee](https://forum.opencv.org/u/Warren_Lee)\
**Post date:** [February 1, 2022, 11:04am UTC](https://forum.opencv.org/t/opencv-image-preprocessing-for-pytesseract/7370/1 "2022-02-01T11:04:05Z")

</div>

Hi,

I have a sample image below where i’m trying to extract the content using pytesseract

 ![Sample](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/2/277c6e0b6dd0d9d01ad64bef9dab0819586f5dc6.jpeg)

I’ve tried pre-processing it in OpenCV first via:

1. Convert to grayscale
2. Apply Gaussian Blurring, then Adaptive Thresholding
3. Apply Dilation

Using Pytesseract, i can extract the text fine apart from those in the **Dividend Period** column, and that is because the words are not pronounced enough.

Are there other pre-processing techniques that i can use in OpenCV to increase the font weight of that column so i can extract those text to a reasonable degree?

Appreciate if someone can point me in the right direction (better if you can share a sample code), or is this not possible at all?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 1, 2022, 12:05pm UTC](https://forum.opencv.org/t/opencv-image-preprocessing-for-pytesseract/7370/2 "2022-02-01T12:05:30Z")

</div>

the very first thing you need to fix is the compression. that text is blurry due to compression.

---

<div class="post-metadata">

**Author:** ![Warren\_Lee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/warren_lee/32/4378_2.png) [@Warren\_Lee](https://forum.opencv.org/u/Warren_Lee)\
**Post date:** [February 1, 2022, 12:53pm UTC](https://forum.opencv.org/t/opencv-image-preprocessing-for-pytesseract/7370/3 "2022-02-01T12:53:13Z")

</div>

Hi @crackwitz,

I’ll have to see if I can get better quality/higher resolution of the scanned in image for the above

Assuming I can and the section is no longer as blurry, the font is still relatively light compared to others.

What would you recommend in terms of preprocessing for the image above apart from what I’ve already tried?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 1, 2022, 1:28pm UTC](https://forum.opencv.org/t/opencv-image-preprocessing-for-pytesseract/7370/4 "2022-02-01T13:28:01Z")

</div>

related: [python 3.x - Pytesseract Extract Light Text From Image - Stack Overflow](https://stackoverflow.com/questions/70939377/pytesseract-extract-light-text-from-image)

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 1, 2022, 1:28pm UTC](https://forum.opencv.org/t/opencv-image-preprocessing-for-pytesseract/7370/5 "2022-02-01T13:28:42Z")

</div>

what I would recommend? subtract a median blur
