[Image-SIG] 3-bit color palette

Gokce Taskan gokcetaskan at gmail.com
Sun Mar 30 01:28:41 CET 2008


I've been searching all over the internet for a method to convert an 
image to a 8 color (3-bit) image. I've used these:

Based on brightness but not good results:
palette = []
for i in range(32):
    palette.extend([0, 0, 0])
for i in range(32):
    palette.extend([0, 0, 255])
for i in range(32):
    palette.extend([0, 255, 0])
for i in range(32):
    palette.extend([0, 255, 255])
for i in range(32):
    palette.extend([255, 0, 0])
for i in range(32):
    palette.extend([255, 0, 255])
for i in range(32):
    palette.extend([255, 255, 0])
for i in range(32):
    palette.extend([255, 255, 255])

Outputs a grayscale image because it fills the rest of the palette with 
black, grays and whites:
palette = [(0,0,0)] * 8
palette[1] = (0, 0, 255)
palette[2] = (0, 255, 0)
palette[3] = (0, 255, 255)
palette[4] = (255, 0, 0)
palette[5] = (255, 0, 255)
palette[6] = (255, 255, 0)
palette[7] = (255, 255, 255)

I am trying find a method to output a resonable image which would look 
like the one in
http://en.wikipedia.org/wiki/List_of_monochrome_and_RGB_palettes#3-bit_RGB

Do you have any advices?

Thank you,

Gokce



More information about the Image-SIG mailing list