Class OMEPyramidWriter

java.lang.Object
qupath.lib.images.writers.ome.OMEPyramidWriter

public class OMEPyramidWriter extends Object
Write OME-TIFF files based on QuPath ImageServers.

The files may optionally be pyramidal TIFFs. Some key metadata is set (e.g. channel names/colors, pixel size), and an effort is made to support multidimensional images - but this has not been extensively checked.

Currently the magnification is not written, nor is the full OME XML metadata, and images written using this class should not be assumed to contain all the necessary information, correctly or at all (i.e. always keep your original data files!).

Note this requires Bio-Formats v6.0.0 or later.

Author:
Pete Bankhead

modified by @phaub , 04'2021 (JPEG support for nChannels > 1, sanity check)

  • Method Details

    • writeImage

      public void writeImage(String path) throws FormatException, IOException
      Write an image consisting of one or more series to the specified path.
      Parameters:
      path -
      Throws:
      FormatException
      IOException
      See Also:
    • createWriter

      public static OMEPyramidWriter createWriter(OMEPyramidWriter.OMEPyramidSeries... series)
      Create a writer capable of writing an image with one or more series.
      Parameters:
      series -
      Returns:
    • createWriter

      public static OMEPyramidWriter createWriter(Collection<OMEPyramidWriter.OMEPyramidSeries> series)
      Create a writer capable of writing an image with a collection of series.
      Parameters:
      series -
      Returns:
    • writeImage

      public static void writeImage(ImageServer<BufferedImage> server, String path) throws FormatException, IOException
      Static helper method to write an image using Bio-Formats. This is primarily intended for saving whole slide images as pyramidal OME-TIFF, but other formats are supported.
      Parameters:
      server -
      path -
      Throws:
      FormatException
      IOException
    • writeImage

      public static void writeImage(ImageServer<BufferedImage> server, String path, OMEPyramidWriter.CompressionType compression) throws FormatException, IOException
      Static helper method to write an image using Bio-Formats with the specified compression. This is primarily intended for saving whole slide images as pyramidal OME-TIFF, but other formats are supported.
      Parameters:
      server -
      path -
      compression -
      Throws:
      FormatException
      IOException
    • writeImage

      public static void writeImage(ImageServer<BufferedImage> server, String path, OMEPyramidWriter.CompressionType compression, ImageRegion region) throws FormatException, IOException
      Static helper method to write an image region using Bio-Formats with the specified compression. If region is null, the entire image will be written. If region is not null, it defines the bounding box of the exported pixels in addition to the z-slice and timepoint.
      Parameters:
      server - image to write
      path - path to output file
      compression - image compression method; may be null to use the default compression
      region - the region to export. If this is a RegionRequest that defines a downsample other than the default for the server, this downsample will be used.
      Throws:
      FormatException
      IOException
    • writeImage

      public static void writeImage(ImageServer<BufferedImage> server, String path, OMEPyramidWriter.CompressionType compression, ImageRegion region, boolean allZ, boolean allT) throws FormatException, IOException
      Static helper method to write an image using Bio-Formats for a defined region with the specified compression, optionally including all z-slices or timepoints. This is intended primarily to write (possibly pyramidal) OME-TIFF images; other formats may support fewer image types and dimensions.
      Parameters:
      server - image to write
      path - path to output file
      compression - image compression method; may be null to use the default compression
      region - the region to export. If this is a RegionRequest that defines a downsample other than the default for the server, this downsample will be used.
      allZ - if true, export all z-slices otherwise export slice defined by region (ignored if image is not a z-stack)
      allT - if true, export all timepoints otherwise export timepoint defined by region (ignored if image is not a timeseries)
      Throws:
      FormatException
      IOException