Given a document image (i.e. newspaper), how to extract photos in it or remove text region?

I think traditional OCR methods may not be suitable here, as I don't need to recognize the text, and OCR is not accurate and slow. I believe text region (i.e. text blocks) and image region should be distinguishable by some threshold based methods in image processing. Any suggestions or example codes in OpenCV will be appreciated. Thanks!

BTW, what if the background color is not white, or the background color of certain blocks are not white?

Example image:

enter image description here


3 Answers 3


What you are asking is called 'page layout analysis' in OCR. Take a look at https://en.wikipedia.org/wiki/Document_layout_analysis.

  • $\begingroup$ It is clear that deep learning techniques, especially on computer vision problems, are quickly developed in recent years. I believe it is now much easier to 1) find picture regions; and 2) detect texts of different font size. However, the layout, or equivalently reading order among different text regions is still a difficult problem. $\endgroup$
    – pitfall
    Feb 19, 2018 at 0:33

in this link , last comment from Sastry Aditya.

There is a technique called windowing. This is done using neural networks or support vector machines.

You basically train your classifier(Neural net or SVM) with 1000000's of images of single characters of pixel size 10 x 10 or so.

If your target image is say 1280 x 720 you start off by dividing into a grid of 10x10 squares. You feed each of this square to a classifier to see if it is a text character. If it turns out to be true you make it blank.

After this anything that is not blank in your image region is the text region.

In this approach, you don't need to recognize the texts like OCR, just detect them!

It will be faster and straight to the point you want.

Edit : took a further study on this topic >> a lot of newspaper segmentation algorithms have been proposed recently (IEEE database). Just for if you want something in academic way.


The Stroke Width Transform seems to be an effective technique (you'll find links easily). Note that it will also find text present in the photos !


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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