I have three types of images and want to segment text from them. So I get a clean binarized img like the first image below. The three types of images are below
I've tried various techniques but it always have some cases to fail. I tried first to threshold the img using otsu
algorithm but it gave bad results in images below
I tried Guassian
, bilateral
and normal blur kernel but didn't enhance the results too much
Any one can provide help!
Code as the best I got results from
import cv2
gray = cv2.imread("/home/shrouk/Pictures/f2.png", 0)
thresholded = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]
cv2.imshow("img", thresholded)
This is the final result I need
This the first type of images that fail. It fails because the text grey level it lighter in the right of the image
The result of otsu on it is here, I just need a way to enhance the words in the third line from right:
Second type that fails because the darker background
otsu result is not very good as the words to the left look like dilated words
This is the type that correctly thresholded by otsu as there is no noise