Class ColorMaps

java.lang.Object
qupath.lib.color.ColorMaps

public class ColorMaps extends Object
Helper class to manage colormaps, which are rather like lookup tables but easily support interpolation.
Author:
Pete Bankhead
  • Constructor Details

    • ColorMaps

      public ColorMaps()
  • Method Details

    • installColorMaps

      public static boolean installColorMaps(Path... paths)
      Install colormaps from the specified paths.
      Parameters:
      paths - optional paths containing either .tsv files containing colormaps, or directories that contain such .tsv files.
      Returns:
      true if changes were made, false otherwise
    • installColorMaps

      public static boolean installColorMaps(ColorMaps.ColorMap... colorMaps)
      Install colormaps.
      Parameters:
      colorMaps - one or more colormaps.
      Returns:
      true if changes were made, false otherwise
    • getColors

      public static int[] getColors(ColorMaps.ColorMap map, int nValues, boolean doInvert)
      Get an array of packed RGB values for a specific colormap.
      Parameters:
      map - the colormap providing colors
      nValues - the number of colors to extract
      doInvert - if true, reverse the order of the colors
      Returns:
      an int array of length nValues
    • getDefaultColorMap

      public static ColorMaps.ColorMap getDefaultColorMap()
      Get a default, general-purpose ColorMaps.ColorMap.
      Returns:
      See Also:
    • setDefaultColorMap

      public static void setDefaultColorMap(ColorMaps.ColorMap colorMap)
      Set the default ColorMaps.ColorMap.
      Parameters:
      colorMap -
      See Also:
    • getColorMaps

      public static Map<String,ColorMaps.ColorMap> getColorMaps()
      Get an unmodifiable map representing all the currently-available colormaps.
      Returns:
      the available colormaps
    • createColorMap

      public static ColorMaps.ColorMap createColorMap(String name, double[] r, double[] g, double[] b)
      Create a colormap using floating point values for red, green and blue. These should be in the range 0-1.
      Parameters:
      name -
      r -
      g -
      b -
      Returns:
    • createColorMap

      public static ColorMaps.ColorMap createColorMap(String name, int[] r, int[] g, int[] b)
      Create a colormap using integer values for red, green and blue. These should be in the range 0-255.
      Parameters:
      name -
      r -
      g -
      b -
      Returns:
    • createColorMap

      public static ColorMaps.ColorMap createColorMap(String name, int r, int g, int b)
      Create a colormap using int values for red, green and blue corresponding to the maximum value; the minimum color will be black. These should be in the range 0-255.
      Parameters:
      name -
      r -
      g -
      b -
      Returns:
    • gammaColorMap

      public static ColorMaps.ColorMap gammaColorMap(ColorMaps.ColorMap map, double gamma)
      Apply gamma to a colormap. The resulting colormap normalizes the input value according to the specified min and max, then applies value = Math.pow(value, gamma) before passing this to the wrapped ColorMaps.ColorMap.
      Parameters:
      map - base colormap
      gamma - gamma value
      Returns:
      transformed colormap