Question

I'm currently working on a small project involving the detection of specific areas in similar pictures representing floor plans drawn over a fixed background.

Here is a picture example:

I'm trying to identify the doors, trying to reach for that kind of result:

I'm a total neophyte on image manipulation and am not sure what kind of algorithm or image manipulation method I am looking for. I tried playing with some edge detection algorithms included in Photoshop but I wasn't able to get to a clean result.

Can anyone provide some help or direction?

Was it helpful?

Solution

I finally got it working with almost any kind of tile. And since the algorithm is just used to generate configuration files for another application, I'll fix the remaining tiles manually :)

Here is my solution for anyone interested:

  1. Raise the contrast and lower the brightness of the image in order to easily distinguish the walls from the rest:

  2. Divide each tile on a 6x6 grid of 200x200px squares. For each square, compute the average RGB value for each side on a 30px side line.

  3. Compare this value to the rest of the tile. If the difference is greater than a specific delta (found empirically), then it's a wall.

  4. Go around each tile on the border to check for walls leading to the exit (vertical walls for the top side, etc) and once you identified them, finding which tile leads to the exit is rather trivial.

Here is the final result on various tiles:

OTHER TIPS

I don't think that edge detection will help you here.

If the floor plans are always regular grids, the task is easier: You just have to loop through all border tiles and identify whether they are wall tiles or floor tiles. If it is a door tile, draw the door as rectangle. (This means that in your example, there are really four doors that are one grid wide, not two doors that are two grids wide each. Floor tiles in the corner would also be two doors, one vertical the other horizontal.)

The problem is to identify the tiles. The floor tiles are too different, have a rough texture and also have shadows cast by the walls. It's easier to identify a wall tile. They are similar in colour.

My first idea was to scale the image down to 6x6 pixels. That would give me an average colour of each tile, but it didn't work: The wall segments give an offset to the colour.

An approach that seems to work is to determine the average RGB colour of the core region of each tile and then compare it to the muddy dark brown of the wall tiles with the Euclidean distance to a wall tile colour sample:

Floor plan with average tile colours

That approach relies on a similar colour scheme for all tiles throughout all plans. I have used the criterion

r > 0x44 || g > 0x44|| b > 0x44

here to identify a floor tile. Maybe you need a better criterion if you have to distinguish between more tile types.

Edit I've just seen the new tiles you've posted. The approach above won't work here, at least not in the plan with the railway tracks. Perhaps the algorithm needs to look at the thin wall.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top