I have a set of rectangles which I need to cluster together, based on euclidean distance between them.The situation is explained in the attached image. .
One possible approach is to take the center of each rectangle and cluster the center points using K means (distance function would be euclidean distance in XY plane). However, I would like to know if there is any other approach to this problem, which does not approximate a rectangle by it's central point, but also takes the actual shape of the rectangle into consideration.