Class DirectServerChannelInfo

java.lang.Object
qupath.lib.display.DirectServerChannelInfo
All Implemented Interfaces:
ChannelDisplayInfo, ChannelDisplayInfo.ModifiableChannelDisplayInfo, SingleChannelDisplayInfo

public class DirectServerChannelInfo extends Object
ChannelInfo intended for use with a single or multichannel image (possibly fluorescence) where the pixel's value is used to scale a single color according to a specified display range according to the following rules:
  • If the pixel's value is >= maxDisplay, the pure color is used.
  • If the pixel's value is <= minDisplay, the black is used.
  • Otherwise, a scaled version of the color is used
The end result is like having a lookup table (LUT) that stretches from black to the 'pure' color specified, but without actually generating the LUT.
Author:
Pete Bankhead
  • Field Details

    • df

      protected static final DecimalFormat df
    • CM_GRAYSCALE

      protected static final IndexColorModel CM_GRAYSCALE
    • CM_GRAYSCALE_INVERTED

      protected static final IndexColorModel CM_GRAYSCALE_INVERTED
    • minAllowed

      protected float minAllowed
    • maxAllowed

      protected float maxAllowed
    • minDisplay

      protected float minDisplay
    • maxDisplay

      protected float maxDisplay
    • clipToAllowed

      protected boolean clipToAllowed
  • Constructor Details

    • DirectServerChannelInfo

      public DirectServerChannelInfo(ImageData<BufferedImage> imageData, int channel)
      Constructor.
      Parameters:
      imageData - the image
      channel - the channel number (0-based index)
  • Method Details

    • getChannel

      public int getChannel()
      Get the channel number.
      Returns:
    • getName

      public String getName()
      Description copied from interface: ChannelDisplayInfo
      Get the channel name. This may also be returned by the toString() method.
      Returns:
    • getColorModel

      protected ColorModel getColorModel(ChannelDisplayMode mode)
      Get a ColorModel to use with a specified ChannelDisplayMode when converting a value to RGB.
      Parameters:
      mode -
      Returns:
    • setLUTColor

      public void setLUTColor(int r, int g, int b)
      Set the 'maximum' color, which defines the lookup table to use.
      Parameters:
      r - red component (0-255)
      g - green component (0-255)
      b - blue component (0-255)
    • getValue

      public float getValue(BufferedImage img, int x, int y)
      Description copied from interface: SingleChannelDisplayInfo
      Extract the value for a single pixel of an image.
      Parameters:
      img - the image
      x - x-coordinate of the pixel
      y - y-coordinate of the pixel
      Returns:
      the value of the pixel
    • getValues

      public float[] getValues(BufferedImage img, int x, int y, int w, int h, float[] array)
      Description copied from interface: SingleChannelDisplayInfo
      Extract values for a square of pixels from an image.
      Parameters:
      img - the image
      x - x-coordinate of the top left corner of the region to extract
      y - y-coordinate of the top left corner of the region to extract
      w - width of the region to extract
      h - height of the region to extract
      array - optional array that may be used to store the output values
      Returns:
      array of values
    • doesSomething

      public boolean doesSomething()
      Description copied from interface: ChannelDisplayInfo
      Returns true if this does something - anything - and false otherwise. For example, this will return false if we have an RGB image with no transformations of any kind applied (e.g. brightness/contrast)
      Returns:
    • isAdditive

      public boolean isAdditive()
      Description copied from interface: ChannelDisplayInfo
      Returns true if this channel can be used additively to create a composite image display; returns false if this channel wants all the color information to itself, so can't be displayed with others.
      Returns:
    • getColor

      public Integer getColor()
      Description copied from interface: ChannelDisplayInfo
      Predominate color used when this ChannelDisplayInfo uses a Color LUT (e.g. Color.RED for a red channel). Returns null if there is no appropriate color choice, or the image is RGB.
      Returns:
    • isMutable

      public boolean isMutable()
      Description copied from interface: SingleChannelDisplayInfo
      Check if SingleChannelDisplayInfo.getValue(BufferedImage, int, int) returns fixed values, or if they are dependent on other properties of the ImageData.

      For example, a transform based on color deconvolution should be flagged as mutable because stain vectors change, while a simple channel separation is not considered mutable (since the pixel values for the underlying image remain constant in QuPath).

      Returns:
    • getRGB

      public int getRGB(float value, ChannelDisplayMode mode)
      Get a suitable RGB value for displaying a pixel with the specified value
      Parameters:
      value -
      mode -
      Returns:
    • getRGB

      public int getRGB(BufferedImage img, int x, int y, ChannelDisplayMode mode)
      Description copied from interface: ChannelDisplayInfo
      Get the RGB value that would be used to display a particular pixel
      Specified by:
      getRGB in interface ChannelDisplayInfo
      Parameters:
      img -
      x -
      y -
      mode -
      Returns:
    • getValueAsString

      public String getValueAsString(BufferedImage img, int x, int y)
      Description copied from interface: ChannelDisplayInfo
      Get a string representation of a pixel's value. This might be a single number, or 3 numbers for an RGB image where the channel includes all values.
      Specified by:
      getValueAsString in interface ChannelDisplayInfo
      Parameters:
      img -
      x -
      y -
      Returns:
    • getRGB

      public int[] getRGB(BufferedImage img, int[] rgb, ChannelDisplayMode mode)
      Description copied from interface: ChannelDisplayInfo
      Get the RGB values that would be used to display all the pixels of an image
      Specified by:
      getRGB in interface ChannelDisplayInfo
      Parameters:
      img -
      rgb -
      mode -
      Returns:
    • updateRGBAdditive

      public void updateRGBAdditive(BufferedImage img, int[] rgb, ChannelDisplayMode mode)
      Description copied from interface: ChannelDisplayInfo
      Update an array of existing pixels (packed RGB) additively using the colors to display a specified image. May throw an UnsupportedOperationException if isAdditive() returns false;
      Specified by:
      updateRGBAdditive in interface ChannelDisplayInfo
      Parameters:
      img -
      rgb -
      mode -
    • getImageData

      protected ImageData<BufferedImage> getImageData()
    • getImageServer

      protected ImageServer<BufferedImage> getImageServer()
    • setMinMaxAllowed

      public void setMinMaxAllowed(float minAllowed, float maxAllowed)
      Description copied from interface: ChannelDisplayInfo.ModifiableChannelDisplayInfo
      Set the maximum permissible range for the image display.

      For an 8-bit image, that should be 0 and 255.

      For a 16-bit image, fewer bits might actually be used... therefore the full range of 0-2^16-1 may be too much.

      Also, for a 32-bit floating point image the limits are rather harder to define in a general way. This method makes it possible to restrict the permissible range to something sensible. Brightness/contrast/min/max sliders may make use of this.

      Specified by:
      setMinMaxAllowed in interface ChannelDisplayInfo.ModifiableChannelDisplayInfo
      Parameters:
      minAllowed -
      maxAllowed -
    • isBrightnessContrastRescaled

      public boolean isBrightnessContrastRescaled()
      Description copied from interface: ChannelDisplayInfo
      Returns true if rescaling according to min & max display levels is applied, false if the full display range is used.
      Specified by:
      isBrightnessContrastRescaled in interface ChannelDisplayInfo
      Returns:
    • setMinDisplay

      public void setMinDisplay(float minDisplay)
      Description copied from interface: ChannelDisplayInfo.ModifiableChannelDisplayInfo
      Set the min display value for this channel. Note that it is *strongly* advised to use ImageDisplay.setMinMaxDisplay instead since this helps ensure that the ImageDisplay fires appropriate events etc.
      Specified by:
      setMinDisplay in interface ChannelDisplayInfo.ModifiableChannelDisplayInfo
      Parameters:
      minDisplay -
      See Also:
    • setMaxDisplay

      public void setMaxDisplay(float maxDisplay)
      Description copied from interface: ChannelDisplayInfo.ModifiableChannelDisplayInfo
      Set the max display value for this channel. Note that it is *strongly* advised to use ImageDisplay.setMinMaxDisplay instead since this helps ensure that the ImageDisplay fires appropriate events etc.
      Specified by:
      setMaxDisplay in interface ChannelDisplayInfo.ModifiableChannelDisplayInfo
      Parameters:
      maxDisplay -
      See Also:
    • getMinAllowed

      public float getMinAllowed()
      Description copied from interface: ChannelDisplayInfo
      Get the min allowed display value. This is only a hint.
      Specified by:
      getMinAllowed in interface ChannelDisplayInfo
      Returns:
    • getMaxAllowed

      public float getMaxAllowed()
      Description copied from interface: ChannelDisplayInfo
      Get the max allowed display value. This is only a hint.
      Specified by:
      getMaxAllowed in interface ChannelDisplayInfo
      Returns:
    • getMinDisplay

      public float getMinDisplay()
      Description copied from interface: ChannelDisplayInfo
      Get the min display value. This is used to control the brightness/contrast when painting.
      Specified by:
      getMinDisplay in interface ChannelDisplayInfo
      Returns:
    • getMaxDisplay

      public float getMaxDisplay()
      Description copied from interface: ChannelDisplayInfo
      Get the max display value. This is used to control the brightness/contrast when painting.
      Specified by:
      getMaxDisplay in interface ChannelDisplayInfo
      Returns:
    • updateRGBAdditive

      public int updateRGBAdditive(BufferedImage img, int x, int y, int rgb, ChannelDisplayMode mode)
      Description copied from interface: ChannelDisplayInfo
      Update an existing pixel (packed RGB) additively using the color used to display a specified one
      Specified by:
      updateRGBAdditive in interface ChannelDisplayInfo
      Parameters:
      img -
      x -
      y -
      rgb -
      mode -
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object