/**
   * Gets an IndexColorModel by loading a hardcoded LUT file. This is just a temporary expedient,
   * really belongs elsewhere.
   *
   * @return null or color model
   */
  public static IndexColorModel getIndexColorModel() {
    IndexColorModel colorModel = null;

    // 'getDirectory("luts")' works in IJ but not in NetBeans development
    String lutPath = IJ.getDirectory("luts");
    if (null == lutPath) {
      // when you run from a shortcut in Linux 'getDirectory("startup")'
      // gives you the directory of the link!
      final String startupPath = IJ.getDirectory("startup");
      lutPath = addSeparator(startupPath) + "luts";
    }
    lutPath = addSeparator(lutPath) + LUT;
    try {
      colorModel = LutLoader.open(lutPath);
    } catch (final IOException e) {
      IJ.showMessage("Missing LUT", "Install lifetime.lut from LOCI FIJI update site.");
      IJ.log("Problem loading LUT " + lutPath);
      return null;
    }
    // IJ converts the FloatProcessor to 8-bits and then uses this palette
    // for display. Unfortunately values less than or greater than the LUT
    // range still get displayed with LUT colors. To work around this, use
    // only 254 of the LUT colors. The first and last colors will represent
    // values less than and greater than the LUT range respectively.

    colorModel = PaletteFix.fixIndexColorModel(colorModel, Color.BLACK, Color.BLACK);
    return colorModel;
  }
Example #2
0
 /**
  * Opens a lookup table (LUT) and returns it as a LUT object, or returns null if there is an
  * error.
  *
  * @see ij.ImagePlus#setLut
  */
 public static LUT openLut(String path) {
   return LutLoader.openLut(path);
 }