I have an image
from where I want to extract each and every character individually.
As i want something like THIS OUTPUT and so on.
What would be the appropriate approach to do this using OpenCV and python?
I have an image
from where I want to extract each and every character individually.
As i want something like THIS OUTPUT and so on.
What would be the appropriate approach to do this using OpenCV and python?
A short addition to Amitay's awesome answer. You should negate the image using
cv2.THRESH_BINARY_INV
to capture black letters on white paper.
Another idea could be the MSER blob detector like that:
img = cv2.imread('path to image')
(h, w) = img.shape[:2]
image_size = h*w
mser = cv2.MSER_create()
mser.setMaxArea(image_size/2)
mser.setMinArea(10)
gray = cv2.cvtColor(filtered, cv2.COLOR_BGR2GRAY) #Converting to GrayScale
_, bw = cv2.threshold(gray, 0.0, 255.0, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
regions, rects = mser.detectRegions(bw)
# With the rects you can e.g. crop the letters
for (x, y, w, h) in rects:
cv2.rectangle(img, (x, y), (x+w, y+h), color=(255, 0, 255), thickness=1)
This also leads to a full letter recognition.
You can do the following ( opencv 3.0 and aboove)