I have a list of shapes (list of points) e.g. rectangles which I want to group/cluster together.
This is what I have:
And this is what I want to achieve.
How to do it?
I already looked at some clustering techniques, e.g., kmeans but it seems there must be a better way.
Thanks!


CD, i.e. the maximum distance between 2 rectangles at which they would be considered a cluster[xmin', ymin', xmax', ymax'] = [xmin - CD/2, ymin - CD/2, xmax + CD/2, ymax + CD/2]xmin'-s andxmax'-s and select all pairs of rectangles where eitherxmin'orxmax'of the first is within(xmin', xmax')range of the second; these are the potential clustering targetsymin'-s andymax'-s and check if the pairs from the previous step do indeed intersect; form clusters(rect #3, rect #10)and cluster(rect #10, rect #7)are to be merged, thus becoming a(rect #3, rect #7, rect #10)cluster