# Clustering data points based on edge strength

I'm looking at a Computer Vision application where I try to analyze the strength of edges a certain set of colors make with another color. For, this I take images of two colors falling on top of each other and record the edge strength (through a gradient) for a pair of colors.

Now, if I plot this edge strength graph for each color pair I get a graph like below: In the graph each point represents an edge strength between two colors, which are represented by a string two RGB tuples.

Based on this edge strength data I'd like to cluster the colors used into a k number of clusters. The clusters should group the colors such that the color pairs with low edge strength are grouped together, and color pairs that with high edge strength end up in different clusters. For example, if white and yellow have high edge strength, I want them to be in different clusters. If white and grey have low edge strength, I want them in the same cluster. Even though the data is between color pairs, I'd like to get a result where the cluster consists of a set of colors.

I thought this was straight forward with k means clustering, but since the data for color pairs and edge strength between two pairs, I cannot understand how to pre-process the data so that I can cluster the data and get colors as per my requirement. May I know how can I solve my problem with k-means or any other method?

Thanks in advance!

## 1 Answer

Edge strength is a similarity, isn't it?

You should thus be able to use any similarity or dissimilarity based algorithm, such as Hierarchical Agglomerative Clustering (HAC).

• This seems to work. I got it working in matlab, with the linkage function with the 'complete' distance metric. I'm usually aware of euclidean distance. Would you happen how this distance metric clusters my data? – dev_nut Apr 21 '15 at 1:58
• Do you have coordinates where "as the bird flies" is adequate? I doubt so. – Anony-Mousse Apr 21 '15 at 9:16
• I didn't understand you. I have the differences, not absolute coordinates. I'm using the method as 'complete' based on this page link. I'm trying to make sense of it without blindly using it. – dev_nut Apr 21 '15 at 17:21
• Euclidean distance is defined on coordinates. If you don't have coordinates, you can't compute euclidean distance. – Anony-Mousse Apr 21 '15 at 21:17