Package qupath.lib.color
Class ColorMaps
java.lang.Object
qupath.lib.color.ColorMaps
Helper class to manage colormaps, which are rather like lookup tables but easily support interpolation.
- Author:
- Pete Bankhead
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
colormap, which acts as an interpolating lookup table with an arbitrary range. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ColorMaps.ColorMap
createColorMap
(String name, double[] r, double[] g, double[] b) Create a colormap using floating point values for red, green and blue.static ColorMaps.ColorMap
createColorMap
(String name, int[] r, int[] g, int[] b) Create a colormap using integer values for red, green and blue.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.static ColorMaps.ColorMap
gammaColorMap
(ColorMaps.ColorMap map, double gamma) Apply gamma to a colormap.static Map
<String, ColorMaps.ColorMap> Get an unmodifiable map representing all the currently-available colormaps.static int[]
getColors
(ColorMaps.ColorMap map, int nValues, boolean doInvert) Get an array of packed RGB values for a specific colormap.static ColorMaps.ColorMap
Get a default, general-purposeColorMaps.ColorMap
.static boolean
installColorMaps
(Path... paths) Install colormaps from the specified paths.static boolean
installColorMaps
(ColorMaps.ColorMap... colorMaps) Install colormaps.static void
setDefaultColorMap
(ColorMaps.ColorMap colorMap) Set the defaultColorMaps.ColorMap
.
-
Constructor Details
-
ColorMaps
public ColorMaps()
-
-
Method Details
-
installColorMaps
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
Install colormaps.- Parameters:
colorMaps
- one or more colormaps.- Returns:
- true if changes were made, false otherwise
-
getColors
Get an array of packed RGB values for a specific colormap.- Parameters:
map
- the colormap providing colorsnValues
- the number of colors to extractdoInvert
- if true, reverse the order of the colors- Returns:
- an int array of length nValues
-
getDefaultColorMap
Get a default, general-purposeColorMaps.ColorMap
.- Returns:
- See Also:
-
setDefaultColorMap
Set the defaultColorMaps.ColorMap
.- Parameters:
colorMap
-- See Also:
-
getColorMaps
Get an unmodifiable map representing all the currently-available colormaps.- Returns:
- the available colormaps
-
createColorMap
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
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
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
Apply gamma to a colormap. The resulting colormap normalizes the input value according to the specified min and max, then appliesvalue = Math.pow(value, gamma)
before passing this to the wrappedColorMaps.ColorMap
.- Parameters:
map
- base colormapgamma
- gamma value- Returns:
- transformed colormap
-