# Devising a mixed strength cost function for clustering

I'm asking this question with a Computer Vision background (my stat background is limited). I have a set of data that measure the edge strength (based on color gradient) of a set of colors.

Since these was some sort of similarity measure, based on the answer to this question I posted earlier, I ran HAC and got some results. Then, I calculate the mean edge strength of each cluster with its std. deviation.

    (mean)     (#)    (std. dev)
13.9970   11.0000    1.2536 --- medium strength edge strength cluster
21.6859    1.0000         0
22.3964    1.0000         0
23.1407    1.0000         0
25.6370    1.0000         0
26.1904    1.0000         0
19.5371    2.0000    0.2155
3.2880    7.0000    1.7849 --- very low edge strength cluster
25.3500    2.0000    1.4310


These results make sense naturally, as the ones with low edge strength are grouped together.

My actual requirement, is to get a number of clusters (k), that would nicely mix the low edge strength ones with higher edge ones, so that the colors with low edge strength will have a good chance of getting recognized as an edge. I was wondering is there a way to define some cost function so that I can get these sort of clusters, instead of just getting clusters that group based on overall edge strength.

Essentially, if I want 3 clusters, I'd like the best possible 3 clusters (within a certain number of iterations) such that the edge strengths are mixed to get the best possible results.

I think understand that I would have to define my own cost function for this to pre-process the data. But, I'm at a loss as to how to define such a cost function. Any help here is much appreciated.

Note: The actual data after being pre-processed to a symmetrical square matrix is available at this link, for anyone who's interested. I directly feed this to HAC through the matlab linkage function using the 'single' method. matlab hac documentation