Decoding Emotion and Coding to Color
My mother is an interior designer and she loves color.
Being this way she taught me that every color conveys an emotion, and even more than that, color carries with it energy that is subtly picked up by the viewer. As a Developer, the correlation of emotion and color has always fascinated me, so I decided to finally try and put both my interest in color and my interest in words together.
The idea is simple, parse out “emotion” from text and then from there translate those emotions into color. Simple right?! I am not going to go into getting the emotion from text, at least not in this post – this post will focus on how I derived a formula to figure out the translation of emotion to color.
First I defined some base emotions to find a pattern, these emotions are: pleased, subdued, unhappy, aggressive, excited, relaxed :

Using my fancy color picker in Photoshop, I found the Red Green and Blue ( RGB ) for each of those emotions. While doing this I quickly noticed a pattern in these colors, either they were a strong representation of a base color – 255 – or low representation – 0 – and if they were kind of neutral – 51 . Thus, using the table above – I came up with the RGB values below:
- pleased : [0,255,255], // no R. strong G. strong B.
- subdued : [51,0,255], // med R. no G. strong B.
- unhappy : [255,0,255], // strong R. no G. strong B.
- agressive : [255,0,0], //strong R. no G. no B.
- excited : [255,255,51], // strong R. strong G. no B.
- relaxed : [51,255,51], // med R. strong G. med b
Once I had this list, I broke it down into a table of all the emotions and their intensity of either Red, Green, or Blue. A Strong Red emotion contained: Aggressive, Excited, and Unhappy. All terms that are rather extreme – so I correlated Extreme emotions with a Strong ( 255 ) Red. I did this with each Red, Green and Blue until I was able to map out key feelings of a color.
All this research left me with a general idea of how this would work in code. Each emotion would be represented in RGB – and each of colors would hold one of three values : 0, 51, and 255. From there I would be able to decide and create a table of emotion and color values . . .
A couple of examples – the word “happy” . . . Red which is aggressive we could say is 255, Green which is a relaxed and neutral color would also be 255, and Blue which is a high emotion color would be 0. Our color :
Lets try “die” -easy enough – if you are dead, you are nothing – no color : R: 0, G: 0, B: 0 Our result:
So now I have a large database of emotion and color, it took a bit of time, but I think I am satisfied with the results. When I parse in text, I pull out all the common words: “a”, “the”, “an” etc. and from there I match up words from the text with words I have in the database – I average out each color value – and I tend to have a good representation of the general emotion of the text.
A quick example : “ I will be so happy when you die” – our emotions are happy and die. Red : ( 255 + 0 ) / 2 = 127, Green: ( 255 + 0 ) / 2 = 127, and Blue: ( 0 + 0 ) / 2 = 0 . . . so we have the RGB values of 127, 127, 0 – our result:
I think a nice gut puke color sums up that statement quite well.
On a final note – the colors are bias to how I feel about each emotion, but on general I think most people agree with what I have chosen. Since I am using this in a sorta secret at the moment project, I cannot go into much more detail . . . in future posts I will make sure to cover the code I use to do this.
Categorized as Random