Class ImageDisplay

All Implemented Interfaces:
ImageRenderer

public class ImageDisplay extends AbstractImageRenderer
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 Details

  • Constructor Details

    • ImageDisplay

      public ImageDisplay()
      Constructor.
  • Method Details

    • create

      public static ImageDisplay create(ImageData<BufferedImage> imageData) throws IOException
      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 the ImageData to a new value
      Parameters:
      imageData - image data that should how be displayed
      retainDisplaySettings - if true, retain the same display settings as for the previous image if possible (i.e. the images have similar channels)
      Throws:
      IOException
    • getImageData

      public ImageData<BufferedImage> getImageData()
      Get the current image data
      Returns:
    • useGrayscaleLutProperty

      public BooleanProperty useGrayscaleLutProperty()
      Property that specifies whether grayscale lookup tables should be preferred to color lookup tables
      Returns:
    • useGrayscaleLuts

      public boolean useGrayscaleLuts()
      Get the value of useGrayscaleLutProperty()
      Returns:
    • setUseGrayscaleLuts

      public void setUseGrayscaleLuts(boolean useGrayscaleLuts)
      Set the value of useGrayscaleLutProperty()
      Parameters:
      useGrayscaleLuts -
    • useInvertedBackgroundProperty

      public BooleanProperty 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()
      Returns:
    • displayMode

      public ObjectBinding<ChannelDisplayMode> displayMode()
      Returns:
    • setUseInvertedBackground

      public void setUseInvertedBackground(boolean useInvertedBackground)
      Parameters:
      useInvertedBackground -
    • useColorLUTs

      public boolean useColorLUTs()
      The opposite of useGrayscaleLuts()
      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 interface ImageRenderer
      Overrides:
      getLastChangeTimestamp in class AbstractImageRenderer
      Returns:
    • changeTimestampProperty

      public LongProperty 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

      public ObjectProperty<ChannelDisplayInfo> switchToGrayscaleChannelProperty()
      Property indicating which channel should be used if useGrayscaleLutProperty() 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

      public void setSwitchToGrayscaleChannel(ChannelDisplayInfo channel)
      Parameters:
      channel -
      Since:
      v0.5.0
    • getSwitchToGrayscaleChannel

      public ChannelDisplayInfo getSwitchToGrayscaleChannel()
      Returns:
      Since:
      v0.5.0
    • setMinMaxDisplay

      public void setMinMaxDisplay(ChannelDisplayInfo info, float minDisplay, float maxDisplay)
      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

      public ObservableList<ChannelDisplayInfo> selectedChannels()
      ObservableList containing the channels currently selected for display.
      Returns:
      See Also:
    • availableChannels

      public ObservableList<ChannelDisplayInfo> availableChannels()
      ObservableList containing the channels currently available for display.
      Returns:
      See Also:
    • setChannelSelected

      public void setChannelSelected(ChannelDisplayInfo channel, boolean selected)
      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

      public BufferedImage applyTransforms(BufferedImage imgInput, BufferedImage imgOutput)
      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)
      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 and ChannelDisplayMode.
      Parameters:
      imgInput - the input image to transform
      imgOutput - optional output image (must be the same size as the input image, and RGB)
      selectedChannels - the channels to use
      mode - 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

      public String getTransformedValueAsString(BufferedImage img, int x, int y)
      Get a string representation of a transformed pixel value, using the currently-selected channels.
      Parameters:
      img - image providing the value
      x - x-coordinate of the pixel
      y - y-coordinate of the pixels
      Returns:
      a String representation of the pixel's transformed value
    • autoSetDisplayRange

      public void autoSetDisplayRange(ChannelDisplayInfo info)
      Automatically set the display range for a channel, using the default saturation defined in PathPrefs.autoBrightnessContrastSaturationPercentProperty().
      Parameters:
      info - channel to update
    • autoSetDisplayRange

      public void autoSetDisplayRange(ChannelDisplayInfo info, double saturation)
      Automatically set the display range for a channel.
      Parameters:
      info - channel to update
      saturation - proportion of pixels that may be saturated, i.e. have the max/min display values (between 0.0 and 1.0)
    • getHistogram

      public Histogram getHistogram(ChannelDisplayInfo info)
      Returns a histogram for a ChannelInfo, or none if no histogram is available (e.g. the channel is RGB)
      Parameters:
      info -
      Returns:
    • toJSON

      public String toJSON(boolean prettyPrint)
      Create a JSON representation of the main components of the current display.
      Parameters:
      prettyPrint -
      Returns:
    • isCompatible

      public boolean isCompatible(ImageDisplay display)
      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

      public boolean updateFromDisplay(ImageDisplay display)
      Update the current display based upon a different display. This only makes changes if isCompatible(ImageDisplay) returns true.

      This method exists to make it easier to sync display settings across viewers.

      Parameters:
      display -
      Returns: