Wednesday, July 31, 2013

Hue Sort

My project is too big for a regular spreadsheet but not quite ready for a relational database. After testing the waters of the Python Imaging Library, I've settled on a file system to organize my colors. Six top level folders named Red, Orange, Yellow, Green, Blue, and Purple each have sixty subfolders. This allots one folder for each of the 360 hues in the color wheel. I'm going to name each of these 360 hues myself, and ask my viewers to name as many of the 16,777,216 unique hex colors as possible.

But I just hit a stumbling block. The 360 major computer generated hues do not fall neatly into 6 categories of 60. I made a little program to draw swatches for each hue so I could name them all; I was hoping to end up with a column for each ROYGBP. I shifted the spectrum so the hues were offset by 30 which helped a bit, but not much. There's too much Green, and not enough Yellow.

The visible spectrum image from Wikipedia looks much more balanced. I wonder if it's rendered in something more attuned to this than Processing, or if the person who generated it did some lerping. Either way, I don't think I'm going to use the Processing hues as the second tier of my color hierarchy. I'll hand-pick them. I'll deal with Magenta (which occurs in the color wheel but not the rainbow) by splitting it across Red and Purple.

Below the Wikipedia image are the spectrums from Processing and the ColorPy library I will be using in the near future. ColorPy is better, but still not great. Computer screens are a matrix of Red, Green & Blue LEDs— displaying secondary and composite colors by blending and gamma correction— which might also account for the Yellow deficit. I look forward to building my own spectrum, and finding the paint and light equivalents.

Thursday, July 25, 2013

Pair Programming

Tom and I did some pair programming last week: he drove (wrote the code) and I navigated (dictated instructions). What we ended up with (link to GitHub) was something that crawls through text looking for color words. It divides the text into lines, and the lines into words. Any time the words red, orange, yellow, green, blue, or purple come up, the other words in that line are filed into a matrix. Once the algorithm is finished, it returns the set of words that have more than one correlation. For example, given the text, The Loves of Krishna in Indian Painting and Poetry by W. G. Archer, the program returned this:

The only really interesting result here is that Krishna is indeed blue (the literal translation of the name is "black" or "dark" but most depictions give him blue skin). It's singular, but still very exciting. One text is too small a dataset, so I'm building up some compilations of my favorite poets, transcendentalists, aesthetic philosophers, etc. I'll also tokenize the text by sentence rather than line (except in poems), and weigh the associated words by how close they are to the color word (so that in the line, red shoes by the newsstand, shoes gets more points than newsstand). I'll also add the words color/s and colour/s.

The results improved dramatically when I added words like black, dark, white, and light. These words are used much more often, particularly in metaphor. It occurred to me to start collecting those for Nila, my black and white painting robot, and I'm thrilled with the idea.

Thursday, July 18, 2013

Neko's Brain Trust

On Monday, Neko and I were successfully funded on Kickstarter! It's tremendously exciting and I can't thank my supporters enough. I just put in a big motor order and look forward to a minor rebuild. As for software, there are two things I'm now teaching Neko: how to select a digital color given a set of words, and how to select pigments to represent that digital color. My new vocabulary for the day is distributional semantics. This is a practice based on the idea that words with similar distributions have similar definitions; "You shall know a word by the company it keeps." I'm building a text crawler that will look for my six core words— Red, Orange, Yellow, Green, Blue, Purple— and find words that are highly collocated with each. I'm picking out old public domain books to walk through, and would love suggestions on books that have high frequency of these words. While I'm waiting for the new motors to arrive, I'll put all the most-associated words into my database. Some of the Kickstarter funds will be allocated to a Mechanical Turk bid, though I'm not sure quite what to ask yet.
The second task is matching the pigments to the colors on-screen. For this I've ordered a color sensor which Neko can use to compare what's on the palette to the target color. I've picked a set of mixing pigments— Cadmium Red Medium, Cadmium Yellow Lemon, and Phthalo Blue— to be Neko's go-to adjusters.