Class ColorMaps

java.lang.Object
inra.ijpb.color.ColorMaps
Direct Known Subclasses:
ColorMaps

public class ColorMaps
extends java.lang.Object
Contains static methods for creating common color maps.
Author:
David Legland
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  ColorMaps.CommonLabelMaps
    A collection of color maps useful for displaying label images.
  • Method Summary

    Modifier and Type Method Description
    static byte[][] circularLut​(byte[][] baseLut, int nColors)
    Creates a cyclic LUT from base LUT values such that the result array has the specified number of colors.
    static java.awt.image.ColorModel createColorModel​(byte[][] cmap)
    Creates a Java.awt.image.ColorModel from a color map given as an triplet of byte arrays.
    static java.awt.image.ColorModel createColorModel​(byte[][] cmap, java.awt.Color bg)
    Creates a Java.awt.image.ColorModel from a color map given as an triplet of byte arrays, and a color for the background that will be associated to label 0.
    static byte[][] createFireLut()
    Creates a byte array representing the Fire LUT.
    static byte[][] createFireLut​(int nColors)
    Creates a byte array representing the Fire LUT.
    static byte[][] createGlasbeyBrightLut()
    Create lookup table with a maximally distinct sets of colors, retaining only colors with high luminance, making it useful for displaying categorical data or label maps over a black background.
    static byte[][] createGlasbeyDarkLut()
    Create lookup table with a maximally distinct sets of colors, retaining only colors with low luminance, making it useful for displaying categorical data or label maps over a white background.
    static byte[][] createGlasbeyLut()
    Create lookup table with a maximally distinct sets of colors (copied from Fiji's Glasbey LUT).
    static byte[][] createGoldenAngleLut​(int nColors)
    Make lookup table with esthetically pleasing colors based on the golden angle
    static byte[][] createGrayLut()
    Creates a byte array representing the gray LUT.
    static byte[][] createIceLut()
    Creates a byte array representing the Ice LUT.
    static byte[][] createIceLut​(int nColors)
    Creates a byte array representing the Ice LUT.
    static byte[][] createJetLut()
    Creates a byte array representing the Jet LUT.
    static byte[][] createJetLut​(int nColors)
    Creates a byte array representing the Jet LUT.
    static byte[][] createMainColorsLut()
    Returns a LUT with only the 6 main colors.
    static byte[][] createMixedColorsLut()
    Returns a LUT with only the main colors and their mixture.
    static byte[][] createRedGreenLut()
    Creates a byte array representing a color gradient from red to green.
    static byte[][] createRGB332Lut()
    Creates a byte array representing the RGB332 LUT.
    static byte[][] createSpectrumLut()
    Creates a byte array representing the Spectrum LUT.
    static byte[][] interpolateLut​(byte[][] baseLut, int nColors)
    Interpolates between LUT values such that the result array has the specified number of colors.
    static byte[][] shuffleLut​(byte[][] lut)
    Creates a new LUT by applying a random permutation to the colors within the original LUT.
    static byte[][] shuffleLut​(byte[][] lut, long seed)
    Shuffles the LUT, using the specified seed for initializing the random generator.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • createColorModel

      public static final java.awt.image.ColorModel createColorModel​(byte[][] cmap)
      Creates a Java.awt.image.ColorModel from a color map given as an triplet of byte arrays.
      Parameters:
      cmap - a colormap given as a triplet of byte arrays
      Returns:
      the corresponding color model
    • createColorModel

      public static final java.awt.image.ColorModel createColorModel​(byte[][] cmap, java.awt.Color bg)
      Creates a Java.awt.image.ColorModel from a color map given as an triplet of byte arrays, and a color for the background that will be associated to label 0.
      Parameters:
      cmap - a colormap given as a triplet of byte arrays
      bg - the color associated to the background
      Returns:
      the corresponding color model
    • createFireLut

      public static final byte[][] createFireLut​(int nColors)
      Creates a byte array representing the Fire LUT.
      Parameters:
      nColors - number of colors
      Returns:
      a nColors-by-3 array of color components.
    • createFireLut

      public static final byte[][] createFireLut()
      Creates a byte array representing the Fire LUT.
      Returns:
      an array of color components.
    • createGlasbeyLut

      public static final byte[][] createGlasbeyLut()
      Create lookup table with a maximally distinct sets of colors (copied from Fiji's Glasbey LUT). Reference: [1] Glasbey, Chris, Gerie van der Heijden, Vivian FK Toh, and Alision Gray. "Colour displays for categorical images." Color Research & Application 32, no. 4 (2007): 304-309.
      Returns:
      Glasbey lookup table
    • createGlasbeyDarkLut

      public static final byte[][] createGlasbeyDarkLut()
      Create lookup table with a maximally distinct sets of colors, retaining only colors with low luminance, making it useful for displaying categorical data or label maps over a white background. References:
      Returns:
      Dark Glasbey lookup table with 256 entries
    • createGlasbeyBrightLut

      public static final byte[][] createGlasbeyBrightLut()
      Create lookup table with a maximally distinct sets of colors, retaining only colors with high luminance, making it useful for displaying categorical data or label maps over a black background. References:
      Returns:
      Dark Glasbey lookup table with 256 entries
    • createGoldenAngleLut

      public static final byte[][] createGoldenAngleLut​(int nColors)
      Make lookup table with esthetically pleasing colors based on the golden angle
      Parameters:
      nColors - number of colors to generate
      Returns:
      lookup table with golden-angled-based colors
    • createGrayLut

      public static final byte[][] createGrayLut()
      Creates a byte array representing the gray LUT.
      Returns:
      a nColors-by-3 array of color components.
    • createJetLut

      public static final byte[][] createJetLut​(int nColors)
      Creates a byte array representing the Jet LUT.
      Parameters:
      nColors - number of colors
      Returns:
      a nColors-by-3 array of color components.
    • createJetLut

      public static final byte[][] createJetLut()
      Creates a byte array representing the Jet LUT.
      Returns:
      a 256-by-3 array of color components.
    • createIceLut

      public static final byte[][] createIceLut​(int nColors)
      Creates a byte array representing the Ice LUT.
      Parameters:
      nColors - number of colors
      Returns:
      a nColors-by-3 array of color components.
    • createIceLut

      public static final byte[][] createIceLut()
      Creates a byte array representing the Ice LUT.
      Returns:
      a nColors-by-3 array of color components.
    • createSpectrumLut

      public static final byte[][] createSpectrumLut()
      Creates a byte array representing the Spectrum LUT.
      Returns:
      a 256-by-3 array of color components.
    • createRGB332Lut

      public static final byte[][] createRGB332Lut()
      Creates a byte array representing the RGB332 LUT.
      Returns:
      a nColors-by-3 array of color components.
    • createRedGreenLut

      public static final byte[][] createRedGreenLut()
      Creates a byte array representing a color gradient from red to green.
      Returns:
      a 256-by-3 array of color components.
    • createMainColorsLut

      public static final byte[][] createMainColorsLut()
      Returns a LUT with only the 6 main colors.
      Returns:
      the created LUT
    • createMixedColorsLut

      public static final byte[][] createMixedColorsLut()
      Returns a LUT with only the main colors and their mixture.
      Returns:
      the created LUT
    • interpolateLut

      public static final byte[][] interpolateLut​(byte[][] baseLut, int nColors)
      Interpolates between LUT values such that the result array has the specified number of colors.
      Parameters:
      baseLut - the LUT to interpolated
      nColors - the number of colors of the new LUT
      Returns:
      a nColors-by-3 array of color components
    • circularLut

      public static final byte[][] circularLut​(byte[][] baseLut, int nColors)
      Creates a cyclic LUT from base LUT values such that the result array has the specified number of colors.
      Parameters:
      baseLut - the LUT to sample colors from
      nColors - the number of colors of the new LUT
      Returns:
      a nColors-by-3 array of color components
    • shuffleLut

      public static final byte[][] shuffleLut​(byte[][] lut)
      Creates a new LUT by applying a random permutation to the colors within the original LUT.
      Parameters:
      lut - the LUT to sample colors from
      Returns:
      the new LUT
    • shuffleLut

      public static final byte[][] shuffleLut​(byte[][] lut, long seed)
      Shuffles the LUT, using the specified seed for initializing the random generator.
      Parameters:
      lut - the initial values of the look-up table
      seed - the value used to initialize the random number generator
      Returns:
      the randomly shuffled look-up table