Skip to content

Instantly share code, notes, and snippets.

@quantixed
Last active June 3, 2019 14:33
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 quantixed/8e7fe0dff9282a2a70f4028b9d484f87 to your computer and use it in GitHub Desktop.
Save quantixed/8e7fe0dff9282a2a70f4028b9d484f87 to your computer and use it in GitHub Desktop.
Export all look-up tables (LUTs) in FIJI to four column text format
function lutValuesToTable(filePath) {
getLut(reds, greens, blues);
tableTitle = "lutValueTable";
eightBit = 256;
run("Table...", "name=["+tableTitle+"] width=600 height=250");
print("["+tableTitle+"]", "\\Headings:Index\tRed\tGreen\tBlue");
for (i = 0; i < eightBit; i ++) {
rowString = d2s(i,0) + "\t" + reds[i] + "\t" + greens[i] + "\t" + blues[i];
print("["+tableTitle+"]", rowString);
}
selectWindow(tableTitle);
saveAs("results",filePath);
close(tableTitle);
}
dirPath = getDirectory("Select a directory");
// Create the output folder
fileDirPath = dirPath + "LutTSVs" + File.separator;
File.makeDirectory(fileDirPath);
lutdirname = "luts";
lutdir = getDirectory("startup") + lutdirname + File.separator;
if (!File.exists(lutdir))
exit("The 'luts' folder not found in the ImageJ folder");
list = getFileList(lutdir);
setBatchMode(true);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], ".lut")) {
//selectWindow("ramp");
open(lutdir+list[i]);
filePath = fileDirPath + list[i];
lutValuesToTable(filePath);
}
}
close();
setBatchMode(false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment