0

I'm new to deep learning and image processing but I've implemented the following code for splitting Arabic characters, but my code does not recognize characters and it only finds the whole word. this is the whole word that is detected by the code

import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline

image = cv.imread('hamd.png')
height, width, depth = image.shape
print(image.shape)

image = cv.resize(image, dsize=(width*5, height*4), interpolation=cv.INTER_CUBIC)
print(image.shape)

gray = cv.cvtColor(image,cv.COLOR_BGR2GRAY)
ret,thresh = cv.threshold(gray,127,255,cv.THRESH_BINARY_INV)

kernel = np.ones((5,5), np.uint8)
img_dilation = cv.dilate(thresh, kernel, iterations=1)

gsblur=cv.GaussianBlur(img_dilation,(5,5),0)

ctrs, hier = cv.findContours(gsblur.copy(), cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
m = list()
sorted_ctrs = sorted(ctrs, key=lambda ctr: cv.boundingRect(ctr)[0])
pchl = list()
dp = image.copy()
for i, ctr in enumerate(sorted_ctrs):
    x, y, w, h = cv.boundingRect(ctr)
    cv.rectangle(dp,(x-10,y-10),( x + w + 10, y + h + 10 ),(90,0,255),9)
plt.imshow(dp)

now i wondered how can i split the character on the distances between two chars? what i mean looks like the image below: this is what i want

mobbbbbbbi
  • 35
  • 5
  • Does this answer your question? [cursive character segmentation in OCR](https://stackoverflow.com/questions/17262452/cursive-character-segmentation-in-ocr) – yann ziselman Aug 12 '21 at 10:32
  • and here's [another similar question](https://stackoverflow.com/questions/50815307/extract-character-images-from-cursive-continuous-handwritten-image) – yann ziselman Aug 12 '21 at 10:34

0 Answers0