Skip to content

Instantly share code, notes, and snippets.

@mutterer
Created August 13, 2015 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mutterer/97dafaf6bb2988945f6c to your computer and use it in GitHub Desktop.
Save mutterer/97dafaf6bb2988945f6c to your computer and use it in GitHub Desktop.
// grab the Viridis (option-d) colormap from Berkeley Institute for Data Science GitHub repo
// and parse it to an ImageJ LUT
// Viridis colormap presented @ SciPy 2015 by Nathaniel Smith and Stéfan van der Walt
s=File.openUrlAsString("https://raw.githubusercontent.com/BIDS/colormap/master/option_d.py");
s=substring(s,indexOf(s,"[[")+1,indexOf(s,"]]")+1);
s=replace(s,'\n\n','\n');
s=replace(s,' ','');
s=split(s,'\n');
length = s.length;
reds = newArray(length);
greens = newArray(length);
blues = newArray(length);
for (i=0;i<s.length;i++) {
l=split(substring (s[i],1,lengthOf(s[i])-2),',');
reds[i] = 255*l[0];
greens[i] = 255*l[1];
blues[i] = 255*l[2];
}
run("Bridge (174K)");
setLut(reds, greens, blues);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment