Class PixelClassificationImageServer
- All Implemented Interfaces:
AutoCloseable
,ImageServer<BufferedImage>
- Author:
- Pete Bankhead
-
Constructor Summary
ConstructorDescriptionPixelClassificationImageServer
(ImageData<BufferedImage> imageData, PixelClassifier classifier) Constructor.PixelClassificationImageServer
(ImageData<BufferedImage> imageData, PixelClassifier classifier, String customID, ColorModel colorModel) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
createID()
Returns a random UUID.protected ImageServerBuilder.ServerBuilder
<BufferedImage> Returns null (does not support ServerBuilders).getCachedTile
(TileRequest tile) Get a cached tile, or null if the tile has not been cached.Get the PixelClassifier performing the classification.protected ColorModel
Get an appropriate colormodel that may be used.Get the underlying ImageData used for classification.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.void
Read all the tiles.protected BufferedImage
readTile
(TileRequest tileRequest) Read a single image tile.void
setMetadata
(ImageServerMetadata metadata) Not allowed - throws anUnsupportedOperationException
.Methods inherited from class qupath.lib.images.servers.AbstractTileableImageServer
allowSmoothInterpolation, createDefaultRGBImage, getEmptyTile, getEmptyTile, getTile, readRegion
Methods inherited from class qupath.lib.images.servers.AbstractImageServer
close, finalize, getAssociatedImage, getAssociatedImageList, getBuilder, getCache, getChannel, getDefaultThumbnail, getDownsampleForResolution, getHeight, getImageClass, getMetadata, getPath, getPixelType, getPreferredDownsamples, getThumbnailDownsampleFactor, getTileRequestManager, getWidth, isEmptyRegion, 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
getPixelCalibration, readBufferedImage, readRegion, readRegion
-
Constructor Details
-
PixelClassificationImageServer
public PixelClassificationImageServer(ImageData<BufferedImage> imageData, PixelClassifier classifier) Constructor.An
ImageData
is required because some forms of classification may required additional image properties (e.g. image type, stains), not simply anImageServer
.- Parameters:
imageData
-classifier
-
-
PixelClassificationImageServer
public PixelClassificationImageServer(ImageData<BufferedImage> imageData, PixelClassifier classifier, String customID, ColorModel colorModel) Constructor.- Parameters:
imageData
-classifier
-customID
- optionally provide a custom ID (path). This is when the default (based upon theImageData
andPixelClassifier
isn't sufficient), e.g. because the classifier can change output based uponImageData
status.colorModel
- optional colormodel
-
-
Method Details
-
readAllTiles
public void readAllTiles()Read all the tiles. This is useful for a classifier that can be applied in full to an image without causing memory issues (e.g. a density map), particularly if it is is dependent upon a changing property of the image (e.g. its object hierarchy). After calling this method, tiles will be returned from an internal cache rather than being computed anew. -
getDefaultColorModel
Description copied from class:AbstractTileableImageServer
Get an appropriate colormodel that may be used. The default implementation uses the default RGB color model for RGB images, or else requests a low-resolution thumbnail to extract the color model from it. If neither implementation is sufficient, subclasses should override this method.- Overrides:
getDefaultColorModel
in classAbstractTileableImageServer
- Returns:
- Throws:
IOException
-
createID
Returns a random UUID.- Specified by:
createID
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()
.- Returns:
-
getImageData
Get the underlying ImageData used for classification.- Returns:
-
getClassifier
Get the PixelClassifier performing the classification.- Returns:
-
getServerType
Description copied from interface:ImageServer
A string describing the type of server, for example the name of the library used (Openslide, Bioformats...)- Returns:
-
getOriginalMetadata
Description copied from interface:ImageServer
Get the original metadata read during creation of the server. This may or may not be correct.- Returns:
- See Also:
-
setMetadata
Not allowed - throws anUnsupportedOperationException
.- Specified by:
setMetadata
in interfaceImageServer<BufferedImage>
- Overrides:
setMetadata
in classAbstractImageServer<BufferedImage>
- Parameters:
metadata
-- Throws:
UnsupportedOperationException
-
getCachedTile
Description copied from class:AbstractImageServer
Get a cached tile, or null if the tile has not been cached.This is useful whenever it is important to return quickly rather than wait for a tile to be fetched or generated.
Warning! The cached tile is returned directly (with no defensive copying) for performance. This means that it must not be modified by the code that requests it. If there is any chance the tile may be modified (or passed to untrusted code), then make sure to make a defensive copy, e.g. using
BufferedImageTools.duplicate(java.awt.image.BufferedImage)
if using a buffered image.- Specified by:
getCachedTile
in interfaceImageServer<BufferedImage>
- Overrides:
getCachedTile
in classAbstractImageServer<BufferedImage>
- Parameters:
tile
-- Returns:
- the tile if it has been cached, or null if no cached tile is available for the request.
-
readTile
Description copied from class:AbstractTileableImageServer
Read a single image tile.- Specified by:
readTile
in classAbstractTileableImageServer
- Parameters:
tileRequest
-- Returns:
- Throws:
IOException
-
createServerBuilder
Returns null (does not support ServerBuilders).- Specified by:
createServerBuilder
in classAbstractImageServer<BufferedImage>
- Returns:
-