Skip to content

Instantly share code, notes, and snippets.

@nvladimus
Created May 8, 2023 09:01
Show Gist options
  • Save nvladimus/4497fd5d3019c3d9c748967b7fbda225 to your computer and use it in GitHub Desktop.
Save nvladimus/4497fd5d3019c3d9c748967b7fbda225 to your computer and use it in GitHub Desktop.
# Export your favorite Matplotlib colormap to Imaris look-up table (.pal file)
# Authors: ChatGPT and Nikita Vladimirov
# License: GPL3
import matplotlib.cm as cm
cmap = cm.get_cmap('plasma')
output_file = './plasma_palette_8bit.pal'
with open(output_file, 'w') as f:
# Write the RGB values of each color in the colormap as text strings
for i in range(256):
rgba = cmap(i)
rgb = [int(x * 255) for x in rgba[:3]]
f.write(f'{rgb[0]:.3f} {rgb[1]:.3f} {rgb[2]:.3f}\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment