Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rectangular Blank Space Detection (OpenCV)

I am looking for a strategy to find rectangular blank spaces in an image (in this case a scanned text document).

My initial thought was to base it on some sort of floodfill algorithm modified for growing rectangles. I've played with Hough Transforms a bit but didn't get the right results (quite possibly because I didn't tune it properly for text blocks).

Before I pull out all my hair, does anyone have any suggestions for algorithms or strategies to accomplish something like this? (I've attached a link to a quick example I mocked up)

Thanks!

http://f.cl.ly/items/0K2b2V231c1a2T0E350L/Untitled%203.png

like image 359
cdunn Avatar asked Sep 03 '26 16:09

cdunn


1 Answers

The simplest thing I would do is; take a white pixel (assume your image is binary), and start to enlarge it with in x and y direction separately. Once an enlargement process hit a black pixel stop enlarging in that direction. But you should keep enlarging the region in other direction until it hits a black pixel too. Otherwise you will get only square pixels.

Then you must save which positions assigned to a region so a pixel should not be assigned to more than one region. Also you must have threshold values for the size in each direction (length and width), therefore you can avoid so many regions.

like image 100
Semih Korkmaz Avatar answered Sep 05 '26 15:09

Semih Korkmaz