I think your image has multi-line text. In this case, you first need to detect these lines.
To do this, first align the image using the Otsu method or adaptive threshold.
Then you can use something called the Horizontal Bar Chart . This looks like a histogram, but shows where there are lines and where there are spaces. Therefore, divide the images into blank lines and you will get each line. Below is a horizontal bar chart.

Now, for each line, find the horizontal histogram. Before doing this, try to do expansion and erosion so that all letters are grouped together. You can then find related components in each line to get each word. Then draw the borders.
The horizontal and vertical histograms are shown below:

This SOF can help: How to convert an image to character segments?
source share