True Colors

Author: Carlos Gomez Grajales

My favorite color is White. I know, I'm weird. I'm also a huge fan of Red, which makes sense since Red is one of the top two favorite colors of all people, Blue being the absolute favorite. I still prefer Red, as most rulers in the world seem to do: approximately 77% of all flags include red. Compare that with the 53% of flags which contain blue and it is an easy win.

Color is everywhere, it is common and so relatable that we don't demand a definition of color, yet the origins of our multi-colored vision are quiet interesting. Color is usually described as a feeling. Most light sources emit light at many different wavelengths. These wavelengths and their intensity are the origin of colors. The spectrum of light arriving at the eye from a given direction determines the color sensation that is produced in the viewer. The reason why humans are able to distinguish colors is based upon the varying sensitivity of different sections in the retina to light of different wavelengths. The retina contains three types of color receptor cells, or cones. One type is most responsive to light that we perceive as violet with wavelengths around 420 nm. Another one is most sensitive to light we perceive as greenish yellow, with wavelengths around 564 nm. The other type is most sensitive to light perceived as green, with wavelengths around 534 nm. In briefing, light is always reduced to three color components by the human eye, which is the basis of our trichromatic world. Not all animals share this limitation though; some species of spiders, marsupials, birds, and fish have four types of color receptors. Some insects, such as bees, can perceive ultraviolet light, which is invisible to humans. These allow them to uncover colors and patterns that are hidden from human vision. You can see some really cool pictures depicting that difference in this link.

Although some believe talking about colors may be shallow, it is actually a recurrent subject in science. Many studies deal with the psychological effects of colors, in order to detect the most arousing, or depressing colors. Some suggest colors affect our judgements, particularly when choosing products or food. Blue, for instance, may act as an appetite suppressant. So, if color is so important for science, we should do what we do with important things in life: generate stats about them! I mean, poverty, unemployment, health, happiness, those are all important issues, that's why we try to measure all of them. As we have seen, color is an important matter too, so why not doing graphs about it? Well, I have some great news. I'm not the first one with the idea: statisticians have been working with colors for a long time.

Numbers have become a powerful way to represent images and colors. Nowadays, every digital image is composed by pixels. You know, those really, really tiny squares that see when you max out the zoom. Every single pixel has a single color or tone, and the whole bunch of pixels together create a digital image. For instance, we have this beautiful sunflower:

Histogram made of Sunflower image using Paint Shop Pro.

Even the tiny flowers in the back look precious!

What? That is a sunflower! More exactly, the Image Histogram of a sunflower. This graph represents the many different tones and colors within an image. The horizontal axis represents each of the tonal variations visible in the image and the vertical axis represents the number of pixels that share that particular tone. Image histograms are commonly seen in digital cameras and almost every image editor software allows to produce and modify this type of histograms. This representation of an image not only allows to visually analyze the composition of the colors but also is quiet useful for modifying and improving the image itself.

Other techniques also rely on statistics to improve coloring in images. Color mapping is an application that repaints the colors of an image based on the pattern of another image. For instance, let's say we have the before snapshot, which looks a bit dark. If we had another picture where the colors were appropriately portraited, we could use it as a reference image to improve the coloring. The result is a picture where the colors are appropriately represented. The algorithm that produces this extreme image makeover is called Histogram Matching, since it is based in modifying those image histograms we just talked about. The basic idea is to modify the histogram of the “before” picture in order to make it look like the one of the reference image. Some modifications of the algorithm even adjust mean and standard deviation of the histograms to improve the results.

Before

Reference Image

After

I can already hear all those graphic designers claiming: Just give me Photoshop and I can do that! I don't need histograms! But the sweet part of color mapping is that the algorithm is automatic, so it can be used as part of other algorithms. For instance, object recognition software often tends to have problems with lighting and colors. A computer may detect differences in color as two different objects, a problem that color matching may help to prevent. As you can see, statistics are quiet useful for working with colors. And we haven't even talked about RGB yet!

Well, RGB, is the name of a color model. In this additive model, colors Red, Green and Blue are added in order to produce an immense array of colors, in a process similar to that of the human eye. Some cool property of RGB is that any color produced can be easily represented by a coordinate of numbers. Any color is expressed as an RGB triplet (R,G,B), each component of which can vary from zero to a defined maximum value. If all the components are at zero the result is black; if all are at maximum, the result is the brightest representable white. As you can imagine, these three coordinates can be represented in a three-dimensional space, as Cartesian coordinates. When the colors are located in this Euclidean space, some cool stuff can be done, such as matching similar colors based on the Euclidean distance among them. Believe it or not, measuring color difference is a subject of interest to color science.

And that's not all. There are some really cool applications that involve some “heavy” statistics. Xuezhong Xiao and Lizhuang Ma, from the Computer Science & Engineering Department of the Shanghai Jiao Tong University proposed a new technique for color transferring based in multivariate statistics. Color transferring is quiet similar to color mapping, just that instead of using a reference image of the same object, you take as a reference any different image with a different coloring. For instance, I may have a beautiful photograph of me and my girlfriend taken in my backyard at 2:00 p.m. By using color transferring, I can change the coloring and lighting of that picture in order to make it look like it was taken at noon, by using a reference image of a beautiful sunset scene in the beach. As you can imagine, since the reference and the “before” picture are totally different, color mapping will not work for this. What Xiao and Ma proposed is quiet interesting: They consider every single pixel as a three-dimension stochastic variable and an image as a set of samples. They then obtained a covariance matrix for those variables, which was the decomposed using SVD, an algorithm common in many statistical techniques such as Principal Component Analysis, Correspondence maps and almost any other multivariate technique. By doing this, they get a rotation matrix which is used to transform the pixels of an image in the current color space and get a different image with different coloring, look and feel. That's the closest I've seen to painting with statistics!

Colors are a big part of ourselves, an underlying artpiece within our world. That's why we have statistics working on them, because the important things in life are worth studying in numbers.

Bookmark and Share

Comment on this article

Submit your comment
  1. Image of unique ID

Skip to Main Site Navigation / Login

Site Search Form

Site Search