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.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionprotected BufferedImagecreateDefaultRGBImage(int width, int height) Create the default (blank) RGB image for this server.protected StringcreateID()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.booleanisEmptyRegion(RegionRequest request) Returns true if there are no objects to be painted within the requested region.protected BufferedImagereadTile(TileRequest tileRequest) Read a single image tile.voidsetMetadata(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, readRegionMethods inherited from class qupath.lib.images.servers.AbstractImageServer
close, getAssociatedImage, getAssociatedImageList, getBuilder, getCache, getCachedTile, getChannel, getDefaultThumbnail, getDownsampleForResolution, getHeight, getImageClass, getMetadata, getPath, getPixelType, getPreferredDownsamples, getThumbnailDownsampleFactor, getTileRequestManager, getWidth, isRGB, nChannels, nResolutions, nTimepoints, nZSlices, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.AutoCloseable
closeMethods 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:
createServerBuilderin classAbstractImageServer<BufferedImage>- Returns:
-
getURIs
Description copied from interface:ImageServerGet 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:
getURIsin interfaceImageServer<BufferedImage>- Returns:
-
createID
Returns a UUID.- Specified by:
createIDin classAbstractImageServer<BufferedImage>- Returns:
-
isEmptyRegion
Returns true if there are no objects to be painted within the requested region.- Specified by:
isEmptyRegionin interfaceImageServer<BufferedImage>- Overrides:
isEmptyRegionin classAbstractImageServer<BufferedImage>- Parameters:
request-- Returns:
- API Note
- In v0.2 this performed a fast bounding box check only. In v0.3 it was updated to test ROIs fully for an intersection.
- Implementation Note
- Since v0.3 the request is expanded by the line thickness before testing intersection. In some edge cases, this might result in returning true even if nothing is drawn within the region. There remains a balance between returning quickly and giving an exact result.
-
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
-
getServerType
Description copied from interface:ImageServerA string describing the type of server, for example the name of the library used (Openslide, Bioformats...)- Specified by:
getServerTypein interfaceImageServer<BufferedImage>- Returns:
-
getOriginalMetadata
Description copied from interface:ImageServerGet the original metadata read during creation of the server. This may or may not be correct.- Specified by:
getOriginalMetadatain 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:
setMetadatain interfaceImageServer<BufferedImage>- Overrides:
setMetadatain classAbstractImageServer<BufferedImage>- Parameters:
metadata-
-
createDefaultRGBImage
Description copied from class:AbstractTileableImageServerCreate the default (blank) RGB image for this server.By default this will have
TYPE_INT_RGBbut a subclass may change this if necessary (e.g. to incorporate an alpha channel).- Overrides:
createDefaultRGBImagein classAbstractTileableImageServer- Parameters:
width-height-- Returns:
-
readTile
Description copied from class:AbstractTileableImageServerRead a single image tile.- Specified by:
readTilein classAbstractTileableImageServer- Parameters:
tileRequest-- Returns:
- Throws:
IOException
-