OpenCV Python - Fixing Broken Text

OpenCV Python - Fixing Broken Text

I am attempting to repair broken text (the images below) so that I can perform OCR on the images. How do I go about repairing the text below? I have already tried dilation, erosion, morphology closing, and using the distance between contours. None of these seem to work. I would appreciate any help, thanks.

I am attempting to repair broken text (the images below) so that I can perform OCR on the images. How do I go about repairing the text below? I have already tried dilation, erosion, morphology closing, and using the distance between contours. None of these seem to work. I would appreciate any help, thanks.

Broken Text:

Attempted Solutions (none work):

import cv2
import pytesseract
import numpy as np

img = cv2.imread ("/Users/2020shatgiskessell/Desktop/OpenSlate/FN2.png")

def OCR (img): config = ('-l eng --oem 1 --psm 3') text = pytesseract.image_to_string(img, config = config) return text

def get_countour(img): try: output = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) output = output.copy() except Exception: output = img.copy() #imgray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) #ret, thresh = cv2.threshold(output, 127, 255, 0) contours, hierarchy = cv2.findContours(output, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) c = max(contours, key = cv2.contourArea) contours.remove(c) cv2.drawContours(output, contours, -1, (0,255,0),-1)

    kernel = np.ones((2,1),np.uint8)
    #eroded = cv2.erode(output, kernel,1)
    output = cv2.dilate(output, kernel,1)
    return output

def strengthen(img): try: imgray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) except Exception: imgray = img #ret, thresh = cv2.threshold(imgray,0,255,cv2.THRESH_BINARY | cv2.THRESH_OTSU) #blur1 = cv2.blur(imgray,(5,5)) blur2 = cv2.GaussianBlur(imgray,(5,5),0) thresh2 = cv2.adaptiveThreshold(blur2, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 31, 2) kernel = np.ones((2,1),np.uint8) #eroded = cv2.erode(thresh2, kernel,1) #opening = cv2.morphologyEx(eroded, cv2.MORPH_CLOSE, kernel) #closing = cv2.morphologyEx(opening, cv2.MORPH_CLOSE, kernel) return thresh2

#MNIST(img) strengthened= strengthen(img)

contours = get_countour(strengthened)

print("from morphology transformation: "+ OCR(contours))

cv2.imshow('img', img) cv2.imshow('contour', contours)

cv2.waitKey(0) cv2.destroyAllWindows()

The above images are recognized as:

Image 1: (CAN ajne oF

Image 2: > AMAR VRAIR

Image 3: STure

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

OpenCV Python Tutorial: Computer Vision With OpenCV In Python

OpenCV Python Tutorial: Computer Vision With OpenCV In Python: Learn Vision Includes all OpenCV Image Processing Features with Simple Examples. Face Detection, Face Recognition. Computer Vision is an AI based, that is, Artificial Intelligence based technology that allows computers to understand and label images. Use OpenCV to work with image files. Create Face Detection Software. Detect Objects, including corner, edge, and grid detection techniques with OpenCV and Python. Use Python and Deep Learning to build image classifiers. Use Python and OpenCV to draw shapes on images and videos. Create Color Histograms with OpenCV

OpenCV Python Tutorial - Computer Vision With OpenCV In Python

In this OpenCV Python Tutorial article, we will be covering various aspects of Computer Vision using OpenCV in Python. OpenCV has been a vital part in the development of software for a long time. Learning OpenCV is a good asset to the developer to improve aspects of coding and also helps in building a software development career.

OpenCV Python for Beginners - Learn Computer Vision with OpenCV 2020

OpenCV Python for Beginners - Learn Computer Vision with OpenCV in 10 Hours (2020). You'll learn: Introduction to OpenCV; How to Install OpenCV for Python on Windows 10; How to Read, Write, Show Images in OpenCV; How to Read, Write, Show Videos from Camera in OpenCV; matplotlib with OpenCV; Image Pyramids with Python and OpenCV; Canny Edge Detection in OpenCV; Image Blending using Pyramids in OpenCV; Face Detection using Haar Cascade Classifiers ...