afyonkarahisarkitapfuari.com

Extracting Text from Images: A Guide Using Python Techniques

Written on

Chapter 1: Understanding OCR

Optical Character Recognition (OCR) has transitioned from being a complex aspect of artificial intelligence to a straightforward task that can be performed on your personal computer.

The image below illustrates the text I aimed to extract:

Image demonstrating text extraction

Chapter 2: Simple Text Extraction Without Code

One of the simplest methods to achieve text extraction involves no programming skills at all and can be done quickly via Google Docs.

To begin, upload your image file to Google Docs. After that, right-click on the image and choose Open with -> Google Docs.

Screenshot of Google Docs interface

This action will generate a two-page document: one page displays the image, while the other contains the converted text.

Output document showing extracted text

However, the extracted text may not always be easily readable.

Time to Write Some Code

To refine the extraction process, I opened PyCharm (you can download the community edition here) and inserted the necessary code. Initially, I encountered some missing components, specifically cv2 and pytesseract, which were highlighted in red.

PyCharm showing missing library errors

A quick right-click on the highlighted imports allows you to address these issues.

Context actions menu in PyCharm

Select Show Context Actions -> Install package opencv-python.

Installing OpenCV package in PyCharm

Similarly, install pytesseract.

Installing Pytesseract package in PyCharm

Once the installation is complete, run the application, and the output will be as follows:

WORDS TO USE

Instead of “very,” consider these alternatives:

  • very noisy → deafening
  • very often → frequently
  • very old → ancient
  • very old-fashioned → archaic
  • very open → transparent
  • very painful → excruciating
  • very pale → ashen
  • very perfect → flawless
  • very poor → destitute
  • very powerful → compelling
  • very pretty → beautiful
  • very quick → rapid
  • very quiet → hushed
  • very rainy → pouring
  • very rich → wealthy
  • very sad → sorrowful
  • very scared → petrified
  • very scary → chilling
  • very serious → grave
  • very sharp → keen
  • very shiny → gleaming
  • very short → brief
  • very shy → timid
  • very simple → basic

Overall, the output is quite decent, but further refinement can enhance the clarity and formatting by removing extraneous characters.

Final Clean Output

The final cleaned-up output is as follows:

  • deafening = very noisy
  • frequently = very often
  • ancient = very old
  • archaic = very old-fashioned
  • transparent = very open
  • excruciating = very painful
  • ashen = very pale
  • flawless = very perfect
  • destitute = very poor
  • compelling = very powerful
  • beautiful = very pretty
  • rapid = very quick
  • hushed = very quiet
  • pouring = very rainy
  • wealthy = very rich
  • sorrowful = very sad
  • petrified = very scared
  • chilling = very scary
  • grave = very serious
  • keen = very sharp
  • gleaming = very shiny
  • brief = very short
  • timid = very shy
  • basic = very simple

If you found this article helpful, feel free to hit the "clap" button below! You can press and hold it to give a standing ovation of up to 50 claps.

Clap button interface on Medium

For more engaging content, consider signing up for Medium—it's free, simple, and quick!

Medium platform logo

Chapter 3: Video Tutorials

To deepen your understanding, check out the following video tutorials:

This tutorial, titled "How to Extract Text From Your Images in ONLY 3 Lines of Code | Python Tutorial," provides a concise guide to text extraction using Python.

Another helpful video is "How to convert image to text using python," which further explores the topic.

Share the page:

Twitter Facebook Reddit LinkIn

-----------------------

Recent Post:

Navigating Relationship Challenges: Insights from Experts

Understand the complexities of relationships and learn how to manage differences for lasting connections.

How I Overcame Smoking After Nearly Two Decades: A Transformative Journey

A personal account of quitting smoking after 19 years, highlighting challenges, growth, and newfound purpose.

Transforming $1,000 into a Fortune: Insights from AI Strategies

Explore how AI can guide you in turning $1,000 into a lucrative investment through smart strategies and insights.