Class XLEFReader

All Implemented Interfaces:
Closeable, AutoCloseable, ICompressedTileReader, IFormatHandler, IFormatReader, IMetadataConfigurable, IPyramidHandler

public class XLEFReader extends LMSFileReader
XLEFReader is the file format reader for Leica Microsystems' XLEF files.
Author:
Melissa Linkert melissa at glencoesoftware.com, Constanze Wendlandt constanze.wendlandt at leica-microsystems.com
  • Field Details

  • Constructor Details

    • XLEFReader

      public XLEFReader()
      Constructs a new Leica XLEF reader.
  • Method Details

    • openBytes

      public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException
      Description copied from interface: IFormatReader
      Obtains a sub-image of the specified image plane into a pre-allocated byte array.
      Specified by:
      openBytes in interface IFormatReader
      Specified by:
      openBytes in class FormatReader
      Parameters:
      no - the plane index within the current series.
      buf - a pre-allocated buffer.
      x - X coordinate of the upper-left corner of the sub-image
      y - Y coordinate of the upper-left corner of the sub-image
      w - width of the sub-image
      h - height of the sub-image
      Returns:
      the pre-allocated buffer buf for convenience.
      Throws:
      FormatException - if there was a problem parsing the metadata of the file.
      IOException - if there was a problem reading the file.
    • openBytes

      public byte[] openBytes(int no, int x, int y, int w, int h) throws FormatException, IOException
      Description copied from interface: IFormatReader
      Obtains a sub-image of the specified image plane, whose upper-left corner is given by (x, y).
      Specified by:
      openBytes in interface IFormatReader
      Overrides:
      openBytes in class FormatReader
      Throws:
      FormatException
      IOException
    • initFile

      protected void initFile(String id) throws FormatException, IOException
      Description copied from class: FormatReader
      Initializes the given file (parsing header information, etc.). Most subclasses should override this method to perform initialization operations such as parsing metadata.
      Overrides:
      initFile in class FormatReader
      Throws:
      FormatException - if a parsing error occurs processing the file.
      IOException - if an I/O error occurs processing the file
    • isSingleFile

      public boolean isSingleFile(String id) throws FormatException, IOException
      Description copied from interface: IFormatReader
      Returns true if the named file is expected to be the only file in the dataset. For single-file formats, always returns true.
      Specified by:
      isSingleFile in interface IFormatReader
      Overrides:
      isSingleFile in class FormatReader
      Throws:
      FormatException
      IOException
    • fileGroupOption

      public int fileGroupOption(String id) throws FormatException, IOException
      Description copied from interface: IFormatReader
      Returns an indication of whether the files in a multi-file dataset can be handled individually. This method is only useful for formats and datasets which contain multiple files.
      Specified by:
      fileGroupOption in interface IFormatReader
      Overrides:
      fileGroupOption in class FormatReader
      Parameters:
      id - a file in the multi-file dataset
      Returns:
      an int indicating that we cannot, must, or might group the files. A return value of FormatTools.MUST_GROUP indicates that the files cannot be handled separately; the reader will always detect and read all files in the dataset. FormatTools.CAN_GROUP indicates that the files may be handled separately, but file grouping must then be disabled via IFormatReader.setGroupFiles(boolean). FormatTools.CANNOT_GROUP indicates that the files must be handled separately; the reader will not attempt to read all files in the dataset (this is rare).
      Throws:
      FormatException
      IOException
      See Also:
    • getUsedFiles

      public String[] getUsedFiles(boolean noPixels)
      Description copied from interface: IFormatReader
      Returns an array of filenames needed to open this dataset. If the 'noPixels' flag is set, then only files that do not contain pixel data will be returned. The first element in the array is expected to be the path passed to IFormatHandler.setId(String), if appropriate based upon 'noPixels'. The remaining elements are expected to be in a consistent order; if a directory listing is necessary to build the list then it should be sorted first.
      Specified by:
      getUsedFiles in interface IFormatReader
      Overrides:
      getUsedFiles in class FormatReader
    • getSeriesUsedFiles

      public String[] getSeriesUsedFiles(boolean noPixels)
      Description copied from interface: IFormatReader
      Returns an array of filenames needed to open the current series. If the 'noPixels' flag is set, then only files that do not contain pixel data will be returned. The first element in the array is expected to be the path passed to IFormatHandler.setId(String), if appropriate based upon 'noPixels'. The remaining elements are expected to be in a consistent order; if a directory listing is necessary to build the list then it should be sorted first.
      Specified by:
      getSeriesUsedFiles in interface IFormatReader
      Overrides:
      getSeriesUsedFiles in class FormatReader
    • close

      public void close(boolean fileOnly) throws IOException
      Description copied from interface: IFormatReader
      Closes the currently open file. If the flag is set, this is all that happens; if unset, it is equivalent to calling Closeable.close().
      Specified by:
      close in interface IFormatReader
      Overrides:
      close in class LMSFileReader
      Throws:
      IOException
    • reopenFile

      public void reopenFile() throws IOException
      Description copied from interface: IFormatReader
      Reopen any files that were closed, and which are expected to be open while the reader is open. This assumes that IFormatHandler.setId(java.lang.String) has been called, but close(false) has not been called.
      Specified by:
      reopenFile in interface IFormatReader
      Overrides:
      reopenFile in class FormatReader
      Throws:
      IOException
    • getImageFormat

      public LMSFileReader.ImageFormat getImageFormat()
      Description copied from class: LMSFileReader
      Returns the file format in which actual image bytes are stored
      Specified by:
      getImageFormat in class LMSFileReader
    • getReaderIndex

      private int getReaderIndex(int seriesIndex)
      Returns the index of the correct reader for the series index. Currently, tilescans are treated as if each tile was an own series (like in LIFReader), so one reader may contain multiple series.
      Parameters:
      seriesIndex - index of series
      Returns:
      reader which contains the series
    • getSeriesPerReaderIndex

      private int getSeriesPerReaderIndex(int series)
      Returns the index of the series (tile) in the corresponding reader
      Parameters:
      series - index of the series over all readers
      Returns:
    • openBytesJpeg

      private byte[] openBytesJpeg(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException
      Gets bytes of jpeg images. Originally monochrome images that were stored by LASX as 24bit (RGB) jpegs are transformed to monochrome again (upscaled to their original bit depth)
      Parameters:
      no - the plane index within the current series
      buf - a pre-allocated buffer
      x - X coordinate of the upper-left corner of the sub-image
      y - Y coordinate of the upper-left corner of the sub-image
      w - width of the sub-image
      h - height of the sub-image
      Returns:
      Throws:
      FormatException
      IOException
    • sortMultipleImagesReaders

      private void sortMultipleImagesReaders() throws FormatException
      Sorts frames of all MultipleImagesReaders as per core dimension sizes and order
      Throws:
      FormatException
    • setMetadataOfMultipleImagesReaders

      private void setMetadataOfMultipleImagesReaders()
    • transformBytes8To16

      private void transformBytes8To16(byte[] in, byte[] out, int outRes)
      Transforms an 8bit byte array to a 16bit byte array, optionally with bit upscaling (8-16bit)
      Parameters:
      in - 8bit buffer with data
      out - 16bit buffer to be filled
      outRes - resolution to which data shall be upscaled (8-16)
    • getRgbChannel

      private byte[] getRgbChannel(int channel, byte[] in)
      Returns single channel data for an rgb plane
      Parameters:
      channel - Index of channel that shall be read
      in - channel separated buffer
    • sum

      private int sum(int[] arr, int start, int end)
      Sums up all values of an array, from start index to (including) end index
      Parameters:
      arr -
      start - first array position whose value shall be added
      end - last array position whose value shall be added
      Returns:
    • sortPaths

      private void sortPaths(List<String> paths)
      Sorts file paths by name and depth and moves current file path to the beginning
      Parameters:
      paths -