Package qupath.lib.images.servers
Class ColorTransforms
java.lang.Object
qupath.lib.images.servers.ColorTransforms
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Interface defining a color transform that can extract a float value from a BufferedImage.static class
TypeAdapter
to support serializing aColorTransforms.ColorTransform
. -
Method Summary
Modifier and TypeMethodDescriptioncreateChannelExtractor
(int channel) Create a ColorTransform that extracts a channel based on its index.createChannelExtractor
(String channelName) Create a ColorTransform that extracts a channel based on its name.createColorDeconvolvedChannel
(ColorDeconvolutionStains stains, int stainNumber) Create a ColorTransform that applies color deconvolution.createLinearCombinationChannelTransform
(double... coefficients) Create a ColorTransform that apply a linear combination to the channels.createLinearCombinationChannelTransform
(List<? extends Number> coefficients) Create a ColorTransform that apply a linear combination to the channels.createLinearCombinationChannelTransform
(Map<String, ? extends Number> coefficients) Create a ColorTransform that apply a linear combination to the channels.Create a ColorTransform that calculates the maximum of all channels.Create a ColorTransform that calculates the mean of all channels.Create a ColorTransform that calculates the minimum of all channels.
-
Method Details
-
createChannelExtractor
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 ofColorTransforms.ColorTransform.getName()
will be 1-based- Returns:
- a ColorTransform extracting the provided channel
-
createChannelExtractor
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
Create a ColorTransform that calculates the mean of all channels. -
createMaximumChannelTransform
Create a ColorTransform that calculates the maximum of all channels. -
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
-