Class ColorMapper
- Direct Known Subclasses:
AnnotationMapper,GraphColorMapper,NodeColorMapper,TreeColorMapper
- Author:
- Tiago Ferreira
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected net.imglib2.display.ColorTableprotected booleanprotected net.imagej.lut.LUTServiceprotected doubleprotected double -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the subset ofgetAvailableLuts()recognized as heatmap LUTs, matched case-insensitively and loosely against a curated list of known heatmap names.Gets the available LUTs, as recognized bygetColorTable(String): every LUT bundled with Fiji (viaLUTService), in addition to the handful of "core" namesColorMaps.get(String)resolves directly (e.g.getColor(double mappedValue) Gets the color corresponding to the specified mapped value.org.scijava.util.ColorRGBgetColorRGB(double mappedValue) Gets the color corresponding to the specified mapped value as ColorRGB.net.imglib2.display.ColorTableGets the current color table used for mapping.net.imglib2.display.ColorTablegetColorTable(String lut) Resolves a LUT (color table) by name.double[]Returns the mapping boundsGets the color used for NaN (Not a Number) values.protected voidinitLuts()booleanChecks if the color mapping uses an integer scale.voidSets up the color mapping for the specified measurement using the given color table.voidsetMaxPercentileClipped(double[] values, double clipPercent) One-sided companion tosetMinMaxPercentileClipped(double[], double): sets only the upper bound, to the(100-clipPercent)th percentile ofvalues, leaving the lower bound untouched.voidsetMinMax(double min, double max) Sets the LUT mapping bounds.voidsetMinMaxPercentileClipped(double[] values, double clipPercent) Sets the LUT mapping bounds to a percentile-clipped range ofvalues, curbing the influence of long-tailed outliers on the color scale.voidsetMinPercentileClipped(double[] values, double clipPercent) One-sided companion tosetMinMaxPercentileClipped(double[], double): sets only the lower bound, to theclipPercentth percentile ofvalues, leaving the upper bound untouched.voidsetNaNColor(Color nanColor) Sets the color to use for NaN (Not a Number) values.static voidunMap(Collection<Path> paths) Removes color mapping from the specified collection of paths.static voidRemoves color mapping from all paths in the specified tree.
-
Field Details
-
lutService
protected net.imagej.lut.LUTService lutService -
luts
-
colorTable
protected net.imglib2.display.ColorTable colorTable -
integerScale
protected boolean integerScale -
min
protected double min -
max
protected double max
-
-
Constructor Details
-
ColorMapper
public ColorMapper()
-
-
Method Details
-
map
Sets up the color mapping for the specified measurement using the given color table.This method configures the ColorMapper to use the specified measurement and color table for mapping values to colors. The actual mapping implementation is left to extending classes.
- Parameters:
measurement- the measurement to be mappedcolorTable- the color table to use for mapping- Throws:
IllegalArgumentException- if colorTable or measurement is null
-
getNaNColor
Gets the color used for NaN (Not a Number) values.Returns the color that will be used when mapping NaN values, which cannot be mapped to the regular color scale.
- Returns:
- the color for NaN values
-
setNaNColor
Sets the color to use for NaN (Not a Number) values.Specifies the color that should be used when mapping NaN values, which cannot be mapped to the regular color scale.
- Parameters:
nanColor- the color to use for NaN values
-
getColor
Gets the color corresponding to the specified mapped value.Maps the given value to a color using the current color table and mapping bounds. Returns the NaN color if the value is NaN.
- Parameters:
mappedValue- the value to map to a color- Returns:
- the corresponding color
-
getColorRGB
public org.scijava.util.ColorRGB getColorRGB(double mappedValue) Gets the color corresponding to the specified mapped value as ColorRGB.- Parameters:
mappedValue- the value to map to a color- Returns:
- the corresponding ColorRGB
- See Also:
-
setMinMax
public void setMinMax(double min, double max) Sets the LUT mapping bounds.- Parameters:
min- the mapping lower bound (i.e., the highest measurement value for the LUT scale). It is automatically calculated (the default) when set to Double.NaNmax- the mapping upper bound (i.e., the highest measurement value for the LUT scale).It is automatically calculated (the default) when set to Double.NaN.
-
setMinMaxPercentileClipped
public void setMinMaxPercentileClipped(double[] values, double clipPercent) Sets the LUT mapping bounds to a percentile-clipped range ofvalues, curbing the influence of long-tailed outliers on the color scale. Plain min-max bounds let a single extreme value (e.g. one path length far outside the rest of the arbor) stretch the whole range, crushing every other mapped value into a narrow, near-indistinguishable band. This clips both ends to a percentile window instead: values beyond it still render as the coldest/hottest color (clamped, not discarded -- seegetColor(double)) but no longer decide where that window sits. Same convention assc.fiji.snt.seed.SeedConfidence#percentileClipNormalize(double[], double), used throughout SNT's seed detectors for the identical long-tail problem.- Parameters:
values- the raw values driving this mapping (e.g., a metric read across every mapped node/path).NaNentries are ignored;nullor all-NaN leaves the current bounds unchanged.clipPercent- percentile clip width, clamped to[0, 45](0recovers plain min-max)
-
setMinPercentileClipped
public void setMinPercentileClipped(double[] values, double clipPercent) One-sided companion tosetMinMaxPercentileClipped(double[], double): sets only the lower bound, to theclipPercentth percentile ofvalues, leaving the upper bound untouched. Useful when only one end of the scale should adapt to the data -- e.g. pairing this with a fixed, caller-chosen upper bound (orsetMaxPercentileClipped(double[], double)for the other combination). UnlikesetMinMax(double, double), this does not validate against the current upper bound, since that bound may not have been set yet -- callers combining both ends should finish with a plainsetMinMax(double, double)(orgetMinMax()-checked call) once both are known.- Parameters:
values- assetMinMaxPercentileClipped(double[], double)clipPercent- percentile clip width, clamped to[0, 45](0= the plain minimum)
-
setMaxPercentileClipped
public void setMaxPercentileClipped(double[] values, double clipPercent) One-sided companion tosetMinMaxPercentileClipped(double[], double): sets only the upper bound, to the(100-clipPercent)th percentile ofvalues, leaving the lower bound untouched. SeesetMinPercentileClipped(double[], double)for the other combination and the caveat about validating the final range once both bounds are known.- Parameters:
values- assetMinMaxPercentileClipped(double[], double)clipPercent- percentile clip width, clamped to[0, 45](0= the plain maximum)
-
isIntegerScale
public boolean isIntegerScale()Checks if the color mapping uses an integer scale.Returns true if the mapping is configured to use discrete integer values rather than continuous floating-point values.
- Returns:
- true if using integer scale, false for continuous scale
-
getMinMax
public double[] getMinMax()Returns the mapping bounds- Returns:
- a two-element array with current {minimum, maximum} mapping bounds
-
getColorTable
public net.imglib2.display.ColorTable getColorTable()Gets the current color table used for mapping.Returns the ColorTable instance that defines the color mapping from values to colors.
- Returns:
- the current color table
-
initLuts
protected void initLuts() -
getAvailableLuts
Gets the available LUTs, as recognized bygetColorTable(String): every LUT bundled with Fiji (viaLUTService), in addition to the handful of "core" namesColorMaps.get(String)resolves directly (e.g. "viridis", "fire", "ice") without needing the LUTService lookup.- Returns:
- the set of keys, corresponding to the set of LUTs available
-
getAvailableHeatmapLuts
Gets the subset ofgetAvailableLuts()recognized as heatmap LUTs, matched case-insensitively and loosely against a curated list of known heatmap names. Absent LUTs are simply not returned, since availability depends on the running Fiji install- Returns:
- the heatmap subset of
getAvailableLuts()
-
getColorTable
Resolves a LUT (color table) by name. Tries the small set of "core" names known toColorMaps.get(String)first (e.g. "viridis", "fire", "ice" -- no LUTService round-trip needed), then falls back to a substring match against every LUT bundled with Fiji, as reported bygetAvailableLuts().- Parameters:
lut- the LUT name, or a substring of one ofgetAvailableLuts()'s entries (e.g. "mpl-viridis.lut")- Returns:
- the matching color table, or null if no match was found
-
unMap
Removes color mapping from all paths in the specified tree.Resets the color of all paths in the tree to their default state, effectively removing any color mapping that was previously applied.
- Parameters:
tree- the tree whose paths should have color mapping removed
-
unMap
Removes color mapping from the specified collection of paths.Resets the color of all paths in the collection to their default state, effectively removing any color mapping that was previously applied. This includes both path-level and node-level color assignments.
- Parameters:
paths- the collection of paths to have color mapping removed
-