Created
August 1, 2013 20:07
-
-
Save dwblair/6134758 to your computer and use it in GitHub Desktop.
Generating a LUT in the format "DN,R,G,B" from the colormap data structure used by matplotlib.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib as mpl | |
import matplotlib.cm as cm | |
import numpy as np | |
norm = mpl.colors.Normalize(vmin=0, vmax=255) | |
cmap = cm.spectral | |
m = cm.ScalarMappable(norm=norm, cmap=cmap) | |
for i in range(0,256): | |
vals=m.to_rgba(i) | |
print str(i) + "," + str(int(vals[0]*255)) + "," + str(int(vals[1]*255))+","+str(int(vals[2]*255)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment