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:

color pairs vs edge strength

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 1


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).

  • $\begingroup$ 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? $\endgroup$
    – dev_nut
    Commented Apr 21, 2015 at 1:58
  • $\begingroup$ Do you have coordinates where "as the bird flies" is adequate? I doubt so. $\endgroup$ Commented Apr 21, 2015 at 9:16
  • $\begingroup$ 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. $\endgroup$
    – dev_nut
    Commented Apr 21, 2015 at 17:21
  • $\begingroup$ Euclidean distance is defined on coordinates. If you don't have coordinates, you can't compute euclidean distance. $\endgroup$ Commented Apr 21, 2015 at 21:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.