Class AbstractTileableImageServer

java.lang.Object
qupath.lib.images.servers.AbstractImageServer<BufferedImage>
qupath.lib.images.servers.AbstractTileableImageServer
All Implemented Interfaces:
AutoCloseable, ImageServer<BufferedImage>
Direct Known Subclasses:
BioFormatsImageServer, LabeledImageServer, OpenslideImageServer, PathHierarchyImageServer, PixelClassificationImageServer, RenderedImageServer, SparseImageServer, WrappedBufferedImageServer

public abstract class AbstractTileableImageServer extends AbstractImageServer<BufferedImage>
Abstract 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 Details

    • AbstractTileableImageServer

      protected AbstractTileableImageServer()
  • Method Details

    • getEmptyTile

      protected BufferedImage getEmptyTile(int width, int height) throws IOException
      Throws:
      IOException
    • getEmptyTile

      protected BufferedImage getEmptyTile(int width, int height, boolean doCache) throws IOException
      Create an empty tile for this server, using the default color model.
      Parameters:
      width -
      height -
      doCache -
      Returns:
      Throws:
      IOException
    • getDefaultColorModel

      protected ColorModel getDefaultColorModel() throws IOException
      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

      protected abstract BufferedImage readTile(TileRequest tileRequest) throws IOException
      Read a single image tile.
      Parameters:
      tileRequest -
      Returns:
      Throws:
      IOException
    • getTile

      protected BufferedImage getTile(TileRequest tileRequest) throws IOException
      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

      protected BufferedImage createDefaultRGBImage(int width, int height)
      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

      public BufferedImage readRegion(RegionRequest request) throws IOException
      Description copied from interface: ImageServer
      Read a 2D(+C) image region for a specified RegionRequest. 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 not ImageServerMetadata.ChannelType.CLASSIFICATION.
      Returns: