MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / LutLoader

Class LutLoader

ij/src/main/java/ij/plugin/LutLoader.java:19–463  ·  view source on GitHub ↗

Opens NIH Image look-up tables (LUTs), 768 byte binary LUTs (256 reds, 256 greens and 256 blues), LUTs in text format, or generates the LUT specified by the string argument passed to the run() method.

Source from the content-addressed store, hash-verified

17 or generates the LUT specified by the string argument
18 passed to the run() method. */
19public class LutLoader extends ImagePlus implements PlugIn {
20
21 private static String defaultDirectory = null;
22 private boolean suppressErrors;
23
24 /** Returns the LUT 'name' as an IndexColorModel, where
25 * 'name' can be any entry in the Image/Lookup Tables menu.
26 * @see ij.IJ#getLuts
27 * See: Help>Examples>JavaScript/Show all LUTs
28 */
29 public static IndexColorModel getLut(String name) {
30 if (name==null) return null;
31 LutLoader ll = new LutLoader();
32 FileInfo fi = ll.getBuiltInLut(name.toLowerCase());
33 if (fi.fileName!=null)
34 return new IndexColorModel(8, 256, fi.reds, fi.greens, fi.blues);
35 String path = IJ.getDir("luts")+name+".lut";
36 IndexColorModel lut = LutLoader.openLut("noerror:"+path);
37 if (lut==null) {
38 path = IJ.getDir("luts")+name.replaceAll(" ","_")+".lut";
39 lut = LutLoader.openLut("noerror:"+path);
40 }
41 return lut;
42 }
43
44 /** If 'arg'="", displays a file open dialog and opens the specified
45 LUT. If 'arg' is a path, opens the LUT specified by the path. If
46 'arg'="fire", "ice", etc., uses a method to generate the LUT. */
47 public void run(String arg) {
48 if (arg.equals("invert")) {
49 invertLut();
50 return;
51 }
52
53 // Built in LUT
54 FileInfo fi = getBuiltInLut(arg);
55 if (fi.fileName!=null) {
56 showLut(fi, true);
57 Menus.updateMenus();
58 return;
59 }
60
61 // LUT in luts folder
62 OpenDialog od = new OpenDialog("Open LUT...", arg);
63 fi.directory = od.getDirectory();
64 fi.fileName = od.getFileName();
65 if (fi.fileName==null)
66 return;
67 if (openLut(fi))
68 showLut(fi, arg.equals(""));
69 IJ.showStatus("");
70 }
71
72 private FileInfo getBuiltInLut(String name) {
73 FileInfo fi = new FileInfo();
74 fi.reds = new byte[256];
75 fi.greens = new byte[256];
76 fi.blues = new byte[256];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected