Class AbstractTileableImageServer
- All Implemented Interfaces:
AutoCloseable
,ImageServer<BufferedImage>
- Direct Known Subclasses:
BioFormatsImageServer
,LabeledImageServer
,OpenslideImageServer
,PathHierarchyImageServer
,PixelClassificationImageServer
,RenderedImageServer
,SparseImageServer
,WrappedBufferedImageServer
ImageServer
for BufferedImages that internally breaks up requests into constituent tiles.
The actual request is then handled by assembling the tiles, resizing as required.
This makes it possible to cache tiles and reuse them more efficiently, and often requires less effort
to implement a new ImageServer
.
- Author:
- Pete Bankhead
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Returns true if this server is permitted to use smooth interpolation when resizing.protected BufferedImage
createDefaultRGBImage
(int width, int height) Create the default (blank) RGB image for this server.protected ColorModel
Get an appropriate colormodel that may be used.protected BufferedImage
getEmptyTile
(int width, int height) protected BufferedImage
getEmptyTile
(int width, int height, boolean doCache) Create an empty tile for this server, using the default color model.protected BufferedImage
getTile
(TileRequest tileRequest) Get a tile for the request - ideally from the cache, but otherwise read it and then add it to the cache.readRegion
(RegionRequest request) Read a 2D(+C) image region for a specifiedRegionRequest
.protected abstract BufferedImage
readTile
(TileRequest tileRequest) Read a single image tile.Methods inherited from class qupath.lib.images.servers.AbstractImageServer
close, createID, createServerBuilder, finalize, getAssociatedImage, getAssociatedImageList, getBuilder, getCache, getCachedTile, getChannel, getDefaultThumbnail, getDownsampleForResolution, getHeight, getImageClass, getMetadata, getPath, getPixelType, getPreferredDownsamples, getThumbnailDownsampleFactor, getTileRequestManager, getWidth, isEmptyRegion, isRGB, nChannels, nResolutions, nTimepoints, nZSlices, setMetadata, 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
getOriginalMetadata, getPixelCalibration, getServerType, getURIs, readBufferedImage, readRegion, readRegion
-
Constructor Details
-
AbstractTileableImageServer
protected AbstractTileableImageServer()
-
-
Method Details
-
getEmptyTile
- Throws:
IOException
-
getEmptyTile
Create an empty tile for this server, using the default color model.- Parameters:
width
-height
-doCache
-- Returns:
- Throws:
IOException
-
getDefaultColorModel
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.- Returns:
- Throws:
IOException
-
readTile
Read a single image tile.- Parameters:
tileRequest
-- Returns:
- Throws:
IOException
-
getTile
Get a tile for the request - ideally from the cache, but otherwise read it and then add it to the cache.- Parameters:
tileRequest
-- Returns:
- Throws:
IOException
-
createDefaultRGBImage
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).- Parameters:
width
-height
-- Returns:
-
readRegion
Description copied from interface:ImageServer
Read 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
- See Also:
-
allowSmoothInterpolation
protected boolean allowSmoothInterpolation()Returns true if this server is permitted to use smooth interpolation when resizing. The default implementation returns true if the channel type is notImageServerMetadata.ChannelType.CLASSIFICATION
.- Returns:
-