Package qupath.lib.gui.tools
Class MeasurementMapper
java.lang.Object
qupath.lib.gui.tools.MeasurementMapper
Helpers class that can be used to map an object's measurement to a color (packed RGB int).
By passing a collection of objects, the minimum and maximum of all the measurements are found and these used to determine the lookup table scaling; alternative minimum and maximum values can also be set to override these extrema.
- Author:
- Pete Bankhead
-
Constructor Summary
ConstructorDescriptionMeasurementMapper
(ColorMaps.ColorMap mapper, String measurement, Collection<? extends PathObject> pathObjects) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiongetColorForObject
(PathObject pathObject) Get the display color for a specified object, according to the settings of this mapper.Get the color mapper, which is effectively a lookup table.double
Get the maximum measurement value from the objects passed to the constructor of this mapper.double
Get the minimum measurement value from the objects passed to the constructor of this mapper.double
Get the measurement value that maps to the last color in the color mapper.double
Get the measurement value that maps to the first color in the color mapper.boolean
Returns true if objects with values outside the specified min/max range have the min/max colors returned, false if null should be returned instead.protected double
getUsefulValue
(PathObject pathObject, double nanValue) boolean
isValid()
Query if the mapper is valid.void
setColorMapper
(ColorMaps.ColorMap mapper) Set a new color mapper.void
setDisplayMaxValue
(double maxValue) Set the measurement value that maps to the last color in the color mapper.void
setDisplayMinValue
(double minValue) Set the measurement value that maps to the first color in the color mapper.void
setExcludeOutsideRange
(boolean excludeOutsideRange) Specify whether out-of-range values should be excluded.
-
Constructor Details
-
MeasurementMapper
public MeasurementMapper(ColorMaps.ColorMap mapper, String measurement, Collection<? extends PathObject> pathObjects) Constructor.- Parameters:
mapper
- color mapper (lookup table)measurement
- the measurement to colorizepathObjects
- an initial collection of objects used to determine display ranges (i.e. find the min/max values of the specified measurement)
-
-
Method Details
-
setColorMapper
Set a new color mapper.- Parameters:
mapper
-
-
getExcludeOutsideRange
public boolean getExcludeOutsideRange()Returns true if objects with values outside the specified min/max range have the min/max colors returned, false if null should be returned instead.- Returns:
-
setExcludeOutsideRange
public void setExcludeOutsideRange(boolean excludeOutsideRange) Specify whether out-of-range values should be excluded.- Parameters:
excludeOutsideRange
-
-
isValid
public boolean isValid()Query if the mapper is valid. This returns true if the mapper has been initialized with objects to determine an appropriate display range.- Returns:
-
getColorForObject
Get the display color for a specified object, according to the settings of this mapper.- Parameters:
pathObject
-- Returns:
-
getUsefulValue
-
getColorMapper
Get the color mapper, which is effectively a lookup table.- Returns:
-
getDataMinValue
public double getDataMinValue()Get the minimum measurement value from the objects passed to the constructor of this mapper.- Returns:
-
getDataMaxValue
public double getDataMaxValue()Get the maximum measurement value from the objects passed to the constructor of this mapper.- Returns:
-
setDisplayMinValue
public void setDisplayMinValue(double minValue) Set the measurement value that maps to the first color in the color mapper.- Parameters:
minValue
-
-
setDisplayMaxValue
public void setDisplayMaxValue(double maxValue) Set the measurement value that maps to the last color in the color mapper.- Parameters:
maxValue
-
-
getDisplayMinValue
public double getDisplayMinValue()Get the measurement value that maps to the first color in the color mapper.- Returns:
-
getDisplayMaxValue
public double getDisplayMaxValue()Get the measurement value that maps to the last color in the color mapper.- Returns:
-