Package qupath.lib.display
Class DirectServerChannelInfo
java.lang.Object
qupath.lib.display.DirectServerChannelInfo
- All Implemented Interfaces:
ChannelDisplayInfo,ChannelDisplayInfo.ModifiableChannelDisplayInfo,SingleChannelDisplayInfo
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface qupath.lib.display.ChannelDisplayInfo
ChannelDisplayInfo.ModifiableChannelDisplayInfo -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected static final IndexColorModelprotected static final IndexColorModelprotected static final DecimalFormatprotected floatprotected floatprotected floatprotected float -
Constructor Summary
ConstructorsConstructorDescriptionDirectServerChannelInfo(ImageData<BufferedImage> imageData, int channel) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if this does something - anything - and false otherwise.intGet the channel number.getColor()Predominate color used when this ChannelDisplayInfo uses a Color LUT (e.g.protected ColorModelGet aColorModelto use with a specifiedChannelDisplayModewhen converting a value to RGB.protected ImageData<BufferedImage> protected ImageServer<BufferedImage> floatGet the max allowed display value.floatGet the max display value.floatGet the min allowed display value.floatGet the min display value.getName()Get the channel name.Get the original channel name, extracted for the current ImageData if available.intgetRGB(float value, ChannelDisplayMode mode) Get a suitable RGB value for displaying a pixel with the specified valueint[]getRGB(BufferedImage img, int[] rgb, ChannelDisplayMode mode) Get the RGB values that would be used to display all the pixels of an imageintgetRGB(BufferedImage img, int x, int y, ChannelDisplayMode mode) Get the RGB value that would be used to display a particular pixelfloatgetValue(BufferedImage img, int x, int y) Extract the value for a single pixel of an image.getValueAsString(BufferedImage img, int x, int y) Get a string representation of a pixel's value.float[]getValues(BufferedImage img, int x, int y, int w, int h, float[] array) Extract values for a square of pixels from an image.booleanReturns 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.booleanReturns true if rescaling according to min & max display levels is applied, false if the full display range is used.booleanCheck ifSingleChannelDisplayInfo.getValue(BufferedImage, int, int)returns fixed values, or if they are dependent on other properties of theImageData.voidsetLUTColor(int r, int g, int b) Set the 'maximum' color, which defines the lookup table to use.voidsetMaxDisplay(float maxDisplay) Set the max display value for this channel.voidsetMinDisplay(float minDisplay) Set the min display value for this channel.voidsetMinMaxAllowed(float minAllowed, float maxAllowed) Set the maximum permissible range for the image display.toString()voidupdateRGBAdditive(BufferedImage img, int[] rgb, ChannelDisplayMode mode) Update an array of existing pixels (packed RGB) additively using the colors to display a specified image.intupdateRGBAdditive(BufferedImage img, int x, int y, int rgb, ChannelDisplayMode mode) Update an existing pixel (packed RGB) additively using the color used to display a specified oneMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface qupath.lib.display.ChannelDisplayInfo
getMaxAllowed, getMaxDisplay, getMethod, getMinAllowed, getMinDisplay, isBrightnessContrastRescaled, updateRGBAdditive
-
Field Details
-
df
-
CM_GRAYSCALE
-
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
Constructor.- Parameters:
imageData- the imagechannel- the channel number (0-based index)
-
-
Method Details
-
getChannel
public int getChannel()Get the channel number.- Returns:
-
getName
Description copied from interface:ChannelDisplayInfoGet the channel name. This may also be returned by thetoString()method.- Returns:
-
getOriginalChannelName
Get the original channel name, extracted for the current ImageData if available. This differs fromgetName()in that it does not append the channel number, or return a default name if no ImageData is present.- Returns:
- the channel name, or null if no image is available
-
getColorModel
Get aColorModelto use with a specifiedChannelDisplayModewhen 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
Description copied from interface:SingleChannelDisplayInfoExtract the value for a single pixel of an image.- Parameters:
img- the imagex- x-coordinate of the pixely- y-coordinate of the pixel- Returns:
- the value of the pixel
-
getValues
Description copied from interface:SingleChannelDisplayInfoExtract values for a square of pixels from an image.- Parameters:
img- the imagex- x-coordinate of the top left corner of the region to extracty- y-coordinate of the top left corner of the region to extractw- width of the region to extracth- height of the region to extractarray- optional array that may be used to store the output values- Returns:
- array of values
-
doesSomething
public boolean doesSomething()Description copied from interface:ChannelDisplayInfoReturns 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:ChannelDisplayInfoReturns 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
Description copied from interface:ChannelDisplayInfoPredominate 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:SingleChannelDisplayInfoCheck ifSingleChannelDisplayInfo.getValue(BufferedImage, int, int)returns fixed values, or if they are dependent on other properties of theImageData.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
Get a suitable RGB value for displaying a pixel with the specified value- Parameters:
value-mode-- Returns:
-
getRGB
Description copied from interface:ChannelDisplayInfoGet the RGB value that would be used to display a particular pixel- Specified by:
getRGBin interfaceChannelDisplayInfo- Parameters:
img-x-y-mode-- Returns:
-
getValueAsString
Description copied from interface:ChannelDisplayInfoGet 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:
getValueAsStringin interfaceChannelDisplayInfo- Parameters:
img-x-y-- Returns:
-
getRGB
Description copied from interface:ChannelDisplayInfoGet the RGB values that would be used to display all the pixels of an image- Specified by:
getRGBin interfaceChannelDisplayInfo- Parameters:
img-rgb-mode-- Returns:
-
updateRGBAdditive
Description copied from interface:ChannelDisplayInfoUpdate 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:
updateRGBAdditivein interfaceChannelDisplayInfo- Parameters:
img-rgb-mode-
-
getImageData
-
getImageServer
-
setMinMaxAllowed
public void setMinMaxAllowed(float minAllowed, float maxAllowed) Description copied from interface:ChannelDisplayInfo.ModifiableChannelDisplayInfoSet 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:
setMinMaxAllowedin interfaceChannelDisplayInfo.ModifiableChannelDisplayInfo- Parameters:
minAllowed-maxAllowed-
-
isBrightnessContrastRescaled
public boolean isBrightnessContrastRescaled()Description copied from interface:ChannelDisplayInfoReturns true if rescaling according to min & max display levels is applied, false if the full display range is used.- Specified by:
isBrightnessContrastRescaledin interfaceChannelDisplayInfo- Returns:
-
setMinDisplay
public void setMinDisplay(float minDisplay) Description copied from interface:ChannelDisplayInfo.ModifiableChannelDisplayInfoSet the min display value for this channel. Note that it is *strongly* advised to useImageDisplay.setMinMaxDisplayinstead since this helps ensure that theImageDisplayfires appropriate events etc.- Specified by:
setMinDisplayin interfaceChannelDisplayInfo.ModifiableChannelDisplayInfo- Parameters:
minDisplay-- See Also:
-
setMaxDisplay
public void setMaxDisplay(float maxDisplay) Description copied from interface:ChannelDisplayInfo.ModifiableChannelDisplayInfoSet the max display value for this channel. Note that it is *strongly* advised to useImageDisplay.setMinMaxDisplayinstead since this helps ensure that theImageDisplayfires appropriate events etc.- Specified by:
setMaxDisplayin interfaceChannelDisplayInfo.ModifiableChannelDisplayInfo- Parameters:
maxDisplay-- See Also:
-
getMinAllowed
public float getMinAllowed()Description copied from interface:ChannelDisplayInfoGet the min allowed display value. This is only a hint.- Specified by:
getMinAllowedin interfaceChannelDisplayInfo- Returns:
-
getMaxAllowed
public float getMaxAllowed()Description copied from interface:ChannelDisplayInfoGet the max allowed display value. This is only a hint.- Specified by:
getMaxAllowedin interfaceChannelDisplayInfo- Returns:
-
getMinDisplay
public float getMinDisplay()Description copied from interface:ChannelDisplayInfoGet the min display value. This is used to control the brightness/contrast when painting.- Specified by:
getMinDisplayin interfaceChannelDisplayInfo- Returns:
-
getMaxDisplay
public float getMaxDisplay()Description copied from interface:ChannelDisplayInfoGet the max display value. This is used to control the brightness/contrast when painting.- Specified by:
getMaxDisplayin interfaceChannelDisplayInfo- Returns:
-
updateRGBAdditive
Description copied from interface:ChannelDisplayInfoUpdate an existing pixel (packed RGB) additively using the color used to display a specified one- Specified by:
updateRGBAdditivein interfaceChannelDisplayInfo- Parameters:
img-x-y-rgb-mode-- Returns:
-
toString
-