Recognition & detection of components connected by a line

asked 2017-04-05 05:35:01 -0600

Mark1988 gravatar image

updated 2017-04-06 06:25:30 -0600

Hello everyone!

Now this is something I've been trying to do for a while without real success and I would really appreciate help. I have a binary image with few components connected with lines. An example would be something like this:

image description

What I need is to recognize all the components (in this example squares, triangles and circles) and how are they connected so the end result would be getting the coordinates of every component and every line so i can recreate it later if necessary.

My thinking is to recognize all the components first and lines later, so I would get something like this:

image description

Then I easily store the coordinates and remove them from the picture and I get only lines:

image description

And this part could be done with probabilistic HoughLines to get all the lines (all 10 of them).


So what I need help with is the way to go with the first part. How do I recognize my components? What is a good approach to this problem?

I would really appreciate any hint for solving this problem.

edit retag flag offensive close merge delete

Comments

LBerger gravatar imageLBerger ( 2017-04-06 06:51:15 -0600 )edit

@LBerger i just took a quick peek at it and i believe the problem is that if i have only one large contour in my image. since the components can be anything (not just triangle, square,...), i was thinking to use machine learning (e.g. kNN), but i stumbled against the same problem with one large contour. i guess one solution could be to try delete the lines and leave the components as separate contours, but i wouldn't know how to do that (not even eroding/dilating since the lines are of same thickness)

Mark1988 gravatar imageMark1988 ( 2017-04-06 07:08:59 -0600 )edit
1

First find shape : I think you can try to dilate hole and then look for connected componenents use logical operator to extract shape only without line. Machine learning : yes it is possible but if you have only circle triangle square hue moment would be suffisient. With machine learning hue moment are good descriptors for shape (invariant by rotation and translation)

LBerger gravatar imageLBerger ( 2017-04-06 07:45:41 -0600 )edit