Domanda

I'm trying to read a map that was hand-drawn in Paint programmatically. The map looks like this:

http://i.stack.imgur.com/mxlXU.png

I need know which region every pixel of the map belongs to and what their names are.

I thought of the following, but I wonder if there's an easier or faster (the original map is quite large) method:

  1. Detect regions: Flood-fill from every pixel and save the regions. This does not match the text.
  2. Detect text/"noise": Flood-fill every pixel again, but this time use the previously detected areas of neighbour pixels to as borders. E.g. when doing this for a pixel of the text in the "Abc" region, everything that does not belong to the region surrounding "Abc" would be flooded. Then discard regions with an area over a specific number, for example 20 pixels. This is done to match letters (with a small area) that are completely contained by the region.
  3. Save the regions' pixels (including pixels detected in 2) in image files and feed each into tesseract to get the name of the region.

I find the approach above quite complicated and it seems to be quite slow (I did not implement it completely yet though). It also doesn't handle completely closed regions well where a border pixel is missing. Are there any simpler/better solutions to do this?

È stato utile?

Soluzione

If you first do the flood filling at every pixel, you'll probably also get small regions inside letters like O, B, A. I think you could try the following:

  1. Detect areas containing labels and remember the coordinates of the rectangle around it.
  2. For each area containing text use tesseract or similar to read the label and remember it.
  3. Remove the rectangles containing text. After that you could try doing some morphological operations to try and close the regions that aren't completely closed. Start the flood fill from locations where you found text to get the regions.

This could work in theory, but the results will depend on what the images look like, how well you detect the text and things like that.

Good luck!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top