Interface ChannelDisplayInfo
- All Known Subinterfaces:
ChannelDisplayInfo.ModifiableChannelDisplayInfo
,SingleChannelDisplayInfo
- All Known Implementing Classes:
DirectServerChannelInfo
The primary uses are:
- to extract floating point pixel values for the channel from a
BufferedImage
(either directly, or via some color transformation that may involve more than one channel/band from the BufferedImage) - to generate RGB pixel values suitable for visualizing the raw channel values extracted above, including the storage of any lookup tables required
- to store min/max display values, which influence the lookup table mapping to RGB (i.e. to store brightness/contrast values)
- to update an existing RGB value, to facilitate creating composite images that depict the values of multiple channels in a single, merged visualization
As such, its uses lie somewhere between Java's SampleModel
and ColorModel
classes.
Its reason for existing is that sometimes we need to be able to adjust the display of channels individually and to create merges - particularly in the case of fluorescence images - but to simplify whole slide image support we need to be able to do this on-the-fly. Switching the ColorModel for an existing BufferedImage is somewhat awkward, and when caching image tiles we want to be able to keep the original ColorModels intact - otherwise ColorModels for recently-seen tiles might be different from the ColorModels of tiles that have been in the cache for longer, even though they were read from the same image servers. Furthermore, 'unknown' image types (i.e. not standard RGB/BGR/single-channel images) don't always behave nicely with Graphics objects if we want to paint or scale them.
Using the ChannelDisplayInfo
approach means that during repainting an (A)RGB image can be produced on-the-fly
without needing to create a new image with the desired ColorModel for painting.
This potentially ends up requiring a bit more computation that is really necessary - and it may be optimized
better in the future - but it was the simplest method I could come up with to provide the features I wanted...
Before v0.4.0, some methods supported a boolean parameter to specify whether or not to use color LUTs.
Since v0.4.0, this has been replaced by ChannelDisplayMode
to support different ways of visualizing channels.
In particular, in some cases an inverted display is requested - where 'inverted' refers to the background
(i.e. switching from black is zero to white is zero, or vice versa depending upon the default display).
Because only additive combinations of RGB colors are permitted, requesting inversion means that the color used for the
LUT should be inverted but everything else proceeds are normal.
The calling code then has the job of inverting the resulting image, as done by
ImageDisplay.applyTransforms(BufferedImage, BufferedImage, java.util.List, ChannelDisplayMode)
.
- Author:
- Pete Bankhead
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Helper interface to indicate that the display ranges can be modified. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if this does something - anything - and false otherwise.getColor()
Predominate color used when this ChannelDisplayInfo uses a Color LUT (e.g.float
Get the max allowed display value.float
Get the max display value.Get theColorTransformer.ColorTransformMethod
associated with this channel, or null if no method is relevant.float
Get the min allowed display value.float
Get the min display value.getName()
Get the channel name.int[]
getRGB
(BufferedImage img, int[] rgb, ChannelDisplayMode mode) Get the RGB values that would be used to display all the pixels of an imageint
getRGB
(BufferedImage img, int x, int y, ChannelDisplayMode mode) Get the RGB value that would be used to display a particular pixelgetValueAsString
(BufferedImage img, int x, int y) Get a string representation of a pixel's value.boolean
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.boolean
Returns true if rescaling according to min & max display levels is applied, false if the full display range is used.void
updateRGBAdditive
(BufferedImage img, int[] rgb, ChannelDisplayMode mode) Update an array of existing pixels (packed RGB) additively using the colors to display a specified image.int
updateRGBAdditive
(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 one
-
Method Details
-
getName
String getName()Get the channel name. This may also be returned by thetoString()
method.- Returns:
-
getMinDisplay
float getMinDisplay()Get the min display value. This is used to control the brightness/contrast when painting.- Returns:
-
getMaxDisplay
float getMaxDisplay()Get the max display value. This is used to control the brightness/contrast when painting.- Returns:
-
getMinAllowed
float getMinAllowed()Get the min allowed display value. This is only a hint.- Returns:
-
getMaxAllowed
float getMaxAllowed()Get the max allowed display value. This is only a hint.- Returns:
-
isAdditive
boolean isAdditive()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:
-
isBrightnessContrastRescaled
boolean isBrightnessContrastRescaled()Returns true if rescaling according to min & max display levels is applied, false if the full display range is used.- Returns:
-
getValueAsString
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.- Parameters:
img
-x
-y
-- Returns:
-
getRGB
Get the RGB value that would be used to display a particular pixel- Parameters:
img
-x
-y
-mode
-- Returns:
-
getRGB
Get the RGB values that would be used to display all the pixels of an image- Parameters:
img
-rgb
-mode
-- Returns:
-
updateRGBAdditive
Update an existing pixel (packed RGB) additively using the color used to display a specified one- Parameters:
img
-x
-y
-rgb
-mode
-- Returns:
-
updateRGBAdditive
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;- Parameters:
img
-rgb
-mode
-
-
doesSomething
boolean doesSomething()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:
-
getColor
Integer getColor()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:
-
getMethod
Get theColorTransformer.ColorTransformMethod
associated with this channel, or null if no method is relevant.- Returns:
-