Class AbstractImageServer<T>
- Type Parameters:
T-
- All Implemented Interfaces:
AutoCloseable,ImageServer<T>
- Direct Known Subclasses:
AbstractTileableImageServer,TransformingImageServer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected abstract StringcreateID()Create a unique ID for the server, which can be returned as the default value ofgetPath().protected abstract ImageServerBuilder.ServerBuilder<T> Create a ServerBuilder, which can be used to construct an identical ImageServer.getAssociatedImage(String name) Get the image for a given associated image name.Get a list of 'associated images', e.g.Get a ServerBuilder capable of building a server the same as this one.protected Map<RegionRequest, T> getCache()Get the internal cache.getCachedTile(TileRequest tile) Get a cached tile, or null if the tile has not been cached.getChannel(int channel) Request information for one channel (0-based index).getDefaultThumbnail(int z, int t) Get the default thumbnail for a specified z-slice and timepoint.doublegetDownsampleForResolution(int level) Get the downsample factor for a specified resolution level, where level 0 is the full resolution image and nResolutions() - 1 is the lowest resolution available.intHeight of the full-resolution image in pixels.Get the class of the image representation returned by this ImageServer.Get essential metadata associated with the ImageServer as a distinct object.getPath()Default implementation lazily callscreateID()on demand.The bit-depth and type of the image.double[]Request the preferred downsamples from the image metadata.protected doublegetThumbnailDownsampleFactor(int maxWidth, int maxHeight) Get a TileRequestManager that can be used to identify image tiles that may be efficiently requested from this ImageServer.intgetWidth()Width of the full-resolution image in pixels.booleanisEmptyRegion(RegionRequest request) Always returns false.booleanisRGB()True if the image has 8-bit red, green & blue channels (and nothing else), false otherwise.intNumber of channels (3 for RGB).intNumber of resolutions for the image.intNumber of time points in a time series.intnZSlices()Number of slices in a z-stack.voidsetMetadata(ImageServerMetadata metadata) Set the metadata to use, e.g.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface qupath.lib.images.servers.ImageServer
getOriginalMetadata, getPixelCalibration, getServerType, getURIs, readBufferedImage, readRegion, readRegion, readRegion
-
Constructor Details
-
AbstractImageServer
-
-
Method Details
-
getImageClass
Description copied from interface:ImageServerGet the class of the image representation returned by this ImageServer.- Specified by:
getImageClassin interfaceImageServer<T>- Returns:
-
getCache
Get the internal cache. This may be useful to check for the existence of a cached tile any time when speed is of the essence, and if no cached tile is available a request will not be made.- Returns:
-
getThumbnailDownsampleFactor
protected double getThumbnailDownsampleFactor(int maxWidth, int maxHeight) -
createServerBuilder
Create a ServerBuilder, which can be used to construct an identical ImageServer. This should also include the current metadata. It is permissible to return null for an ImageServer that cannot be recreated via aImageServerBuilder.ServerBuilder.- Returns:
-
getBuilder
Description copied from interface:ImageServerGet a ServerBuilder capable of building a server the same as this one.The purpose of this is to aid serialization of servers by switching to a simpler representation.
The default implementation returns null, indicating that rebuilding the server is not supported.
- Specified by:
getBuilderin interfaceImageServer<T>- Returns:
-
getDownsampleForResolution
public double getDownsampleForResolution(int level) Description copied from interface:ImageServerGet the downsample factor for a specified resolution level, where level 0 is the full resolution image and nResolutions() - 1 is the lowest resolution available.- Specified by:
getDownsampleForResolutionin interfaceImageServer<T>- Parameters:
level- Resolution level, should be 0 <= level < nResolutions().- Returns:
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
nResolutions
public int nResolutions()Description copied from interface:ImageServerNumber of resolutions for the image.This is equivalent to
getPreferredDownsamples().length.- Specified by:
nResolutionsin interfaceImageServer<T>- Returns:
-
getPreferredDownsamples
public double[] getPreferredDownsamples()Request the preferred downsamples from the image metadata.Note that this makes a defensive copy of the array, so it is generally preferable to use
#getDownsampleForResolution(int)where possible.- Specified by:
getPreferredDownsamplesin interfaceImageServer<T>- Returns:
- See Also:
-
isRGB
public boolean isRGB()Description copied from interface:ImageServerTrue if the image has 8-bit red, green & blue channels (and nothing else), false otherwise.- Specified by:
isRGBin interfaceImageServer<T>- Returns:
-
getPixelType
Description copied from interface:ImageServerThe bit-depth and type of the image. This refers to a single channel, e.g. an 8-bit RGB image will have a type ofPixelType.UINT8.- Specified by:
getPixelTypein interfaceImageServer<T>- Returns:
-
isEmptyRegion
Always returns false.- Specified by:
isEmptyRegionin interfaceImageServer<T>- Parameters:
request-- Returns:
-
toString
-
getCachedTile
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:
getCachedTilein interfaceImageServer<T>- Parameters:
tile-- Returns:
- the tile if it has been cached, or null if no cached tile is available for the request.
-
createID
Create a unique ID for the server, which can be returned as the default value ofgetPath(). A suggested implementation isgetClass().getName() + ": " + URI + parameters
This will be called on demand whenevergetPath()is first required.- Returns:
-
getPath
Default implementation lazily callscreateID()on demand.- Specified by:
getPathin interfaceImageServer<T>- Returns:
- See Also:
-
getWidth
public int getWidth()Description copied from interface:ImageServerWidth of the full-resolution image in pixels.- Specified by:
getWidthin interfaceImageServer<T>- Returns:
-
getHeight
public int getHeight()Description copied from interface:ImageServerHeight of the full-resolution image in pixels.- Specified by:
getHeightin interfaceImageServer<T>- Returns:
-
nChannels
public int nChannels()Description copied from interface:ImageServerNumber of channels (3 for RGB).- Specified by:
nChannelsin interfaceImageServer<T>- Returns:
-
nZSlices
public int nZSlices()Description copied from interface:ImageServerNumber of slices in a z-stack.- Specified by:
nZSlicesin interfaceImageServer<T>- Returns:
-
nTimepoints
public int nTimepoints()Description copied from interface:ImageServerNumber of time points in a time series.- Specified by:
nTimepointsin interfaceImageServer<T>- Returns:
-
getMetadata
Description copied from interface:ImageServerGet essential metadata associated with the ImageServer as a distinct object. This may be edited by the user.- Specified by:
getMetadatain interfaceImageServer<T>- Returns:
- See Also:
-
setMetadata
Description copied from interface:ImageServerSet the metadata to use, e.g. to change the pixel size in microns.- Specified by:
setMetadatain interfaceImageServer<T>- Parameters:
metadata-
-
getAssociatedImageList
Description copied from interface:ImageServerGet a list of 'associated images', e.g. thumbnails or slide overview images.Each associated image is simply a T that does not warrant (or require) a full ImageServer, and most likely would never be analyzed.
- Specified by:
getAssociatedImageListin interfaceImageServer<T>- Returns:
- See Also:
-
getAssociatedImage
Description copied from interface:ImageServerGet the image for a given associated image name.- Specified by:
getAssociatedImagein interfaceImageServer<T>- Parameters:
name-- Returns:
- See Also:
-
getChannel
Description copied from interface:ImageServerRequest information for one channel (0-based index).- Specified by:
getChannelin interfaceImageServer<T>- Parameters:
channel-- Returns:
- See Also:
-
getDefaultThumbnail
Description copied from interface:ImageServerGet the default thumbnail for a specified z-slice and timepoint.This should be the lowest resolution image that is available in the case of the multiresolution image, or else the full image. For large datasets, it may be used to determine basic statistics or histograms without requiring every pixel to be visited in the full resolution image.
- Specified by:
getDefaultThumbnailin interfaceImageServer<T>- Parameters:
z-t-- Returns:
- Throws:
IOException
-
getTileRequestManager
Description copied from interface:ImageServerGet a TileRequestManager that can be used to identify image tiles that may be efficiently requested from this ImageServer.This is useful because managing arbitrary RegionRequests can result in inefficiencies if a request straddles multiple tiles unnecessarily. Also, it can be used to help ensure consistency whenever requesting regions at different resolutions, where rounding errors might otherwise occur.
Note that the TileRequestManager is not guaranteed to remain the same for the lifecycle of the server. For example, if the image metadata is changed then a new manager may be constructed.
- Specified by:
getTileRequestManagerin interfaceImageServer<T>- Returns:
-