Class PixelClassificationOverlay

All Implemented Interfaces:
PathOverlay

public class PixelClassificationOverlay extends AbstractImageOverlay
PathOverlay that gives the results of pixel classification.
  • Property Details

  • Method Details

    • create

      public static PixelClassificationOverlay create(OverlayOptions options, qupath.lib.classifiers.pixel.PixelClassifier classifier)
      Create an overlay to display the live application of a PixelClassifier to an image, using the default number of parallel threads for classification.
      Parameters:
      options - the options controlling the overlay display
      classifier - the classifier
      Returns:
    • create

      public static PixelClassificationOverlay create(OverlayOptions options, qupath.lib.classifiers.pixel.PixelClassifier classifier, int nThreads)
      Create an overlay to display the live application of a PixelClassifier to an image.
      Parameters:
      options - the options controlling the overlay display
      classifier - the classifier
      nThreads - number of parallel threads to use for classification (will be clipped to 1 or greater)
      Returns:
    • create

      public static PixelClassificationOverlay create(OverlayOptions options, Function<qupath.lib.images.ImageData<BufferedImage>,qupath.lib.images.servers.ImageServer<BufferedImage>> fun, ImageRenderer renderer)
      Create an overlay to display a live image that can be created from an existing ImageData.
      Parameters:
      options - options to control the overlay display
      fun - function to create an ImageServer from the ImageData. Note that the server generated by the function call will be cached. If it is necessary to control the caching, this needs to be done externally and create(OverlayOptions, Map, ImageRenderer) should be used instead.
      renderer - rendered used to create an RGB image
      Returns:
      the PixelClassificationOverlay
    • create

      public static PixelClassificationOverlay create(OverlayOptions options, Map<qupath.lib.images.ImageData<BufferedImage>,qupath.lib.images.servers.ImageServer<BufferedImage>> map, ImageRenderer renderer)
      Create an overlay to display a live image that can be created from an existing ImageData. This differs from create(OverlayOptions, Function, ImageRenderer) in that a cached map of classifier servers is used directly.
      Parameters:
      options - options to control the overlay display
      map - map to obtain an ImageServer from an ImageData
      renderer - rendered used to create an RGB image
      Returns:
      the PixelClassificationOverlay
    • createFeatureDisplayOverlay

      @Deprecated public static PixelClassificationOverlay createFeatureDisplayOverlay(OverlayOptions options, Function<qupath.lib.images.ImageData<BufferedImage>,qupath.lib.images.servers.ImageServer<BufferedImage>> fun, ImageRenderer renderer)
      Create an overlay to display a live image that can be created from an existing ImageData.
      Parameters:
      options - options to control the overlay display
      fun - function to create an ImageServer from the ImageData
      renderer - rendered used to create an RGB image
      Returns:
      the PixelClassificationOverlay
    • rendererProperty

      public ObjectProperty<ImageRenderer> rendererProperty()
      Get the ImageRenderer property used with this overlay.
      Returns:
      See Also:
    • getRenderer

      public ImageRenderer getRenderer()
      Get the ImageRenderer used with this overlay, which may be null.
      Returns:
    • setMaxThreads

      public void setMaxThreads(int nThreads)
      Set the maximum number of threads that may be used during live prediction.
      Parameters:
      nThreads -
    • getMaxThreads

      public int getMaxThreads()
      Get the maximum number of threads that may be used during live prediction.
      Returns:
    • setRenderer

      public void setRenderer(ImageRenderer renderer)
      Set the ImageRenderer to be used with this overlay.
      Parameters:
      renderer -
    • getLivePrediction

      public boolean getLivePrediction()
      Query whether live prediction is turned on.
      Returns:
    • setLivePrediction

      public void setLivePrediction(boolean livePrediction)
      Turn on or off live prediction. This requests tile classifications as the overlay is being viewed.
      Parameters:
      livePrediction -
    • getPixelClassificationServer

      public qupath.lib.images.servers.ImageServer<BufferedImage> getPixelClassificationServer(qupath.lib.images.ImageData<BufferedImage> imageData)
      Get the ImageServer that would be used by this overlay for the specified ImageData. Note that the servers are cached internally.
      Parameters:
      imageData -
      Returns:
    • paintOverlay

      public void paintOverlay(Graphics2D g2d, qupath.lib.regions.ImageRegion imageRegion, double downsampleFactor, qupath.lib.images.ImageData<BufferedImage> imageData, boolean paintCompletely)
      Description copied from interface: PathOverlay
      Paint the overlay to a graphics object. The graphics object will have a transform applied to it, so the painting should make use of coordinates in the original image space.
      Specified by:
      paintOverlay in interface PathOverlay
      Overrides:
      paintOverlay in class AbstractImageOverlay
      Parameters:
      g2d - Graphics2D object to which drawing should be performed. This should have any transform already applied to it.
      imageRegion - The maximum image region that should be shown.
      downsampleFactor - The downsample factor at which the overlay will be viewed. There is no need for rescaling according to this value since it has already been applied to the Graphics2D as part of its AffineTransform, however it may optionally be needed within the method e.g. to correct line thicknesses.
      imageData - the ImageData associated with this overlay. If the overlay is being displayed on a viewer, this is the ImageData open within the viewer. Not all overlays require this, and it may be null.
      paintCompletely - If true, the method is permitted to return without completely painting everything, for performance reasons.
    • clearCache

      public void clearCache()
      Clear any cached tiles.
    • stop

      public void stop()
      Stop the overlap, halting any pending tile requests.
    • getLocationString

      public String getLocationString(qupath.lib.images.ImageData<BufferedImage> imageData, double x, double y, int z, int t)
      Description copied from interface: PathOverlay
      Get a location string to display when showing a specified image.

      The default implementation returns null. If subclasses override this method, they must return quickly, as it may be used to determine text to display as the mouse moves over an image.

      Specified by:
      getLocationString in interface PathOverlay
      Overrides:
      getLocationString in class AbstractOverlay
      Parameters:
      imageData -
      x - x-coordinate, in the image space (not the viewer component space)
      y - y-coordinate, in the image space (not the viewer component space)
      z - z-index for the region currently being viewed
      t - t-index for the region currently being viewed
      Returns:
    • getDefaultLocationString

      public static String getDefaultLocationString(qupath.lib.images.servers.ImageServer<BufferedImage> server, double x, double y, int z, int t)
      Default method for getting a location string from an ImageServer using cached tiles. If tiles are not cached, no string is returned.

      May be used by classes implementing PathOverlay.getLocationString(ImageData, double, double, int, int)

      Parameters:
      server -
      x -
      y -
      z -
      t -
      Returns:
      location String based upon pixel values and cached tiles, or null if no String is available