I've some data that I can express as an image. Within this data I found some clusters (shown in the image below). I can just assign different colors to different clusters and visualize the image but if I do so randomly I lose the spatial relation that can be observed within the image.

Projection of my clusters into a 2D to visualize distances between them

To solve that in order to let close clusters have close colors I thought that a good solution might be to map this space into a color map (or the other way around)

Just to say I guess that I should use the color map such that in the center is black rather than white just for displaying purposes. (white marker in white canvas does not show up much ;) )

Color Space

A possible solution is to directly map the PCA of my centroids to 3D coordinate system and use this one to map HSV coloration.

enter image description here

Centroids nearby have similar coloration but differences in saturation and brightness does that nearby differ and are close to other centroids far away in the first two coordinates but close in the third one.

A solution is to use the same coordinate for saturation and brightness leading to this coloration (or even just use hue)

enter image description here

However clusters on the top can be easily differentiated meanwhile the clusters on the bottom they all look similar (dark). On the other hand using only hue it would lead to a reduced subset of colors. Saturation can be mapped as distance to the center but still, the color space is not properly used to have the best coloration.

The final goal is to re-project back into an image the coloration of the clusters to obtain a colored visualization of its texture, as follows:

enter image description here

  • $\begingroup$ please try to post the same question on stackoverflow or cross-validated. $\endgroup$
    – Avitus
    Commented Sep 3, 2013 at 12:42
  • $\begingroup$ Ditto what Avitus said. This isn't a question about mathematics. You'll have better luck at cross-validated, where people think about data visualization. $\endgroup$
    – rschwieb
    Commented Sep 3, 2013 at 13:04
  • 1
    $\begingroup$ Colours are fine, but why not use different symbols as well or instead? Different symbols e.g. $\diamond \circ +$ express qualitative contrasts well. On colour, remember that many people have difficulties distinguishing colours, especially red and green. $\endgroup$
    – Nick Cox
    Commented Sep 3, 2013 at 13:50
  • $\begingroup$ The idea is to be able to then use those colors to generate an image. Such clusters represent textures of my image, and i want to color every texture with a color. I can just do it randomly but the images look disturbing, and the sense of close and far texture gets lost. $\endgroup$
    – Sik
    Commented Sep 3, 2013 at 13:54
  • $\begingroup$ The question looks to be about colour visualization of densities, or clots, and not about clusters. Clusters are descrete classes, although some speak of 'overlapping' clusters as well. But in any case clusters cannot flow gradually into each other, as your fine coloration implies. Was the question ill-formulated? $\endgroup$
    – ttnphns
    Commented Sep 3, 2013 at 14:40

1 Answer 1


First of all, I don't see any meaningful clusters here. This looks like a forced quantization to me (typical for k-means) - the results may be all but meaningful.

Have you considered just using 1D or 2D projections, e.g. by doing multidimensional scaling? You might be aware that in HSV space, we can't really tell apart different hues, unless they are also well saturated and bright enough. So you might want to use a 2D projection to maximum saturation, and then use only values 0.5 to 1.0, plus the whole range of hues.

However, for HSV space, you'd need to project your data to a cone formed space, actually... RGB may be the better choice, because the axes may be more uniformly on what we can visually tell appart.

You may want to look at discussions such as this:


which focus on finding a good, user-friendly "colorful" palette. Don't neglect that you also need contrast to the background (or in computer games: to the landscape)

  • $\begingroup$ Well, that's actually what i did I extracted features from my image (actually i used SIFT) and then k-means to find 36 clusters to discretize the feature space. I'm preparing an illustrative example of how to characterize texture using SIFT and Bag-of-Words. 36 clusters is big enough and let us keep track of it. I was looking to colorize the SIFT image. Do you have any suggestion in order to cluster the space instead of using k-means? some mode-seeker methodology would be preferred? I've seen k-means be widely used for this application. $\endgroup$
    – Sik
    Commented Sep 3, 2013 at 18:51
  • $\begingroup$ The vectors should be sparse. I suggest you choose a fixed palette of 10 well-discernible colors, and assign them to the top 10 words for the image, and hide all the rare labels. If the resulting vectors are not sparse, the bag-of-words approach already failed. $\endgroup$ Commented Sep 3, 2013 at 21:07

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.