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.- Author:
- Pete Bankhead
-
Property Summary
Properties 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 TypeMethodDescriptionvoid
Clear any cached tiles.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
.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
.static PixelClassificationOverlay
create
(OverlayOptions options, PixelClassifier classifier) Create an overlay to display the live application of aPixelClassifier
to an image, using the default number of parallel threads for classification.static PixelClassificationOverlay
create
(OverlayOptions options, PixelClassifier classifier, int nThreads) Create an overlay to display the live application of aPixelClassifier
to an image.static PixelClassificationOverlay
createFeatureDisplayOverlay
(OverlayOptions options, Function<ImageData<BufferedImage>, ImageServer<BufferedImage>> fun, ImageRenderer renderer) Deprecated.static String
getDefaultLocationString
(ImageServer<BufferedImage> server, double x, double y, int z, int t) Default method for getting a location string from anImageServer
using cached tiles.boolean
Query 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.int
Get the maximum number of threads that may be used during live prediction.getPixelClassificationServer
(ImageData<BufferedImage> imageData) Get theImageServer
that would be used by this overlay for the specifiedImageData
.Get theImageRenderer
used with this overlay, which may be null.void
paintOverlay
(Graphics2D g2d, ImageRegion imageRegion, double downsampleFactor, ImageData<BufferedImage> imageData, boolean paintCompletely) Paint the overlay to a graphics object.Get theImageRenderer
property used with this overlay.void
setLivePrediction
(boolean livePrediction) Turn on or off live prediction.void
setMaxThreads
(int nThreads) Set the maximum number of threads that may be used during live prediction.void
setRenderer
(ImageRenderer renderer) Set theImageRenderer
to be used with this overlay.void
stop()
Stop the overlap, halting any pending tile requests.Methods inherited from class qupath.lib.gui.viewer.overlays.AbstractImageOverlay
getInterpolation, interpolationProperty, setInterpolation, setInterpolation
Methods inherited from class qupath.lib.gui.viewer.overlays.AbstractOverlay
getAlphaComposite, getLocationStringFunction, getOpacity, getOverlayOptions, getPreferredOverlayColor, isVisible, setAlphaComposite, setLocationStringFunction, setOpacity, setPreferredOverlayColor
-
Property Details
-
renderer
Get theImageRenderer
property used with this overlay.- See Also:
-
-
Method Details
-
create
Create an overlay to display the live application of aPixelClassifier
to 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 aPixelClassifier
to 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 anImageServer
from 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 anImageServer
from anImageData
renderer
- 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 anImageServer
from theImageData
renderer
- rendered used to create an RGB image- Returns:
- the
PixelClassificationOverlay
-
rendererProperty
Get theImageRenderer
property used with this overlay.- Returns:
- See Also:
-
getRenderer
Get theImageRenderer
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
Set theImageRenderer
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
Get theImageServer
that 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: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 interfacePathOverlay
- Overrides:
paintOverlay
in 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 theGraphics2D
as part of itsAffineTransform
, however it may optionally be needed within the method e.g. to correct line thicknesses.imageData
- theImageData
associated with this overlay. If the overlay is being displayed on a viewer, this is theImageData
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(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 interfacePathOverlay
- Overrides:
getLocationString
in 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 anImageServer
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
-
create(OverlayOptions, Function, ImageRenderer)
instead.