Package loci.formats
Class MinMaxCalculator
java.lang.Object
loci.formats.ReaderWrapper
loci.formats.MinMaxCalculator
- All Implemented Interfaces:
Closeable,AutoCloseable,ICompressedTileReader,IFormatHandler,IFormatReader,IMetadataConfigurable,IPyramidHandler
Logic to compute minimum and maximum values for each channel.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected 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 IMinMaxStoreConsumer of channel global minima and maximaprotected double[][]Max values for each plane.protected double[][]Min values for each plane.Fields inherited from class loci.formats.ReaderWrapper
readerFields inherited from interface loci.formats.IFormatReader
CAN_GROUP, CANNOT_GROUP, MUST_GROUP -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a MinMaxCalculator around a new image reader.Constructs a MinMaxCalculator with the given reader. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose(boolean fileOnly) Closes the currently open file.getChannelGlobalMaximum(int theC) Retrieves a specified channel's global maximum.getChannelGlobalMinimum(int theC) Retrieves a specified channel's global minimum.getChannelKnownMaximum(int theC) Retrieves the specified channel's maximum based on the images that have been read.getChannelKnownMinimum(int theC) Retrieves the specified channel's minimum based on the images that have been read.Retrieves the current active min-max store for the calculator.Class<?> Returns the native data type of image planes for this reader, as returned byIFormatReader.openPlane(int, int, int, int, int)orIFormatWriter.savePlane(int, java.lang.Object).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 voidEnsures internal min/max variables are initialized properly.booleanReturns true if the values returned by getChannelGlobalMinimum/Maximum can be trusted.static MinMaxCalculatorConverts 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).voidsetMinMaxStore(IMinMaxStore store) Sets the active min-max store for the calculator.protected voidupdateMinMax(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
-
Field Details
-
chanMin
protected double[][] chanMinMin values for each channel. -
chanMax
protected double[][] chanMaxMax values for each channel. -
planeMin
protected double[][] planeMinMin values for each plane. -
planeMax
protected double[][] planeMaxMax values for each plane. -
minMaxDone
protected int[] minMaxDoneNumber of planes for which min/max computations have been completed. -
minMaxStore
Consumer of channel global minima and maxima
-
-
Constructor Details
-
MinMaxCalculator
public MinMaxCalculator()Constructs a MinMaxCalculator around a new image reader. -
MinMaxCalculator
Constructs a MinMaxCalculator with the given reader.
-
-
Method Details
-
makeMinMaxCalculator
Converts the given reader into a MinMaxCalculator, wrapping if needed. -
setMinMaxStore
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
Retrieves the current active min-max store for the calculator.- Returns:
- See above.
-
getChannelGlobalMinimum
Retrieves a specified channel's global minimum. Returns null if some of the image planes have not been read.- Throws:
IOException- Not actually thrown.FormatException
-
getChannelGlobalMaximum
Retrieves a specified channel's global maximum. Returns null if some of the image planes have not been read.- Throws:
IOException- Not actually thrown.FormatException
-
getChannelKnownMinimum
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.IOException- Not actually thrown.
-
getChannelKnownMaximum
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.IOException- Not actually thrown.
-
getPlaneMinimum
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.IOException- Not actually thrown.
-
getPlaneMaximum
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.IOException- Not actually thrown.
-
isMinMaxPopulated
Returns true if the values returned by getChannelGlobalMinimum/Maximum can be trusted.- Throws:
FormatException- Not actually thrown.IOException- Not actually thrown.
-
openBytes
Description copied from interface:IFormatReaderObtains the specified image plane from the current file as a byte array.- Specified by:
openBytesin interfaceIFormatReader- Overrides:
openBytesin classReaderWrapper- Throws:
FormatExceptionIOException- See Also:
-
openBytes
Description copied from interface:IFormatReaderObtains the specified image plane from the current file into a pre-allocated byte array of (sizeX * sizeY * bytesPerPixel * RGB channel count).- Specified by:
openBytesin interfaceIFormatReader- Overrides:
openBytesin classReaderWrapper- Parameters:
no- the plane index within the current series.buf- a pre-allocated buffer.- Returns:
- the pre-allocated buffer
buffor convenience. - Throws:
FormatException- if there was a problem parsing the metadata of the file.IOException- if there was a problem reading the file.
-
openBytes
Description copied from interface:IFormatReaderObtains a sub-image of the specified image plane, whose upper-left corner is given by (x, y).- Specified by:
openBytesin interfaceIFormatReader- Overrides:
openBytesin classReaderWrapper- Throws:
FormatExceptionIOException
-
openBytes
public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException Description copied from interface:IFormatReaderObtains a sub-image of the specified image plane into a pre-allocated byte array.- Specified by:
openBytesin interfaceIFormatReader- Overrides:
openBytesin classReaderWrapper- 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-imagey- Y coordinate of the upper-left corner of the sub-imagew- width of the sub-imageh- height of the sub-image- Returns:
- the pre-allocated buffer
buffor convenience. - Throws:
FormatException- if there was a problem parsing the metadata of the file.IOException- if there was a problem reading the file.
-
close
Description copied from interface:IFormatReaderCloses the currently open file. If the flag is set, this is all that happens; if unset, it is equivalent to callingCloseable.close().- Specified by:
closein interfaceIFormatReader- Overrides:
closein classReaderWrapper- Throws:
IOException
-
getNativeDataType
Description copied from interface:IFormatHandlerReturns the native data type of image planes for this reader, as returned byIFormatReader.openPlane(int, int, int, int, int)orIFormatWriter.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 asBufferedImage.- Specified by:
getNativeDataTypein interfaceIFormatHandler- Overrides:
getNativeDataTypein classReaderWrapper
-
updateMinMax
Updates min/max values based on the given byte array.- Parameters:
no- the plane index within the series.buf- a pre-allocated buffer.len- asbufmay be larger than the actual pixel count having been written to it, the length (in bytes) of the those pixels.- Throws:
FormatExceptionIOException
-
initMinMax
Ensures internal min/max variables are initialized properly.- Throws:
FormatException- Not actually thrown.IOException- Not actually thrown.
-