I am trying to detect the word coordinates for a line image.
I achieved the line segmentation by using horizontal histogram projection.
Now I need to make word segmentation in that line image.
I tried this algorithm.
The above algorithm is working fine but it is decreasing the size of an image. It was affecting the word size.
So, I need some help to do word segmentation without decreasing the size of an image.
I also tried some methods, but it was working only for few lines images.
gray = cv2.cvtColor(line_image, cv2.COLOR_BGR2GRAY)
ret, thresh1 = cv2.threshold(gray, 0, 255, cv2.THRESH_OTSU | cv2.THRESH_BINARY_INV)
rect_kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (59,59))
dilation = cv2.dilate(thresh1, rect_kernel, iterations =1)
contours, hierarchy = cv2.findContours(dilation, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
boundary=[]
for c,cnt in enumerate(contours):
x,y,w,h = cv2.boundingRect(cnt)
boundary.append((x,y,w,h))
k=sorted(boundary)
print(boundary)
The above code is working for only a few images.
Sample image

I need some help to do word segmentation without decreasing the size (height or width) of an image.