Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change palette in streamtest.py #27

Open
kami83 opened this issue May 25, 2022 · 1 comment
Open

Change palette in streamtest.py #27

kami83 opened this issue May 25, 2022 · 1 comment

Comments

@kami83
Copy link

kami83 commented May 25, 2022

Hi,

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

Thanks a lot.

Best regards kami

@danjulio
Copy link
Owner

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants