Package qupath.lib.images.servers
Class LabeledImageServer
java.lang.Object
qupath.lib.images.servers.AbstractImageServer<BufferedImage>
qupath.lib.images.servers.AbstractTileableImageServer
qupath.lib.images.servers.LabeledImageServer
- All Implemented Interfaces:
AutoCloseable
,GeneratingImageServer<BufferedImage>
,ImageServer<BufferedImage>
public class LabeledImageServer
extends AbstractTileableImageServer
implements GeneratingImageServer<BufferedImage>
A special ImageServer implementation that doesn't have a backing image, but rather
constructs tiles from a
PathObjectHierarchy
where pixel values are integer labels corresponding
stored and classified annotations.
Warning! This is intend for temporary use when exporting labelled images. No attempt is made to respond to changes within the hierarchy. For consistent results, the hierarchy must remain static for the time in which this server is being used.
- Author:
- Pete Bankhead
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected BufferedImage
createDefaultRGBImage
(int width, int height) Create the default (blank) RGB image for this server.protected String
createID()
Returns a UUID.protected ImageServerBuilder.ServerBuilder
<BufferedImage> Returns null (does not support ServerBuilders).Get an unmodifiable map of classifications and their corresponding boundary labels, if available.Get a mapping between objects and instance labels.Get an unmodifiable map of classifications and their corresponding labels.getObjectsForRegion
(ImageRegion region) Get the objects to be painted that fall within a specified region.Get the original metadata read during creation of the server.A string describing the type of server, for example the name of the library used (Openslide, Bioformats...)getURIs()
Get the URIs for images required for this server.boolean
isEmptyRegion
(RegionRequest request) Returns true if there are no objects to be painted within the requested region.protected BufferedImage
readTile
(TileRequest tileRequest) Read a single image tile.void
setMetadata
(ImageServerMetadata metadata) Throws an exception - metadata should not be set for a hierarchy image server directly.Methods inherited from class qupath.lib.images.servers.AbstractTileableImageServer
allowSmoothInterpolation, getDefaultColorModel, getEmptyTile, getEmptyTile, getTile, readRegion
Methods inherited from class qupath.lib.images.servers.AbstractImageServer
finalize, getAssociatedImage, getAssociatedImageList, getBuilder, getCache, getCachedTile, getChannel, getDefaultThumbnail, getDownsampleForResolution, getHeight, getImageClass, getMetadata, getPath, getPixelType, getPreferredDownsamples, getThumbnailDownsampleFactor, getTileRequestManager, getWidth, isRGB, nChannels, nResolutions, nTimepoints, nZSlices, toString
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface qupath.lib.images.servers.ImageServer
getAssociatedImage, getAssociatedImageList, getBuilder, getCachedTile, getChannel, getDefaultThumbnail, getDownsampleForResolution, getHeight, getImageClass, getMetadata, getPath, getPixelCalibration, getPixelType, getPreferredDownsamples, getTileRequestManager, getWidth, isRGB, nChannels, nResolutions, nTimepoints, nZSlices, readBufferedImage, readRegion, readRegion, readRegion
-
Method Details
-
getInstanceLabels
Get a mapping between objects and instance labels.- Returns:
- the instance label map, or an empty map if no objects are available or
LabeledImageServer.Builder.useInstanceLabels()
was not selected.
-
getLabels
Get an unmodifiable map of classifications and their corresponding labels. Note that multiple classifications may use the same integer label.- Returns:
- a map of labels, or empty map if none are available or
useInstanceLabels()
was selected.
-
getBoundaryLabels
Get an unmodifiable map of classifications and their corresponding boundary labels, if available. Note that multiple classifications may use the same integer label.- Returns:
- a map of boundary labels, or empty map if none are available or
useInstanceLabels()
was selected.
-
createServerBuilder
Returns null (does not support ServerBuilders).- Specified by:
createServerBuilder
in classAbstractImageServer<BufferedImage>
- Returns:
-
getURIs
Description copied from interface:ImageServer
Get the URIs for images required for this server. In the simplest case, this is a singleton list returning a URI representing a local file. However, some ImageServers may not have an associated URI at all, whereas others may depend upon multiple URIs (e.g. if concatenating images).Note: A URI alone may not be sufficient to recreate even a simple ImageServer; see
ImageServer.getBuilder()
.- Specified by:
getURIs
in interfaceImageServer<BufferedImage>
- Returns:
-
createID
Returns a UUID.- Specified by:
createID
in classAbstractImageServer<BufferedImage>
- Returns:
-
isEmptyRegion
Returns true if there are no objects to be painted within the requested region.- Specified by:
isEmptyRegion
in interfaceImageServer<BufferedImage>
- Overrides:
isEmptyRegion
in classAbstractImageServer<BufferedImage>
- Parameters:
request
-- Returns:
-
getObjectsForRegion
Get the objects to be painted that fall within a specified region. Note that this does not take into consideration line thickness, and therefore results are not guaranteed to matchisEmptyRegion(RegionRequest)
; in other worse, an object might fall outside the region but still influence an image type because of thick lines being drawn. If thicker lines should influence the result, the region should be padded accordingly.- Parameters:
region
-- Returns:
- a list of objects with ROIs that intersect the specified region
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Overrides:
close
in classAbstractImageServer<BufferedImage>
-
getServerType
Description copied from interface:ImageServer
A string describing the type of server, for example the name of the library used (Openslide, Bioformats...)- Specified by:
getServerType
in interfaceImageServer<BufferedImage>
- Returns:
-
getOriginalMetadata
Description copied from interface:ImageServer
Get the original metadata read during creation of the server. This may or may not be correct.- Specified by:
getOriginalMetadata
in interfaceImageServer<BufferedImage>
- Returns:
- See Also:
-
setMetadata
Throws an exception - metadata should not be set for a hierarchy image server directly. Any changes should be made to the underlying image server for which this server represents an object hierarchy.- Specified by:
setMetadata
in interfaceImageServer<BufferedImage>
- Overrides:
setMetadata
in classAbstractImageServer<BufferedImage>
- Parameters:
metadata
-
-
createDefaultRGBImage
Description copied from class:AbstractTileableImageServer
Create the default (blank) RGB image for this server.By default this will have
TYPE_INT_RGB
but a subclass may change this if necessary (e.g. to incorporate an alpha channel).- Overrides:
createDefaultRGBImage
in classAbstractTileableImageServer
- Parameters:
width
-height
-- Returns:
-
readTile
Description copied from class:AbstractTileableImageServer
Read a single image tile.- Specified by:
readTile
in classAbstractTileableImageServer
- Parameters:
tileRequest
-- Returns:
- Throws:
IOException
-