represent vector as a color

This isn't specifically a MATLAB question, although a solution in MATLAB would be nice (if there is a solution).
Lets say I have some vectors, say '<1,2,7,6,10> and '<3,4,6,1,4>.
Is there any way to represent each of these vectors as a single color? I am looking for a way to "color" n-dimensional vectors with a single color - I'm not sure that it's possible.

3 Comments

What do you mean single color? If there is only one color, how do you tell the difference?
I mean a single color for each vector. '<1,2,7,6,10> and '<3,4,6,1,4> would each have different colors based on their elements. In reality I would be trying to do this for hundreds, if not thousands of vectors.
The goal would be to have vectors with similar elements to have similar colors. '<1,2,7,6,10> and '<1.1, 1.9, 7, 6.1, 9.9> would be "closer" in color than '<1,2,7,6,10> and '<3,4,6,1,4>. But looking at Walter Roberson's answer below, this may be hard to do in any practical way.
pcolor() will show that vector [1,2,7,6,10] and [1.1, 1.9, 7, 6.1, 9.9] are similar but of course they contain multiple color grids.

Sign in to comment.

 Accepted Answer

Walter Roberson
Walter Roberson on 1 Sep 2011
If your n is 7 or higher and your vector components have infinite variability (not limited to a strictly finite set of values), then there is no known way to do what you ask.
For n=5 or 6, you might be able to use one of the LAB* representations of color and convert to RGB. But possibly only if some of the components have fixed maximum values.
For n=4, you could use CMYK and convert to RGB, but possibly only if some of the components have fixed maximum values.
If each of the components of your n dimensional vectors is discrete and has a maximum value (so all the possible values at that component could be written out in a finite list), then no matter how many dimensions you had, you could map the vector in to a unique RGB value. Only the other hand, few people have the equivalent of "absolute pitch" when it comes to color (humans are much better at distinguishing differences in colors). It is more or less the case that once you get beyond about 3000 different colors (3000 different distinct vectors in your case) that it becomes useless unless you have calibrated equipment and trained observers and controlled conditions.

6 Comments

The values of the components of the vectors will not necessarily be discrete. But I will be able to find the minimum and maximum values for each component of the vector. That is, each component occurs in a within some finite range. As I mentioned above there are likely to be thousands of vectors of n-dimensions.
I did some further research. I am NOT a color specialist, so I might have missed something in my searching.
Earlier I indicated that for n = 5 or 6 you might be able to use one of the LAB* representations of colors. (The reference should have been to CIE* rather than LAB*). I have looked over the some CIE representations and CIE appears to be strictly a 3-component representation in all of its variations.
CMYK is a subtractive four-component representation whereas most other representations are additive representations. CMYK is intended for printing. CMYK can be mostly mapped to RGB such as is used in most displays, but some CMYK tones fall a bit outside of what standard RGB can represent.
There is a 6 color extension of CMYK that adds light cyan and light magenta. These do not, however, increase the theoretical color range: they are a work-around to printing-specific problems having to do with half-toning light colors.
Likewise, CMYK is not really a theoretical extension to a 3 color process based upon cyan, magenta, and yellow: it is a practical extension to get dark enough tones when there are practical limits on the amount of ink that can be applied to any one spot.
Human color vision is fundamentally a 3 frequency process for the perception of "color" itself; although such a process cannot adequately represent the human eye's reaction to intensity, neither can any kind of standard computer display.
Human vision does also have rods, which are not sensitive to color but are excellent photodetectors in low-light conditions. The brightness range over which one can effectively stimulate both rods and cones is fairly small, nearly unreachable on computer displays.
So.... what we are left with is that you can map an N-dimensional vector in to a "color" uniquely if and only if you can find a unique mapping from each number in the N-dimensional space in to the 3 dimensional space of non-negative numbers.
One of the first problems you are going to encounter is that all modern color displays are digital and have a finite number of pixel colors that can be transferred from the graphics card to the display. This eliminates the possibility of uniquely mapping non-discrete vectors in to *representable* colors, even if you were starting from a 1D vector.
The next question then becomes, "Is it possible to uniquely map every coordinate in an continuous N>3 dimensional space to a coordinate in a continuous 3 dimensional space? The theoretical answer to that is YES, because if it were not possible then the size of the number of points in N continuous dimensions would have to be greater than the size of the number of points in one continuous dimension, Aleph-One, the number of reals, but no such larger infinity has ever been found and it is thought that Aleph-One is the largest infinity possible.
The obvious next question is, "Okay, so *how* do I do that mapping?". And that is something I do not know at the moment. I have a partial construction floating around in my head, but I need to flesh it out further.
A question after that would be "Will 'similar' vectors in the original space map in to 'similar' numbers in 3D space?" The answer to that depend greatly on how you define the "similarity" of vectors in the original space. I seem to recall reading a number of years ago that when an N dimensional space is projected in to a smaller dimensional space, that it can be proven that there will have to be numbers that are "close together" in the original space but which will end up arbitrarily far apart in the projected space.
Thanks for the info Walter. At least it gives me some idea of what I might be able to do. This is really just another way of representing data observations (vectors) from a cluster analysis. It might OK if some colors are alike and it is hard to differentiate between the colors of vectors within a cluster as long as the colors of vectors in two different clusters where noticeably different. Though I'm sure this could get a bit messy if there were a both a high number of vectors and clusters.
Map clusters to colors arbitrarily: cluster #1 -> color #1 . Every vector in a particular cluster to the same color, rather than trying to use the numeric values of the vector components to select the color directly.
Your limit would then be number of clusters vs number of colors that are "noticeably different" even when not side by side. I'm not sure that is really going to be much more than 100-ish (each color component at 0, 1/4, 1/2, 3/4, 1), maybe not more than 64.
@Walter, you have a lot going on here. Most of it seems on the right path. Quick proof for distance in reduced dimensionality. In 2-D space an equilateral triangle has 3 points that are equally far away from each other, if you project that to 1-D space the three points can no longer be equally far away from each other.
Good example for distance in reduced dimensionality.
Still, Craig talked about "similarity" rather than "distance". If Craig _defined_ the "similarity" of all vectors to be a constant, then after projection downward the "similarity" could remain constant. The necessity that similarity will change thus depends upon the definition of "similarity". It seems to me to be plausible that there might be sufficiently strange geometries (e.g., of a fractal nature) in which it is not possible to define "distance" in any of the usual senses. My projective answers were based just upon counting arguments, not upon specific definitions of "distance".
Don't mind me; I haven't had a chance yet this morning to step out to the corner store and buy an argument.

Sign in to comment.

More Answers (1)

Daniel Shub
Daniel Shub on 2 Sep 2011
As Walter said, color is a three dimensional precept. Printers use CMYK to generate there colors, but all this means is that there are multiple was of combining inks to produce the same color. Monitors work with RGB. There are a number of ways of reducing the dimensionality of your data set (clustering is one and principal component analysis is another). It seems like you have a grasp on this.
Basically you need to map from a N-D space to a 3-D space. You then want to map from the 3-D space to a color space. A trivial mapping would be to use the magnitude of each of the 3 dimensions to drive the R/G/B of your monitor. Unfortunately, this will result in a warped color space: some points which are close in your 3D space will be perceptually very different and some points which are far apart in you 3D space will be perceptually similar. A better mapping would be to use an LMS color space. Ideally, this would be done with a calibrated monitor, but that is probably overkill.
It looks like: href=""<http://www.mathworks.com/matlabcentral/fileexchange/28790-colorspace-transformations</a>>
can convert RGB to LMS.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!