Monday, April 21, 2014

Building a Color Space

There are several major systems for defining color, each well-suited to different needs. RGB is the default for computer screens; each pixel is basically made up of a red, green, and blue LED. CMYK (cyan, magenta, yellow, black) are the ink colors which produce the best gamut for printers. CIE XYZ accounts for the green-dominance in human sight.

For me and Neko, hue is central. Hue is the relationship between primaries— a pale cherry red and a dark cherry red share a hue. I found this little algorithm for converting RGB is HSV (hue, saturation/white, value/black), and wanted to make a note of it for the future.

// r,g,b values are from 0 to 1
// h = [0,360], s = [0,1], v = [0,1]
//  if s == 0, then h = -1 (undefined)
void RGBtoHSV( float r, float g, float b, float *h, float *s, float *v )
 float min, max, delta;
 min = MIN( r, g, b );
 max = MAX( r, g, b );
 *v = max;    // v
 delta = max - min;
 if( max != 0 )
  *s = delta / max;  // s
 else {
  // r = g = b = 0  // s = 0, v is undefined
  *s = 0;
  *h = -1;
 if( r == max )
  *h = ( g - b ) / delta;  // between yellow & magenta
 else if( g == max )
  *h = 2 + ( b - r ) / delta; // between cyan & yellow
  *h = 4 + ( r - g ) / delta; // between magenta & cyan
 *h *= 60;    // degrees
 if( *h < 0 )
  *h += 360;

Once I have completed Neko's new set of pigment swatches, I will assign each pigment to a specific hue. When Neko has a target digital hue, he can refer to that database to find the closest pigments. Our color system is also growing in text references to each pigment, so word associations can be made as well.

Edit 4/23: Found this comprehensive color system website today.

Thursday, January 23, 2014

Neko 2.2


For my needs, the accelerometer and gyroscope gave both too much and too little information. I decided to scrap the locational sensors and use mild trigonometry. Using the ultrasonic sensor as a guide for keeping the brush on the canvas did work quite well, so I might reinstall that. I'm testing out a color sensor, cameras and lights now that the arm is working smoothly.


I'm expanding my text-based approach after reading the wonderful novel Galatea 2.2, by Richard Powers. Instead of just looking for color words in texts about art, I want Neko to do freer association on a larger corpus. I'm still going to be selective about the texts I incorporate, but I liked the relationship Powers' narrator had with his machine.


This is the firmware that's running in the video. This was just a piece of test code, but I really like the motion it makes. I don't want it to get too rigid and boring, treating the painting as a 2D grid. I want to find the kind of strokes Neko is good at. I'm starting to think of it like a dance: programmed sequences of graceful motion, recombined.
Click to expand