Simple color detection

Hi, I’m trying to detect primary, secondary and black/white colors in specific x-y pixel locations. If I have the 8-bit RGB values from get_pixel(x, y) I can just run it through

def convert_to_1bRGB(r, g, b):
return (r // 128, g // 128, b // 128)

and get a simple 1-bit RGB tuplet that seems to work fine for now where (0,0,0) = black, (1,1,1) = white, (0,0,0) = mostly blue, etc., etc.

How could I show the reduced 8-color palette on the LCD shield instead of RGB565?

Hi, you should use the gamma() method which can just apply a gain of to the whole image. In this case the gain would be (1/128). Then you could apply another gamma() again to get pixels back to 0-255. Then just draw that to the screen.

Alternatively, you could also create a color lookup table that maps the grayscale value of the image to a new color system. This will be far more efficient. All the drawing methods accept a color lookup table.