Class ImageDisplay
- All Implemented Interfaces:
ImageRenderer
Warning! This implementation is likely to change in a future version.
-
Property Summary
PropertiesTypePropertyDescriptionCounter for the number of display changes that have been made.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. -
Constructor Summary
Constructors -
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, 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.Read-only observable list containing the channels currently available for display.static ImageDisplay
create
(ImageData<BufferedImage> imageData) Create a new image display, and set the specified image data.Get the value ofuseInvertedBackgroundProperty()
Counter for the number of display changes that have been made.getHistogram
(ChannelDisplayInfo channel) Returns a histogram for a channel of the current image.Get the current image datalong
Get the event count, which is here used as an alternative to a timestamp.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.Read-only observable list 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:
-
eventCount
Counter for the number of display changes that have been made.Note: This replaces a timestamp property used before v0.6.0. It should be more reliable, because changes occurring in quick succession can still be captured - whereas previously any changes that were faster than the millisecond close might get lost.
- 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
- the image to set initially; may be null- Returns:
- a new instance
- Throws:
IOException
- if an exception occurs when trying to set the image
-
setImageData
public void setImageData(ImageData<BufferedImage> imageData, boolean retainDisplaySettings) throws IOException Set theImageData
to a new value- Parameters:
imageData
- image data that should 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 the event count, which is here used as an alternative to a timestamp.- Returns:
-
eventCountProperty
Counter for the number of display changes that have been made.Note: This replaces a timestamp property used before v0.6.0. It should be more reliable, because changes occurring in quick succession can still be captured - whereas previously any changes that were faster than the millisecond close might get lost.
- 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
Read-only observable list containing the channels currently selected for display.- Returns:
- the selected channels
- See Also:
-
availableChannels
Read-only observable list containing the channels currently available for display.- Returns:
- the available channels
- 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
- the channelselected
- 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.Warning: This is not thread-safe.
- Parameters:
imgInput
- the input image; this should not be null, and should be of a type that matches theImageData
(i.e. same number of channels, same bit-depth).imgOutput
- the output image (optional); if not null, this should be an RGB image (usuallyTYPE_INT_RGB
).- Returns:
- the transformed image; this may be the same as
imgOutput
, if provided
-
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 channel of the current image.- Parameters:
channel
- the channel- Returns:
- the histogram for the specified channel, or null if no histogram is available (e.g. the channel is a packed RGB representation that can't have a single histogram associated with it)
-
toJSON
Create a JSON representation of the main components of the current display.- Parameters:
prettyPrint
- optionally request pretty printing- Returns:
- the Json representation, or null if no image has been set
-
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.- Parameters:
display
- the other display with which to check compatibility- Returns:
- true if the display is compatible, false otherwise
-
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:
-