Interface ImageServer<T>
- Type Parameters:
- T-
- All Superinterfaces:
- AutoCloseable
- All Known Subinterfaces:
- GeneratingImageServer<T>,- ImageDataServer<T>
- All Known Implementing Classes:
- AbstractImageServer,- AbstractTileableImageServer,- AffineTransformImageServer,- BioFormatsImageServer,- ChannelDisplayTransformServer,- ChannelTransformFeatureServer,- CroppedImageServer,- ImageJServer,- LabeledImageServer,- NormalizedImageServer,- OpenslideImageServer,- PathHierarchyImageServer,- PixelClassificationImageServer,- RearrangeRGBImageServer,- RenderedImageServer,- RotatedImageServer,- SlicedImageServer,- SparseImageServer,- TiledTransformingImageServer,- TransformingImageServer,- TypeConvertImageServer,- WrappedBufferedImageServer,- ZConcatenatedImageServer,- ZProjectedImageServer
 The idea behind making this generic was that it could be used on various platforms and with different UIs, e.g. Swing, JavaFX, 
 or with different kinds of image reader.
 In practice, the generic parameter is almost always BufferedImage.
 
 Important! The readBufferedImage(RegionRequest) method was replaced by readRegion(RegionRequest) in 
 v0.4.0. Implementing classes need only to worry about overriding readRegion(RegionRequest) - and legacy implementations 
 should be updated to override the new method rather than the old one.
 Default implementations of both methods exist to try to ease the transition, but this may change in the future and 
 readBufferedImage(RegionRequest) is likely to be removed.
- 
Method SummaryModifier and TypeMethodDescriptiongetAssociatedImage(String name) Get the image for a given associated image name.Get a list of 'associated images', e.g.default ImageServerBuilder.ServerBuilder<T> Get a ServerBuilder capable of building a server the same as this one.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.Get the original metadata read during creation of the server.getPath()Get a String path that can uniquely identify this image.default PixelCalibrationGet the PixelCalibration object from the current metadata.The bit-depth and type of the image.double[]Get an array of downsample factors supported by the serverA string describing the type of server, for example the name of the library used (Openslide, Bioformats...)Get a TileRequestManager that can be used to identify image tiles that may be efficiently requested from this ImageServer.getURIs()Get the URIs for images required for this server.intgetWidth()Width of the full-resolution image in pixels.booleanisEmptyRegion(RegionRequest request) Test whether a region is empty, i.e.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.default TreadBufferedImage(RegionRequest request) Deprecated.since v0.4.0.default TreadRegion(double downsample, int x, int y, int width, int height) Read a 2D(+C) image region from the defaultImagePlane(i.e.default TreadRegion(double downsample, int x, int y, int width, int height, int z, int t) Read a 2D(+C) image region for a specified z-plane and timepoint.default TreadRegion(RegionRequest request) Read a 2D(+C) image region for a specifiedRegionRequest.voidsetMetadata(ImageServerMetadata metadata) Set the metadata to use, e.g.Methods inherited from interface java.lang.AutoCloseableclose
- 
Method Details- 
getPathString getPath()Get a String path that can uniquely identify this image.For most standard images, this should be a String representation of an absolute URI. If multiple images are stored within the same file, then this information should be encoded in the URI. For images that are generated some other way (e.g. created dynamically) the path may not lend itself to a URI representation, but must still be unique so that it can be used for caching tiles. - Returns:
 
- 
getURIsCollection<URI> getURIs()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 getBuilder().- Returns:
 
- 
getPreferredDownsamplesdouble[] getPreferredDownsamples()Get an array of downsample factors supported by the server- Returns:
 
- 
nResolutionsint nResolutions()Number of resolutions for the image.This is equivalent to getPreferredDownsamples().length.- Returns:
 
- 
getDownsampleForResolutiondouble getDownsampleForResolution(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.- Parameters:
- level- Resolution level, should be 0 <= level < nResolutions().
- Returns:
 
- 
getWidthint getWidth()Width of the full-resolution image in pixels.- Returns:
 
- 
getHeightint getHeight()Height of the full-resolution image in pixels.- Returns:
 
- 
nChannelsint nChannels()Number of channels (3 for RGB).- Returns:
 
- 
isRGBboolean isRGB()True if the image has 8-bit red, green & blue channels (and nothing else), false otherwise.- Returns:
 
- 
nZSlicesint nZSlices()Number of slices in a z-stack.- Returns:
 
- 
nTimepointsint nTimepoints()Number of time points in a time series.- Returns:
 
- 
getPixelCalibrationGet the PixelCalibration object from the current metadata.- Returns:
 
- 
getCachedTileGet 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! This method should be used very cautiously, as it is permitted to return the tile stored internally in the cache for performance. This must not be modified by any code requesting the tile. - Parameters:
- tile-
- Returns:
- the tile if it has been cached, or null if no cached tile is available for the request.
- Implementation Requirements
- because this method exists for performance, the tile may be returned directly without defensive copying. If the tile is mutable, consumers must be extremely careful to avoid modifying the tile.
 
- 
readBufferedImageDeprecated.since v0.4.0. Implementations ofImageServershould overridereadRegion(RegionRequest)instead. This method will be removed in a future release; it exists now only to maintain compatibility with QuPath extensions that have not yet been updated to use the newer method.Legacy method to request pixels for aRegionRequest, now replaced byreadRegion(RegionRequest). This method is deprecated; if the generic parameter<T>represented anything other than aBufferedImagethen its name became misleading.- Parameters:
- request- the region for which pixels are requested
- Returns:
- pixels for the region being requested
- Throws:
- IOException
- Implementation Note
- The default implementation simply calls readRegion(RegionRequest)
 
- 
readRegionRead a 2D(+C) image region for a specifiedRegionRequest. Coordinates and bounding box dimensions from the request are in pixel units, at the full image resolution (i.e. when downsample = 1).All channels are always returned. No specific checking is guaranteed to ensure that the request is valid, e.g. if it extends beyond the image boundary then it is likely (but not certain) that the returned image will be cropped accordingly - but some implementations may contain empty padding instead. Therefore it is up to the caller to ensure that the requests are within range. However, it is expected that any returnable region will be at least 1x1 pixel in size, even if via high downsampling one might otherwise expect a 0x0 image. This is consistent with the idea of pixels representing point samples rather than little squares. Note: One should avoid returning null, as this cannot be stored as a value in some map implementations that may be used for caching. - Parameters:
- request- the region for which pixels are requested
- Returns:
- pixels for the region being requested
- Throws:
- IOException
- Since:
- v0.4.0
- See Also:
- Implementation Note
- Implementations of ImageServermust override this method! The default implementation exists to search for the (deprecated)readBufferedImage(RegionRequest)method, so as to maintain compatibility with olderImageServerimplementations - and throws anUnsupportedOperationExceptionif this is not found.
 
- 
readRegiondefault T readRegion(double downsample, int x, int y, int width, int height, int z, int t) throws IOException Read a 2D(+C) image region for a specified z-plane and timepoint. Coordinates and bounding box dimensions are in pixel units, at the full image resolution (i.e. when downsample = 1).All channels are always returned. - Parameters:
- downsample- downsample factor for the region
- x- x coordinate of the top left of the region bounding box
- y- y coordinate of the top left of the region bounding box
- width- bounding box width
- height- bounding box height
- z- index for the z-position
- t- index for the timepoint
- Returns:
- pixels for the region being requested
- Throws:
- IOException
- Since:
- v0.4.0
- See Also:
 
- 
readRegionRead a 2D(+C) image region from the defaultImagePlane(i.e. z and t are 0). Coordinates and bounding box dimensions are in pixel units, at the full image resolution (i.e. when downsample = 1).All channels are always returned. - Parameters:
- downsample- downsample factor for the region
- x- x coordinate of the top left of the region bounding box
- y- y coordinate of the top left of the region bounding box
- width- bounding box width
- height- bounding box height
- Returns:
- pixels for the region being requested
- Throws:
- IOException
- Since:
- v0.4.0
- See Also:
 
- 
getServerTypeString getServerType()A string describing the type of server, for example the name of the library used (Openslide, Bioformats...)- Returns:
 
- 
getAssociatedImageListGet 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. - Returns:
- See Also:
 
- 
getAssociatedImageGet the image for a given associated image name.- Parameters:
- name-
- Returns:
- See Also:
 
- 
isEmptyRegionTest whether a region is empty, i.e. it contains nothing to be painted (e.g. the server paints objects but there are no objects present in the region) andreadRegion(RegionRequest)would return an empty tile.This makes it possible to avoid a (potentially more expensive) request to readRegion(RegionRequest), or to add it to a request queue, if we know there will be nothing to show for it.Note: Even if the method returns false it is possible that the region is still empty - the purpose of this method is to assist performance, and it should return quickly. Therefore if the calculations needed to identify if the region is empty are too onerous, it may conservatively return false. - Parameters:
- request-
- Returns:
 
- 
getPixelTypePixelType getPixelType()The 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.- Returns:
 
- 
getChannelRequest information for one channel (0-based index).- Parameters:
- channel-
- Returns:
- See Also:
 
- 
getMetadataImageServerMetadata getMetadata()Get essential metadata associated with the ImageServer as a distinct object. This may be edited by the user.- Returns:
- See Also:
 
- 
setMetadataSet the metadata to use, e.g. to change the pixel size in microns.- Parameters:
- metadata-
- Throws:
- IllegalArgumentException- if the metadata is incompatible (e.g. different image path, different bit-depth).
 
- 
getOriginalMetadataImageServerMetadata getOriginalMetadata()Get the original metadata read during creation of the server. This may or may not be correct.- Returns:
- See Also:
 
- 
getDefaultThumbnailGet 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. - Parameters:
- z-
- t-
- Returns:
- Throws:
- IOException
 
- 
getTileRequestManagerTileRequestManager getTileRequestManager()Get 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. - Returns:
 
- 
getImageClassGet the class of the image representation returned by this ImageServer.- Returns:
 
- 
getBuilderGet 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. - Returns:
 
 
-