Python

Using python to sort the colors by luminance, generating a luminance pattern and picking the most appropriate color. The pixels are iterated in random order so that the less favorable luminance matches that naturally happen when the list of available colors gets smaller are evenly spread throughout the picture.
#!/usr/bin/env python
from PIL import Image
from math import pi, sin, cos
import random
WIDTH = 256
HEIGHT = 128
img = Image.new("RGB", (WIDTH, HEIGHT))
colors = [(x >> 10, (x >> 5) & 31, x & 31) for x in range(32768)]
colors = [(x[0] << 3, x[1] << 3, x[2] << 3) for x in colors]
colors.sort(key=lambda x: x[0] * 0.2126 + x[1] * 0.7152 + x[2] * 0.0722)
def get_pixel(lum):
for i in range(len(colors)):
c = colors[i]
if c[0] * 0.2126 + c[1] * 0.7152 + c[2] * 0.0722 > lum:
break
return colors.pop(i)
def plasma(x, y):
x -= WIDTH / 2
p = sin(pi * x / (32 + 10 * sin(y * pi / 32)))
p *= cos(pi * y / 64)
return 128 + 127 * p
xy = []
for x in range(WIDTH):
for y in range(HEIGHT):
xy.append((x, y))
random.shuffle(xy)
count = 0
for x, y in xy:
l = int(plasma(x, y))
img.putpixel((x, y), get_pixel(plasma(x, y)))
count += 1
if not count & 255:
print "%d pixels rendered" % count
img.save("test.png")