Package loci.formats

Class MinMaxCalculator

java.lang.Object
loci.formats.ReaderWrapper
loci.formats.MinMaxCalculator
All Implemented Interfaces:
Closeable, AutoCloseable, loci.formats.ICompressedTileReader, loci.formats.IFormatHandler, loci.formats.IFormatReader, loci.formats.IMetadataConfigurable, loci.formats.IPyramidHandler

public class MinMaxCalculator extends loci.formats.ReaderWrapper
Logic to compute minimum and maximum values for each channel.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double[][]
    Max values for each channel.
    protected double[][]
    Min values for each channel.
    protected int[]
    Number of planes for which min/max computations have been completed.
    protected loci.formats.meta.IMinMaxStore
    Consumer of channel global minima and maxima
    protected double[][]
    Max values for each plane.
    protected double[][]
    Min values for each plane.

    Fields inherited from class loci.formats.ReaderWrapper

    reader

    Fields inherited from interface loci.formats.IFormatReader

    CAN_GROUP, CANNOT_GROUP, MUST_GROUP
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a MinMaxCalculator around a new image reader.
    MinMaxCalculator(loci.formats.IFormatReader r)
    Constructs a MinMaxCalculator with the given reader.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    close(boolean fileOnly)
     
    Retrieves a specified channel's global maximum.
    Retrieves a specified channel's global minimum.
    Retrieves the specified channel's maximum based on the images that have been read.
    Retrieves the specified channel's minimum based on the images that have been read.
    loci.formats.meta.IMinMaxStore
    Retrieves the current active min-max store for the calculator.
     
    Retrieves the maximum pixel value for the specified plane.
    Retrieves the minimum pixel value for the specified plane.
    protected void
    Ensures internal min/max variables are initialized properly.
    boolean
    Returns true if the values returned by getChannelGlobalMinimum/Maximum can be trusted.
    makeMinMaxCalculator(loci.formats.IFormatReader r)
    Converts the given reader into a MinMaxCalculator, wrapping if needed.
    byte[]
    openBytes(int no)
     
    byte[]
    openBytes(int no, byte[] buf)
     
    byte[]
    openBytes(int no, byte[] buf, int x, int y, int w, int h)
     
    byte[]
    openBytes(int no, int x, int y, int w, int h)
     
    void
    setMinMaxStore(loci.formats.meta.IMinMaxStore store)
    Sets the active min-max store for the calculator.
    protected void
    updateMinMax(int no, byte[] buf, int len)
    Updates min/max values based on the given byte array.

    Methods inherited from class loci.formats.ReaderWrapper

    close, coreIndexToSeries, duplicate, fileGroupOption, get16BitLookupTable, get8BitLookupTable, getAdvancedSeriesUsedFiles, getAdvancedUsedFiles, getBitsPerPixel, getCoreIndex, getCoreMetadataList, getCurrentFile, getDatasetStructureDescription, getDimensionOrder, getDomains, getEffectiveSizeC, getFillColor, getFormat, getGlobalMetadata, getImageCount, getIndex, getIndex, getMetadataOptions, getMetadataStore, getMetadataStoreRoot, getMetadataValue, getModuloC, getModuloT, getModuloZ, getOptimalTileHeight, getOptimalTileWidth, getPixelType, getPossibleDomains, getReader, getRequiredDirectories, getResolution, getResolutionCount, getRGBChannelCount, getSeries, getSeriesCount, getSeriesMetadata, getSeriesMetadataValue, getSeriesUsedFiles, getSeriesUsedFiles, getSizeC, getSizeT, getSizeX, getSizeY, getSizeZ, getSuffixes, getSupportedMetadataLevels, getThumbSizeX, getThumbSizeY, getTileBoundingBox, getTileCodec, getTileCodecOptions, getTileColumns, getTileRows, getUnderlyingReaders, getUsedFiles, getUsedFiles, getZCTCoords, getZCTModuloCoords, hasCompanionFiles, hasFlattenedResolutions, isFalseColor, isGroupFiles, isIndexed, isInterleaved, isInterleaved, isLittleEndian, isMetadataComplete, isMetadataFiltered, isNormalized, isOrderCertain, isOriginalMetadataPopulated, isRGB, isSingleFile, isThisType, isThisType, isThisType, isThisType, isThumbnailSeries, openCompressedBytes, openCompressedBytes, openPlane, openThumbBytes, reopenFile, seriesToCoreIndex, setCoreIndex, setFillColor, setFlattenedResolutions, setGroupFiles, setId, setMetadataFiltered, setMetadataOptions, setMetadataStore, setNormalized, setOriginalMetadataPopulated, setResolution, setSeries, unwrap, unwrap, unwrap

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • chanMin

      protected double[][] chanMin
      Min values for each channel.
    • chanMax

      protected double[][] chanMax
      Max values for each channel.
    • planeMin

      protected double[][] planeMin
      Min values for each plane.
    • planeMax

      protected double[][] planeMax
      Max values for each plane.
    • minMaxDone

      protected int[] minMaxDone
      Number of planes for which min/max computations have been completed.
    • minMaxStore

      protected loci.formats.meta.IMinMaxStore minMaxStore
      Consumer of channel global minima and maxima
  • Constructor Details

    • MinMaxCalculator

      public MinMaxCalculator()
      Constructs a MinMaxCalculator around a new image reader.
    • MinMaxCalculator

      public MinMaxCalculator(loci.formats.IFormatReader r)
      Constructs a MinMaxCalculator with the given reader.
  • Method Details

    • makeMinMaxCalculator

      public static MinMaxCalculator makeMinMaxCalculator(loci.formats.IFormatReader r)
      Converts the given reader into a MinMaxCalculator, wrapping if needed.
    • setMinMaxStore

      public void setMinMaxStore(loci.formats.meta.IMinMaxStore store)
      Sets the active min-max store for the calculator. Whenever a channel's global minimum and maximum calculation has been completed this store is notified.
      Parameters:
      store - See above.
    • getMinMaxStore

      public loci.formats.meta.IMinMaxStore getMinMaxStore()
      Retrieves the current active min-max store for the calculator.
      Returns:
      See above.
    • getChannelGlobalMinimum

      public Double getChannelGlobalMinimum(int theC) throws loci.formats.FormatException, IOException
      Retrieves a specified channel's global minimum. Returns null if some of the image planes have not been read.
      Throws:
      IOException - Not actually thrown.
      loci.formats.FormatException
    • getChannelGlobalMaximum

      public Double getChannelGlobalMaximum(int theC) throws loci.formats.FormatException, IOException
      Retrieves a specified channel's global maximum. Returns null if some of the image planes have not been read.
      Throws:
      IOException - Not actually thrown.
      loci.formats.FormatException
    • getChannelKnownMinimum

      public Double getChannelKnownMinimum(int theC) throws loci.formats.FormatException, IOException
      Retrieves the specified channel's minimum based on the images that have been read. Returns null if no image planes have been read yet.
      Throws:
      loci.formats.FormatException - Not actually thrown.
      IOException - Not actually thrown.
    • getChannelKnownMaximum

      public Double getChannelKnownMaximum(int theC) throws loci.formats.FormatException, IOException
      Retrieves the specified channel's maximum based on the images that have been read. Returns null if no image planes have been read yet.
      Throws:
      loci.formats.FormatException - Not actually thrown.
      IOException - Not actually thrown.
    • getPlaneMinimum

      public Double[] getPlaneMinimum(int no) throws loci.formats.FormatException, IOException
      Retrieves the minimum pixel value for the specified plane. If each image plane contains more than one channel (i.e., ReaderWrapper.getRGBChannelCount() > 1), returns the maximum value for each embedded channel. Returns null if the plane has not already been read.
      Throws:
      loci.formats.FormatException - Not actually thrown.
      IOException - Not actually thrown.
    • getPlaneMaximum

      public Double[] getPlaneMaximum(int no) throws loci.formats.FormatException, IOException
      Retrieves the maximum pixel value for the specified plane. If each image plane contains more than one channel (i.e., ReaderWrapper.getRGBChannelCount() > 1), returns the maximum value for each embedded channel. Returns null if the plane has not already been read.
      Throws:
      loci.formats.FormatException - Not actually thrown.
      IOException - Not actually thrown.
    • isMinMaxPopulated

      public boolean isMinMaxPopulated() throws loci.formats.FormatException, IOException
      Returns true if the values returned by getChannelGlobalMinimum/Maximum can be trusted.
      Throws:
      loci.formats.FormatException - Not actually thrown.
      IOException - Not actually thrown.
    • openBytes

      public byte[] openBytes(int no) throws loci.formats.FormatException, IOException
      Specified by:
      openBytes in interface loci.formats.IFormatReader
      Overrides:
      openBytes in class loci.formats.ReaderWrapper
      Throws:
      loci.formats.FormatException
      IOException
    • openBytes

      public byte[] openBytes(int no, byte[] buf) throws loci.formats.FormatException, IOException
      Specified by:
      openBytes in interface loci.formats.IFormatReader
      Overrides:
      openBytes in class loci.formats.ReaderWrapper
      Throws:
      loci.formats.FormatException
      IOException
    • openBytes

      public byte[] openBytes(int no, int x, int y, int w, int h) throws loci.formats.FormatException, IOException
      Specified by:
      openBytes in interface loci.formats.IFormatReader
      Overrides:
      openBytes in class loci.formats.ReaderWrapper
      Throws:
      loci.formats.FormatException
      IOException
    • openBytes

      public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws loci.formats.FormatException, IOException
      Specified by:
      openBytes in interface loci.formats.IFormatReader
      Overrides:
      openBytes in class loci.formats.ReaderWrapper
      Throws:
      loci.formats.FormatException
      IOException
    • close

      public void close(boolean fileOnly) throws IOException
      Specified by:
      close in interface loci.formats.IFormatReader
      Overrides:
      close in class loci.formats.ReaderWrapper
      Throws:
      IOException
    • getNativeDataType

      public Class<?> getNativeDataType()
      Specified by:
      getNativeDataType in interface loci.formats.IFormatHandler
      Overrides:
      getNativeDataType in class loci.formats.ReaderWrapper
    • updateMinMax

      protected void updateMinMax(int no, byte[] buf, int len) throws loci.formats.FormatException, IOException
      Updates min/max values based on the given byte array.
      Parameters:
      no - the plane index within the series.
      buf - a pre-allocated buffer.
      len - as buf may be larger than the actual pixel count having been written to it, the length (in bytes) of the those pixels.
      Throws:
      loci.formats.FormatException
      IOException
    • initMinMax

      protected void initMinMax() throws loci.formats.FormatException, IOException
      Ensures internal min/max variables are initialized properly.
      Throws:
      loci.formats.FormatException - Not actually thrown.
      IOException - Not actually thrown.