Recognition & detection of components connected by a line
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:
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:
Then I easily store the coordinates and remove them from the picture and I get only lines:
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.
you can try with shape and distance matching
@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)
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)