loci.formats

## Class MinMaxCalculator

- java.lang.Object
- - loci.formats.ReaderWrapper
  - - loci.formats.MinMaxCalculator

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, ICompressedTileReader, IFormatHandler, IFormatReader, IMetadataConfigurable, IPyramidHandler

      public class MinMaxCalculator
      extends ReaderWrapper

  Logic to compute minimum and maximum values for each channel.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected double[][]` | `chanMax` Max values for each channel.
    `protected double[][]` | `chanMin` Min values for each channel.
    `protected int[]` | `minMaxDone` Number of planes for which min/max computations have been completed.
    `protected IMinMaxStore` | `minMaxStore` Consumer of channel global minima and maxima
    `protected double[][]` | `planeMax` Max values for each plane.
    `protected double[][]` | `planeMin` 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 and Description
    `MinMaxCalculator()` Constructs a MinMaxCalculator around a new image reader.
    `MinMaxCalculator(IFormatReader r)` Constructs a MinMaxCalculator with the given reader.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close(boolean fileOnly)` Closes the currently open file.
    `java.lang.Double` | `getChannelGlobalMaximum(int theC)` Retrieves a specified channel's global maximum.
    `java.lang.Double` | `getChannelGlobalMinimum(int theC)` Retrieves a specified channel's global minimum.
    `java.lang.Double` | `getChannelKnownMaximum(int theC)` Retrieves the specified channel's maximum based on the images that have been read.
    `java.lang.Double` | `getChannelKnownMinimum(int theC)` Retrieves the specified channel's minimum based on the images that have been read.
    `IMinMaxStore` | `getMinMaxStore()` Retrieves the current active min-max store for the calculator.
    `java.lang.Class<?>` | `getNativeDataType()` Returns the native data type of image planes for this reader, as returned by `IFormatReader.openPlane(int, int, int, int, int)` or `IFormatWriter.savePlane(int, java.lang.Object)`.
    `java.lang.Double[]` | `getPlaneMaximum(int no)` Retrieves the maximum pixel value for the specified plane.
    `java.lang.Double[]` | `getPlaneMinimum(int no)` Retrieves the minimum pixel value for the specified plane.
    `protected void` | `initMinMax()` Ensures internal min/max variables are initialized properly.
    `boolean` | `isMinMaxPopulated()` Returns true if the values returned by getChannelGlobalMinimum/Maximum can be trusted.
    `static MinMaxCalculator` | `makeMinMaxCalculator(IFormatReader r)` Converts the given reader into a MinMaxCalculator, wrapping if needed.
    `byte[]` | `openBytes(int no)` Obtains the specified image plane from the current file as a byte array.
    `byte[]` | `openBytes(int no, byte[] buf)` Obtains the specified image plane from the current file into a pre-allocated byte array of (sizeX * sizeY * bytesPerPixel * RGB channel count).
    `byte[]` | `openBytes(int no, byte[] buf, int x, int y, int w, int h)` Obtains a sub-image of the specified image plane into a pre-allocated byte array.
    `byte[]` | `openBytes(int no, int x, int y, int w, int h)` Obtains a sub-image of the specified image plane, whose upper-left corner is given by (x, y).
    `void` | `setMinMaxStore(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, 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 Detail

    - #### 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 IMinMaxStore minMaxStore

      Consumer of channel global minima and maxima

  - ### Constructor Detail

    - #### MinMaxCalculator

          public MinMaxCalculator()

      Constructs a MinMaxCalculator around a new image reader.

    - #### MinMaxCalculator

          public MinMaxCalculator(IFormatReader r)

      Constructs a MinMaxCalculator with the given reader.

  - ### Method Detail

    - #### makeMinMaxCalculator

          public static MinMaxCalculator makeMinMaxCalculator(IFormatReader r)

      Converts the given reader into a MinMaxCalculator, wrapping if needed.

    - #### setMinMaxStore

          public void setMinMaxStore(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 IMinMaxStore getMinMaxStore()

      Retrieves the current active min-max store for the calculator.
      Returns:
        See above.

    - #### getChannelGlobalMinimum

          public java.lang.Double getChannelGlobalMinimum(int theC)
                                                   throws FormatException,
                                                          java.io.IOException

      Retrieves a specified channel's global minimum. Returns null if some of the image planes have not been read.
      Throws:
        `java.io.IOException` - Not actually thrown.
        `FormatException`

    - #### getChannelGlobalMaximum

          public java.lang.Double getChannelGlobalMaximum(int theC)
                                                   throws FormatException,
                                                          java.io.IOException

      Retrieves a specified channel's global maximum. Returns null if some of the image planes have not been read.
      Throws:
        `java.io.IOException` - Not actually thrown.
        `FormatException`

    - #### getChannelKnownMinimum

          public java.lang.Double getChannelKnownMinimum(int theC)
                                                  throws FormatException,
                                                         java.io.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:
        `FormatException` - Not actually thrown.
        `java.io.IOException` - Not actually thrown.

    - #### getChannelKnownMaximum

          public java.lang.Double getChannelKnownMaximum(int theC)
                                                  throws FormatException,
                                                         java.io.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:
        `FormatException` - Not actually thrown.
        `java.io.IOException` - Not actually thrown.

    - #### getPlaneMinimum

          public java.lang.Double[] getPlaneMinimum(int no)
                                             throws FormatException,
                                                    java.io.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:
        `FormatException` - Not actually thrown.
        `java.io.IOException` - Not actually thrown.

    - #### getPlaneMaximum

          public java.lang.Double[] getPlaneMaximum(int no)
                                             throws FormatException,
                                                    java.io.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:
        `FormatException` - Not actually thrown.
        `java.io.IOException` - Not actually thrown.

    - #### isMinMaxPopulated

          public boolean isMinMaxPopulated()
                                    throws FormatException,
                                           java.io.IOException

      Returns true if the values returned by getChannelGlobalMinimum/Maximum can be trusted.
      Throws:
        `FormatException` - Not actually thrown.
        `java.io.IOException` - Not actually thrown.

    - #### openBytes

          public byte[] openBytes(int no)
                           throws FormatException,
                                  java.io.IOException

      Description copied from interface: `IFormatReader`
      Obtains the specified image plane from the current file as a byte array.
      Specified by:
        `openBytes` in interface `IFormatReader`
      Overrides:
        `openBytes` in class `ReaderWrapper`
      Throws:
        `FormatException`
        `java.io.IOException`
      See Also:
        `IFormatReader.openBytes(int, byte[])`

    - #### openBytes

          public byte[] openBytes(int no,
                                  byte[] buf)
                           throws FormatException,
                                  java.io.IOException

      Description copied from interface: `IFormatReader`
      Obtains the specified image plane from the current file into a pre-allocated byte array of (sizeX * sizeY * bytesPerPixel * RGB channel count).
      Specified by:
        `openBytes` in interface `IFormatReader`
      Overrides:
        `openBytes` in class `ReaderWrapper`
      Parameters:
        `no` - the plane index within the current series.
        `buf` - a pre-allocated buffer.
      Returns:
        the pre-allocated buffer `buf` for convenience.
      Throws:
        `FormatException` - if there was a problem parsing the metadata of the file.
        `java.io.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,
                                  java.io.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 `ReaderWrapper`
      Throws:
        `FormatException`
        `java.io.IOException`

    - #### openBytes

          public byte[] openBytes(int no,
                                  byte[] buf,
                                  int x,
                                  int y,
                                  int w,
                                  int h)
                           throws FormatException,
                                  java.io.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`
      Overrides:
        `openBytes` in class `ReaderWrapper`
      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.
        `java.io.IOException` - if there was a problem reading the file.

    - #### close

          public void close(boolean fileOnly)
                     throws java.io.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 `ReaderWrapper`
      Throws:
        `java.io.IOException`

    - #### getNativeDataType

          public java.lang.Class<?> getNativeDataType()

      Description copied from interface: `IFormatHandler`
      Returns the native data type of image planes for this reader, as returned by `IFormatReader.openPlane(int, int, int, int, int)` or `IFormatWriter.savePlane(int, java.lang.Object)`. For most readers this type will be a byte array; however, some readers call external APIs that work with other types such as `BufferedImage`.
      Specified by:
        `getNativeDataType` in interface `IFormatHandler`
      Overrides:
        `getNativeDataType` in class `ReaderWrapper`

    - #### updateMinMax

          protected void updateMinMax(int no,
                                      byte[] buf,
                                      int len)
                               throws FormatException,
                                      java.io.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:
        `FormatException`
        `java.io.IOException`

    - #### initMinMax

          protected void initMinMax()
                             throws FormatException,
                                    java.io.IOException

      Ensures internal min/max variables are initialized properly.
      Throws:
        `FormatException` - Not actually thrown.
        `java.io.IOException` - Not actually thrown.

Copyright © 2026 Open Microscopy Environment