How to group contours in close proximity to each other?

clustering is right. flann might be useful in this situation. I disagree with k-means, since there is no k here.

maybe you want to use mean shift.