I am planning to detect texts from document text images like below:


enter image description here

WORK DONE: I have tried to solve this with some scene text detection algorithms like EAST Text detector and PixelLink. But it only provides result in such a way it detects each and every word individually as below, which is obvious: enter image description here

What method can help me detect blocks of texts as mentioned under GOAL.


I don't want extract all texts via OCR. What I want instead is to detect texts based on their visual positional arrangement. See in the image, texts positioned together are detected as blocks. And my result should contain all the bounding box co-ordinates of all the detected text blocks.

  • 1
    $\begingroup$ If you are able to get to words, why don't you try to reconstruct the paragraphs by the geometry of the text? Simply put, words on the same row can be ordered according to the x coordinate to build the sentences. You might need to allow for some tollerance to noise/variation, but this should be easily manageable. Otherwise, it is difficult to determine what does it mean that two words are in the same text box, which can be easily observed in your headers and footers. $\endgroup$ – mapto Feb 25 '19 at 8:53
  • $\begingroup$ Possible duplicate of How to label and detect the document text images $\endgroup$ – HFulcher Feb 25 '19 at 10:04
  • $\begingroup$ @HFulcher well that refers to extract all the texts in the image through OCR, what I'm trying to solve is to detect text blocks based on their positional arrangement. I don't want to perform OCR, I need only the bounding boxes co-ordinates $\endgroup$ – DGS Feb 25 '19 at 10:43
  • 1
    $\begingroup$ @HFulcher Thanks for letting me know this. I have edited my question. $\endgroup$ – DGS Feb 25 '19 at 11:29
  • 1
    $\begingroup$ @DGS not a problem, hope you get an answer :) $\endgroup$ – HFulcher Feb 25 '19 at 11:30

I would approach the text block amalgamation as a clustering problem. If you define a suitable distance metric or a neighbour predicate between the individual text boxes, you could group the boxes and then determine their minimum bounding box, which is essentially what you are aiming for.

I guess DBSCAN could be a suitable candidate for the clustering algorithm, but more care would have to go into the design of the neighbor predicate - one idea could be that vertical distance could be treated differently than horizontal distance, etc.

  • 1
    $\begingroup$ I think this is the solution. Words from different blocks clearly have a distinctive distance compared to neighbor words inside a block. Algorithms for non-convex clusters such as DBSCAN would work. $\endgroup$ – Esmailian Mar 7 '19 at 19:24
  • 1
    $\begingroup$ Assuming (0, 0) is the top-left, (min x, min y) and (max x, max y) of set of words inside each cluster are the coordinates of bounding box of the corresponding block. $\endgroup$ – Esmailian Mar 7 '19 at 19:46
  • $\begingroup$ @Esmailian Can you point me out to some sample codes! $\endgroup$ – DGS Mar 14 '19 at 12:06
  • 1
    $\begingroup$ @DGS I assume you already have the center position of each word $w$ as $(x_w, y_w)$, now apply DBSCAN for clustering (it is a mainstream library), then use two points (min x, min y) and (max x, max y) that are calculated from words in each cluster as the bounding box of block (assuming top-left of page is (0, 0)). Your done! $\endgroup$ – Esmailian Mar 14 '19 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.