Package qupath.lib.gui.viewer.overlays
Class PixelClassificationOverlay
java.lang.Object
qupath.lib.gui.viewer.overlays.AbstractOverlay
qupath.lib.gui.viewer.overlays.AbstractImageOverlay
qupath.lib.gui.viewer.overlays.PixelClassificationOverlay
- All Implemented Interfaces:
PathOverlay
PathOverlay that gives the results of pixel classification.-
Property Summary
PropertiesProperties inherited from class qupath.lib.gui.viewer.overlays.AbstractImageOverlay
interpolation -
Nested Class Summary
Nested classes/interfaces inherited from class qupath.lib.gui.viewer.overlays.AbstractOverlay
AbstractOverlay.LocationStringFunction -
Method Summary
Modifier and TypeMethodDescriptionvoidClear any cached tiles.static PixelClassificationOverlaycreate(OverlayOptions options, Function<ImageData<BufferedImage>, ImageServer<BufferedImage>> fun, ImageRenderer renderer) Create an overlay to display a live image that can be created from an existingImageData.static PixelClassificationOverlaycreate(OverlayOptions options, Map<ImageData<BufferedImage>, ImageServer<BufferedImage>> map, ImageRenderer renderer) Create an overlay to display a live image that can be created from an existingImageData.static PixelClassificationOverlaycreate(OverlayOptions options, PixelClassifier classifier) Create an overlay to display the live application of aPixelClassifierto an image, using the default number of parallel threads for classification.static PixelClassificationOverlaycreate(OverlayOptions options, PixelClassifier classifier, int nThreads) Create an overlay to display the live application of aPixelClassifierto an image.static PixelClassificationOverlaycreateFeatureDisplayOverlay(OverlayOptions options, Function<ImageData<BufferedImage>, ImageServer<BufferedImage>> fun, ImageRenderer renderer) Deprecated.static StringgetDefaultLocationString(ImageServer<BufferedImage> server, double x, double y, int z, int t) Default method for getting a location string from anImageServerusing cached tiles.booleanQuery whether live prediction is turned on.getLocationString(ImageData<BufferedImage> imageData, double x, double y, int z, int t) Get a location string to display when showing a specified image.intGet the maximum number of threads that may be used during live prediction.getPixelClassificationServer(ImageData<BufferedImage> imageData) Get theImageServerthat would be used by this overlay for the specifiedImageData.Get theImageRendererused with this overlay, which may be null.voidpaintOverlay(Graphics2D g2d, ImageRegion imageRegion, double downsampleFactor, ImageData<BufferedImage> imageData, boolean paintCompletely) Paint the overlay to a graphics object.Get theImageRendererproperty used with this overlay.voidsetLivePrediction(boolean livePrediction) Turn on or off live prediction.voidsetMaxThreads(int nThreads) Set the maximum number of threads that may be used during live prediction.voidsetRenderer(ImageRenderer renderer) Set theImageRendererto be used with this overlay.voidstop()Stop the overlap, halting any pending tile requests.Methods inherited from class qupath.lib.gui.viewer.overlays.AbstractImageOverlay
getInterpolation, interpolationProperty, setInterpolation, setInterpolationMethods inherited from class qupath.lib.gui.viewer.overlays.AbstractOverlay
getAlphaComposite, getLocationStringFunction, getOpacity, getOverlayOptions, getPreferredOverlayColor, isVisible, setAlphaComposite, setLocationStringFunction, setOpacity, setPreferredOverlayColor
-
Property Details
-
renderer
Get theImageRendererproperty used with this overlay.- See Also:
-
-
Method Details
-
create
Create an overlay to display the live application of aPixelClassifierto an image, using the default number of parallel threads for classification.- Parameters:
options- the options controlling the overlay displayclassifier- the classifier- Returns:
-
create
public static PixelClassificationOverlay create(OverlayOptions options, PixelClassifier classifier, int nThreads) Create an overlay to display the live application of aPixelClassifierto an image.- Parameters:
options- the options controlling the overlay displayclassifier- the classifiernThreads- number of parallel threads to use for classification (will be clipped to 1 or greater)- Returns:
-
create
public static PixelClassificationOverlay create(OverlayOptions options, Function<ImageData<BufferedImage>, ImageServer<BufferedImage>> fun, ImageRenderer renderer) Create an overlay to display a live image that can be created from an existingImageData.- Parameters:
options- options to control the overlay displayfun- function to create anImageServerfrom theImageData. 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 andcreate(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<ImageData<BufferedImage>, ImageServer<BufferedImage>> map, ImageRenderer renderer) Create an overlay to display a live image that can be created from an existingImageData. This differs fromcreate(OverlayOptions, Function, ImageRenderer)in that a cached map of classifier servers is used directly.- Parameters:
options- options to control the overlay displaymap- map to obtain anImageServerfrom anImageDatarenderer- rendered used to create an RGB image- Returns:
- the
PixelClassificationOverlay
-
createFeatureDisplayOverlay
@Deprecated public static PixelClassificationOverlay createFeatureDisplayOverlay(OverlayOptions options, Function<ImageData<BufferedImage>, ImageServer<BufferedImage>> fun, ImageRenderer renderer) Deprecated.Usecreate(OverlayOptions, Function, ImageRenderer)instead.Create an overlay to display a live image that can be created from an existingImageData.- Parameters:
options- options to control the overlay displayfun- function to create anImageServerfrom theImageDatarenderer- rendered used to create an RGB image- Returns:
- the
PixelClassificationOverlay
-
rendererProperty
Get theImageRendererproperty used with this overlay.- Returns:
- See Also:
-
getRenderer
Get theImageRendererused 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
Set theImageRendererto 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
Get theImageServerthat would be used by this overlay for the specifiedImageData. Note that the servers are cached internally.- Parameters:
imageData-- Returns:
-
paintOverlay
public void paintOverlay(Graphics2D g2d, ImageRegion imageRegion, double downsampleFactor, ImageData<BufferedImage> imageData, boolean paintCompletely) Description copied from interface:PathOverlayPaint 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:
paintOverlayin interfacePathOverlay- Overrides:
paintOverlayin classAbstractImageOverlay- 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 theGraphics2Das part of itsAffineTransform, however it may optionally be needed within the method e.g. to correct line thicknesses.imageData- theImageDataassociated with this overlay. If the overlay is being displayed on a viewer, this is theImageDataopen 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(ImageData<BufferedImage> imageData, double x, double y, int z, int t) Description copied from interface:PathOverlayGet 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:
getLocationStringin interfacePathOverlay- Overrides:
getLocationStringin classAbstractOverlay- 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 viewedt- t-index for the region currently being viewed- Returns:
-
getDefaultLocationString
public static String getDefaultLocationString(ImageServer<BufferedImage> server, double x, double y, int z, int t) Default method for getting a location string from anImageServerusing 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
-
create(OverlayOptions, Function, ImageRenderer)instead.