Class ColorTransforms

java.lang.Object
qupath.lib.images.servers.ColorTransforms

public class ColorTransforms extends Object
Color transforms that may be used to extract single-channel images from BufferedImages. These are JSON-serializable, and therefore can be used with pixel classifiers.
  • Method Details

    • createChannelExtractor

      public static ColorTransforms.ColorTransform createChannelExtractor(int channel)
      Create a ColorTransform that extracts a channel based on its index.
      Parameters:
      channel - the index of the channel to extract. It must be 0-based, although the result of ColorTransforms.ColorTransform.getName() will be 1-based
      Returns:
      a ColorTransform extracting the provided channel
    • createChannelExtractor

      public static ColorTransforms.ColorTransform createChannelExtractor(String channelName)
      Create a ColorTransform that extracts a channel based on its name.
      Parameters:
      channelName - the name of the channel to extract
      Returns:
      a ColorTransform extracting the provided channel
    • createLinearCombinationChannelTransform

      public static ColorTransforms.ColorTransform createLinearCombinationChannelTransform(Map<String,? extends Number> coefficients)
      Create a ColorTransform that apply a linear combination to the channels. For example, calling this function with the Map {"c1": 0.5, "c3": 0.2} will create a new channel with values "0.5*c1 + 0.2*c3".
      Parameters:
      coefficients - the channel names mapped to coefficients
      Returns:
      a ColorTransform computing the provided linear combination
    • createLinearCombinationChannelTransform

      public static ColorTransforms.ColorTransform createLinearCombinationChannelTransform(List<? extends Number> coefficients)
      Create a ColorTransform that apply a linear combination to the channels. For example, calling this function with the list [0.5, 0.9] will create a new channel with values "0.5*firstChannel + 0.9*secondChannel".
      Parameters:
      coefficients - the list of coefficients to apply to each channel
      Returns:
      a ColorTransform computing the provided linear combination
    • createLinearCombinationChannelTransform

      public static ColorTransforms.ColorTransform createLinearCombinationChannelTransform(double... coefficients)
      Create a ColorTransform that apply a linear combination to the channels. For example, calling this function with the coefficients (0.5, 0.9) will create a new channel with values "0.5*firstChannel + 0.9*secondChannel".
      Parameters:
      coefficients - the coefficients to apply to each channel
      Returns:
      a ColorTransform computing the provided linear combination
    • createMeanChannelTransform

      public static ColorTransforms.ColorTransform createMeanChannelTransform()
      Create a ColorTransform that calculates the mean of all channels.
    • createMaximumChannelTransform

      public static ColorTransforms.ColorTransform createMaximumChannelTransform()
      Create a ColorTransform that calculates the maximum of all channels.
    • createMinimumChannelTransform

      public static ColorTransforms.ColorTransform createMinimumChannelTransform()
      Create a ColorTransform that calculates the minimum of all channels.
    • createColorDeconvolvedChannel

      public static ColorTransforms.ColorTransform createColorDeconvolvedChannel(ColorDeconvolutionStains stains, int stainNumber)
      Create a ColorTransform that applies color deconvolution. It only works on RGB images.
      Parameters:
      stains - the stains (this will be 'fixed', and not adapted for each image)
      stainNumber - number of the stain (1, 2 or 3)
      Returns:
      a ColorTransform applying color deconvolution with the provided parameters
      Throws:
      IllegalArgumentException - when the stain number is incorrect