Last active
June 3, 2019 14:33
-
-
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
This file contains 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
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