Package qupath.lib.display
Class ImageDisplay
java.lang.Object
qupath.lib.gui.images.stores.AbstractImageRenderer
qupath.lib.display.ImageDisplay
- All Implemented Interfaces:
ImageRenderer
Class used to look after the color transforms that may be applied to an image,
including brightness/contrast settings.
Warning! This implementation is likely to change in a future version.
- Author:
- Pete Bankhead
-
Property Summary
TypePropertyDescriptionTimestamp for the most recent change.Property indicating which channel should be used ifuseGrayscaleLutProperty()
is turned on.Property that specifies whether grayscale lookup tables should be preferred to color lookup tablesProperty that specifies whether the background should be inverted (i.e. -
Field Summary
Fields inherited from class qupath.lib.gui.images.stores.AbstractImageRenderer
timestamp
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapplyTransforms
(BufferedImage imgInput, BufferedImage imgOutput) Apply the required transforms to a BufferedImage to get the appropriate display.static BufferedImage
applyTransforms
(BufferedImage imgInput, BufferedImage imgOutput, List<? extends ChannelDisplayInfo> selectedChannels, boolean useGrayscaleLuts) Deprecated.static BufferedImage
applyTransforms
(BufferedImage imgInput, BufferedImage imgOutput, List<? extends ChannelDisplayInfo> selectedChannels, ChannelDisplayMode mode) Convert an image to RGB by applying the specified ChannelDisplayInfos andChannelDisplayMode
.void
Automatically set the display range for a channel, using the default saturation defined inPathPrefs.autoBrightnessContrastSaturationPercentProperty()
.void
autoSetDisplayRange
(ChannelDisplayInfo info, double saturation) Automatically set the display range for a channel.ObservableList
containing the channels currently available for display.Timestamp for the most recent change.static ImageDisplay
create
(ImageData<BufferedImage> imageData) Create a new image display, and set the specified image data.Get the value ofuseInvertedBackgroundProperty()
Returns a histogram for a ChannelInfo, or none if no histogram is available (e.g.Get the current image datalong
Get a timestamp the last known changes for the object.Get the value ofswitchToGrayscaleChannelProperty()
.getTransformedValueAsString
(BufferedImage img, int x, int y) Get a string representation of a transformed pixel value, using the currently-selected channels.boolean
isCompatible
(ImageDisplay display) Check if an image display is 'compatible' with this one.void
Refresh the channel options.void
Save color channels in the ImageData properties.ObservableList
containing the channels currently selected for display.void
setChannelSelected
(ChannelDisplayInfo channel, boolean selected) Set the selection of a channel on or off.void
setImageData
(ImageData<BufferedImage> imageData, boolean retainDisplaySettings) Set theImageData
to a new valuevoid
setMinMaxDisplay
(ChannelDisplayInfo info, float minDisplay, float maxDisplay) Set the min/max display values for a specified ChannelDisplayInfo.void
Set the value ofswitchToGrayscaleChannelProperty()
.void
setUseGrayscaleLuts
(boolean useGrayscaleLuts) Set the value ofuseGrayscaleLutProperty()
void
setUseInvertedBackground
(boolean useInvertedBackground) Set the value ofuseInvertedBackgroundProperty()
Property indicating which channel should be used ifuseGrayscaleLutProperty()
is turned on.toJSON
(boolean prettyPrint) Create a JSON representation of the main components of the current display.boolean
updateFromDisplay
(ImageDisplay display) Update the current display based upon a different display.boolean
The opposite ofuseGrayscaleLuts()
Property that specifies whether grayscale lookup tables should be preferred to color lookup tablesboolean
Get the value ofuseGrayscaleLutProperty()
boolean
Get the value ofuseInvertedBackgroundProperty()
Property that specifies whether the background should be inverted (i.e.Methods inherited from class qupath.lib.gui.images.stores.AbstractImageRenderer
getUniqueID
-
Property Details
-
useGrayscaleLut
Property that specifies whether grayscale lookup tables should be preferred to color lookup tables- See Also:
-
useInvertedBackground
Property that specifies whether the background should be inverted (i.e. to make fluorescence resemble brightfield, and vice versa)- See Also:
-
changeTimestamp
Timestamp for the most recent change. This can be used to listen for display changes.- See Also:
-
switchToGrayscaleChannel
Property indicating which channel should be used ifuseGrayscaleLutProperty()
is turned on. This is useful to develop more intuitive interfaces and prevent surprises when switching to grayscale mode.Settings this value does not have any immediate effect on whether channels are selected or not, but rather it is only used when switching to grayscale mode.
- Since:
- v0.5.0
- See Also:
-
-
Constructor Details
-
ImageDisplay
public ImageDisplay()Constructor.
-
-
Method Details
-
create
Create a new image display, and set the specified image data.- Parameters:
imageData
-- Returns:
- Throws:
IOException
-
setImageData
public void setImageData(ImageData<BufferedImage> imageData, boolean retainDisplaySettings) throws IOException Set theImageData
to a new value- Parameters:
imageData
- image data that should how be displayedretainDisplaySettings
- if true, retain the same display settings as for the previous image if possible (i.e. the images have similar channels)- Throws:
IOException
-
getImageData
Get the current image data- Returns:
-
useGrayscaleLutProperty
Property that specifies whether grayscale lookup tables should be preferred to color lookup tables- Returns:
-
useGrayscaleLuts
public boolean useGrayscaleLuts()Get the value ofuseGrayscaleLutProperty()
- Returns:
-
setUseGrayscaleLuts
public void setUseGrayscaleLuts(boolean useGrayscaleLuts) Set the value ofuseGrayscaleLutProperty()
- Parameters:
useGrayscaleLuts
-
-
useInvertedBackgroundProperty
Property that specifies whether the background should be inverted (i.e. to make fluorescence resemble brightfield, and vice versa)- Returns:
- See Also:
-
useInvertedBackground
public boolean useInvertedBackground()Get the value ofuseInvertedBackgroundProperty()
- Returns:
-
displayMode
Get the value ofuseInvertedBackgroundProperty()
- Returns:
-
setUseInvertedBackground
public void setUseInvertedBackground(boolean useInvertedBackground) Set the value ofuseInvertedBackgroundProperty()
- Parameters:
useInvertedBackground
-
-
useColorLUTs
public boolean useColorLUTs()The opposite ofuseGrayscaleLuts()
- Returns:
-
getLastChangeTimestamp
public long getLastChangeTimestamp()Get a timestamp the last known changes for the object. This is useful to abort painting if the display changes during a paint run.- Specified by:
getLastChangeTimestamp
in interfaceImageRenderer
- Overrides:
getLastChangeTimestamp
in classAbstractImageRenderer
- Returns:
-
changeTimestampProperty
Timestamp for the most recent change. This can be used to listen for display changes.- Returns:
-
refreshChannelOptions
public void refreshChannelOptions()Refresh the channel options. This may be used if an underlying property of the image has changed, such as the channel names or lookup tables. -
switchToGrayscaleChannelProperty
Property indicating which channel should be used ifuseGrayscaleLutProperty()
is turned on. This is useful to develop more intuitive interfaces and prevent surprises when switching to grayscale mode.Settings this value does not have any immediate effect on whether channels are selected or not, but rather it is only used when switching to grayscale mode.
- Returns:
- Since:
- v0.5.0
- See Also:
-
setSwitchToGrayscaleChannel
Set the value ofswitchToGrayscaleChannelProperty()
.- Parameters:
channel
-- Since:
- v0.5.0
-
getSwitchToGrayscaleChannel
Get the value ofswitchToGrayscaleChannelProperty()
.- Returns:
- Since:
- v0.5.0
-
setMinMaxDisplay
Set the min/max display values for a specified ChannelDisplayInfo. The benefit of calling this method is that it will update the ImageData metadata if appropriate.- Parameters:
info
-minDisplay
-maxDisplay
-
-
saveChannelColorProperties
public void saveChannelColorProperties()Save color channels in the ImageData properties. This lets them be deserialized later. -
selectedChannels
ObservableList
containing the channels currently selected for display.- Returns:
- See Also:
-
availableChannels
ObservableList
containing the channels currently available for display.- Returns:
- See Also:
-
setChannelSelected
Set the selection of a channel on or off. If a channel's isAdditive() method returns false, all other selected channels will be cleared. Otherwise, other selected channels will be cleared if they are non-additive - but kept if they are additive (and therefore can be sensibly displayed in combination with this channel).- Parameters:
channel
-selected
- true if the channel should be selected, false if it should not
-
applyTransforms
Apply the required transforms to a BufferedImage to get the appropriate display. imgOutput should always be an RGB image (of some kind), or null if a new image should be created. imgInput should always be an image of the kind that matches the imgData, e.g. RGB/non-RGB, same number of channels, same bit-depth. Warning: This is not thread-safe. Warning #2: imgOutput should be TYPE_INT_RGB- Parameters:
imgInput
-imgOutput
-- Returns:
-
applyTransforms
@Deprecated public static BufferedImage applyTransforms(BufferedImage imgInput, BufferedImage imgOutput, List<? extends ChannelDisplayInfo> selectedChannels, boolean useGrayscaleLuts) Deprecated.Convert an image to RGB by applying the specified ChannelDisplayInfos.- Parameters:
imgInput
-imgOutput
-selectedChannels
-useGrayscaleLuts
-- Returns:
-
applyTransforms
public static BufferedImage applyTransforms(BufferedImage imgInput, BufferedImage imgOutput, List<? extends ChannelDisplayInfo> selectedChannels, ChannelDisplayMode mode) Convert an image to RGB by applying the specified ChannelDisplayInfos andChannelDisplayMode
.- Parameters:
imgInput
- the input image to transformimgOutput
- optional output image (must be the same size as the input image, and RGB)selectedChannels
- the channels to usemode
- the mode used to determine RGB colors for each channel- Returns:
- an RGB image determined by transforming the input image using the specified channels
-
getTransformedValueAsString
Get a string representation of a transformed pixel value, using the currently-selected channels.- Parameters:
img
- image providing the valuex
- x-coordinate of the pixely
- y-coordinate of the pixels- Returns:
- a String representation of the pixel's transformed value
-
autoSetDisplayRange
Automatically set the display range for a channel, using the default saturation defined inPathPrefs.autoBrightnessContrastSaturationPercentProperty()
.- Parameters:
info
- channel to update
-
autoSetDisplayRange
Automatically set the display range for a channel.- Parameters:
info
- channel to updatesaturation
- proportion of pixels that may be saturated, i.e. have the max/min display values (between 0.0 and 1.0)
-
getHistogram
Returns a histogram for a ChannelInfo, or none if no histogram is available (e.g. the channel is RGB)- Parameters:
info
-- Returns:
-
toJSON
Create a JSON representation of the main components of the current display.- Parameters:
prettyPrint
-- Returns:
-
isCompatible
Check if an image display is 'compatible' with this one. Compatible means that they have the same number of channels, and the same channel names. This may be used p- Parameters:
display
-- Returns:
-
updateFromDisplay
Update the current display based upon a different display. This only makes changes ifisCompatible(ImageDisplay)
returns true.This method exists to make it easier to sync display settings across viewers.
- Parameters:
display
-- Returns:
-
applyTransforms(BufferedImage, BufferedImage, List, ChannelDisplayMode)