Message Boards Message Boards

0
|
8776 Views
|
7 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Segmenting Rectangles

Does anyone know how to take a Banalized Image that has a table with handwritten data in it, and identify and segment the rectangles formed by each cell in the table? I have the other parts of the problem solved, but am having trouble figuring out how to feature detect the rectangles. Thanks for your help. Rod Shankle

Attachments:
POSTED BY: William Shankle
7 Replies

Hi there,

I haven't had much time, but just to get the discussion going, this finds the boxes and colours them.

img = Import["~/Desktop/TestForm.jpg"];
SelectComponents[MorphologicalComponents[Binarize[ColorNegate@ImageResize[img, 800]]], "Rectangularity", # > 0.7 &] // Colorize

enter image description here

I have resized the image; note that the boxes in the first row, are often split into two parts because the "tick" cuts them into two.

Cheers,

Marco

POSTED BY: Marco Thiel

dear Marco Thank you very much. I will try this out and let you know how it works. Sinbcdrely Rod

POSTED BY: William Shankle
Posted 10 years ago

I have some experience detecting tables of specific proportions. You may find this information useful: http://mathematica.stackexchange.com/questions/13918/detecting-grid-lines-in-a-raster-image

POSTED BY: Gustavo Delfino

Dear Gustavo Your program is pretty amazing. It ran all the way down to the last line but is giving an error that I cannot understand. It indicates that "Part::partw: Part 1 of {} does not exist. >>" My interpretation is that it does not seem to recognize {h, horizontalGridLineMasks} I have attached the notebook with the image I am trying to work on. If you have any advice as to how fix this, I would greatly appreciate it. The data are the largest database in the world on memory loss in Alzheimer's Disease and normal aging, and will result in some real important breakthroughs for the field. Sincerely Rod Shankle

Attachments:
POSTED BY: William Shankle
Posted 10 years ago

William, I did not get that error, but I haven't had time to see what is going on. In the meanwhile, I am attaching a more complete notebook with my related work. I started preparing it for presenting it at a WTC but then I had to move and I couldn't go. So the last part of the notebook is not too well explained and some sections may still be in Spanish.

Attachments:
POSTED BY: Gustavo Delfino

Dear Gustavo You were so kind to share your insights with me that I thought you may be interested in a slightly different but usable approach to the problem you addressed in recognizing the table on the ballot, and then putting the cells of the table into a matrix that can be analyzed to determine its contents.

This article is from a computer science group in Brasil. They approached the problem by identifying that a table has 9 "structured elements". These elements correspond to the four corners of the table, the four sides of the table and the intersection of the lines of the cells that do not lie along the borders of the table. By recognizing these structured elements, one can identify and segment the cells of a table, then read the cells' contents.

I have still not been able to get your solution to work, but it has been helpful. I am still trying to understand what your code does in some points. Thanks again. Sincerely William

Attachments:
POSTED BY: William Shankle

William, this is an interesting and useful problem but I just don't have the time now. I am in the middle of an international move (Germany->USA).

Regards, Gustavo

POSTED BY: Gustavo Delfino
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract