Class MeasurementMapper

java.lang.Object
qupath.lib.gui.tools.MeasurementMapper

public class MeasurementMapper extends Object
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 Details

    • MeasurementMapper

      public MeasurementMapper(ColorMaps.ColorMap mapper, String measurement, Collection<? extends PathObject> pathObjects)
      Constructor.
      Parameters:
      mapper - color mapper (lookup table)
      measurement - the measurement to colorize
      pathObjects - an initial collection of objects used to determine display ranges (i.e. find the min/max values of the specified measurement)
  • Method Details

    • setColorMapper

      public void setColorMapper(ColorMaps.ColorMap mapper)
      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

      public Integer getColorForObject(PathObject pathObject)
      Get the display color for a specified object, according to the settings of this mapper.
      Parameters:
      pathObject -
      Returns:
    • getUsefulValue

      protected double getUsefulValue(PathObject pathObject, double nanValue)
    • getColorMapper

      public ColorMaps.ColorMap 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: