lepton icon indicating copy to clipboard operation
lepton copied to clipboard

Change palette in streamtest.py

Open kami83 opened this issue 3 years ago • 1 comments

Hi,

can you also show an example with changing the color palette for the stream?

Thanks a lot.

Best regards kami

kami83 avatar May 25 '22 15:05 kami83

Sorry this fell through the cracks. You can use a palette to colorize the image as follows. For example to use the rainbow palette.

At the top of the demo include the palette

   from palettes import rainbow_palette

Then index the palette when building the image. Replace

        if val > 255:
            a[r, c] = [255, 255, 255]
        else:
            a[r, c] = [val, val, val]

with

        if val > 255:
            a[r, c] = rainbow_palette[255]
        else:
            a[r, c] = rainbow_palette[val]

danjulio avatar Jul 19 '22 03:07 danjulio