danjulio / lepton

Code and libraries to use a FLIR Lepton Thermal Imaging Camera Module
179 stars 37 forks source link

Change palette in streamtest.py #27

Open kami83 opened 2 years ago

kami83 commented 2 years ago

Hi,

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

Thanks a lot.

Best regards kami

danjulio commented 2 years ago

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]