loci.formats
Class MinMaxCalculator

java.lang.Object
  extended by loci.formats.ReaderWrapper
      extended by loci.formats.MinMaxCalculator
All Implemented Interfaces:
IFormatHandler, IFormatReader, StatusReporter

public class MinMaxCalculator
extends ReaderWrapper

Logic to compute minimum and maximum values for each channel.

Source code:
Trac, SVN


Field Summary
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  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
MinMaxCalculator()
          Constructs a MinMaxCalculator around a new image reader.
MinMaxCalculator(IFormatReader r)
          Constructs a MinMaxCalculator with the given reader.
 
Method Summary
 void close()
          Closes currently open file(s) and frees allocated memory.
 Double getChannelGlobalMaximum(int theC)
          Retrieves a specified channel's global maximum.
 Double getChannelGlobalMinimum(int theC)
          Retrieves a specified channel's global minimum.
 Double getChannelKnownMaximum(int theC)
          Retrieves the specified channel's maximum based on the images that have been read.
 Double getChannelKnownMinimum(int theC)
          Retrieves the specified channel's minimum based on the images that have been read.
 Double[] getPlaneMaximum(int no)
          Retrieves the maximum pixel value for the specified plane.
 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.
 byte[] openBytes(int no)
          Obtains the specified image from the current file as a byte array.
 byte[] openBytes(int no, byte[] buf)
          Obtains the specified image from the current file into a pre-allocated byte array of (sizeX * sizeY * bytesPerPixel).
 byte[] openBytes(String id, int no)
          Deprecated. Replaced by openBytes(int)
 byte[] openBytes(String id, int no, byte[] buf)
          Deprecated. Replaced by openBytes(int, byte[])
 BufferedImage openImage(int no)
          Obtains the specified image from the current file.
 BufferedImage openImage(String id, int no)
          Deprecated. Replaced by openImage(int)
protected  void updateMinMax(BufferedImage b, int ndx)
          Updates min/max values based on the given BufferedImage.
protected  void updateMinMax(byte[] b, int ndx)
          Updates min/max values based on the given byte array.
 
Methods inherited from class loci.formats.ReaderWrapper
addStatusListener, close, fileGroupOption, get16BitLookupTable, get8BitLookupTable, getChannelDimLengths, getChannelDimLengths, getChannelDimTypes, getChannelDimTypes, getCoreMetadata, getCoreMetadata, getCurrentFile, getDimensionOrder, getDimensionOrder, getEffectiveSizeC, getEffectiveSizeC, getFormat, getImageCount, getImageCount, getIndex, getIndex, getMetadata, getMetadata, getMetadataStore, getMetadataStore, getMetadataStoreRoot, getMetadataStoreRoot, getMetadataValue, getMetadataValue, getPixelType, getPixelType, getReader, getRGBChannelCount, getRGBChannelCount, getSeries, getSeries, getSeriesCount, getSeriesCount, getSizeC, getSizeC, getSizeT, getSizeT, getSizeX, getSizeX, getSizeY, getSizeY, getSizeZ, getSizeZ, getStatusListeners, getSuffixes, getThumbSizeX, getThumbSizeX, getThumbSizeY, getThumbSizeY, getUsedFiles, getUsedFiles, getZCTCoords, getZCTCoords, isFalseColor, isGroupFiles, isIndexed, isInterleaved, isInterleaved, isInterleaved, isInterleaved, isLittleEndian, isLittleEndian, isMetadataCollected, isMetadataComplete, isMetadataFiltered, isNormalized, isOrderCertain, isOrderCertain, isOriginalMetadataPopulated, isRGB, isRGB, isThisType, isThisType, isThisType, openThumbBytes, openThumbBytes, openThumbImage, openThumbImage, removeStatusListener, setGroupFiles, setId, setId, setMetadataCollected, setMetadataFiltered, setMetadataStore, setNormalized, setOriginalMetadataPopulated, setSeries, setSeries
 
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.

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

getChannelGlobalMinimum

public Double getChannelGlobalMinimum(int theC)
                               throws FormatException,
                                      IOException
Retrieves a specified channel's global minimum. Returns null if some of the image planes have not been read.

Throws:
FormatException
IOException

getChannelGlobalMaximum

public Double getChannelGlobalMaximum(int theC)
                               throws FormatException,
                                      IOException
Retrieves a specified channel's global maximum. Returns null if some of the image planes have not been read.

Throws:
FormatException
IOException

getChannelKnownMinimum

public Double getChannelKnownMinimum(int theC)
                              throws 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:
FormatException
IOException

getChannelKnownMaximum

public Double getChannelKnownMaximum(int theC)
                              throws 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:
FormatException
IOException

getPlaneMinimum

public Double[] getPlaneMinimum(int no)
                         throws FormatException,
                                IOException
Retrieves the minimum pixel value for the specified plane. If each image plane contains more than one channel (i.e., ReaderWrapper.getRGBChannelCount(String)), returns the maximum value for each embedded channel. Returns null if the plane has not already been read.

Throws:
FormatException
IOException

getPlaneMaximum

public Double[] getPlaneMaximum(int no)
                         throws FormatException,
                                IOException
Retrieves the maximum pixel value for the specified plane. If each image plane contains more than one channel (i.e., ReaderWrapper.getRGBChannelCount(String)), returns the maximum value for each embedded channel. Returns null if the plane has not already been read.

Throws:
FormatException
IOException

isMinMaxPopulated

public boolean isMinMaxPopulated()
                          throws FormatException,
                                 IOException
Returns true if the values returned by getChannelGlobalMinimum/Maximum can be trusted.

Throws:
FormatException
IOException

openImage

public BufferedImage openImage(int no)
                        throws FormatException,
                               IOException
Description copied from interface: IFormatReader
Obtains the specified image from the current file.

Specified by:
openImage in interface IFormatReader
Overrides:
openImage in class ReaderWrapper
Throws:
FormatException
IOException

openBytes

public byte[] openBytes(int no)
                 throws FormatException,
                        IOException
Description copied from interface: IFormatReader
Obtains the specified image from the current file as a byte array.

Specified by:
openBytes in interface IFormatReader
Overrides:
openBytes in class ReaderWrapper
Throws:
FormatException
IOException

openBytes

public byte[] openBytes(int no,
                        byte[] buf)
                 throws FormatException,
                        IOException
Description copied from interface: IFormatReader
Obtains the specified image from the current file into a pre-allocated byte array of (sizeX * sizeY * bytesPerPixel).

Specified by:
openBytes in interface IFormatReader
Overrides:
openBytes in class ReaderWrapper
Parameters:
no - the image index within the file.
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.
IOException - if there was a problem reading the file.

close

public void close()
           throws IOException
Description copied from interface: IFormatHandler
Closes currently open file(s) and frees allocated memory.

Specified by:
close in interface IFormatHandler
Overrides:
close in class ReaderWrapper
Throws:
IOException

updateMinMax

protected void updateMinMax(BufferedImage b,
                            int ndx)
                     throws FormatException,
                            IOException
Updates min/max values based on the given BufferedImage.

Throws:
FormatException
IOException

updateMinMax

protected void updateMinMax(byte[] b,
                            int ndx)
                     throws FormatException,
                            IOException
Updates min/max values based on the given byte array.

Throws:
FormatException
IOException

initMinMax

protected void initMinMax()
                   throws FormatException,
                          IOException
Ensures internal min/max variables are initialized properly.

Throws:
FormatException
IOException

openImage

public BufferedImage openImage(String id,
                               int no)
                        throws FormatException,
                               IOException
Deprecated. Replaced by openImage(int)

Specified by:
openImage in interface IFormatReader
Overrides:
openImage in class ReaderWrapper
Throws:
FormatException
IOException

openBytes

public byte[] openBytes(String id,
                        int no)
                 throws FormatException,
                        IOException
Deprecated. Replaced by openBytes(int)

Specified by:
openBytes in interface IFormatReader
Overrides:
openBytes in class ReaderWrapper
Throws:
FormatException
IOException

openBytes

public byte[] openBytes(String id,
                        int no,
                        byte[] buf)
                 throws FormatException,
                        IOException
Deprecated. Replaced by openBytes(int, byte[])

Specified by:
openBytes in interface IFormatReader
Overrides:
openBytes in class ReaderWrapper
Throws:
FormatException
IOException