public final class FormatTools
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
ALL_DOMAINS
List of all supported domains.
|
static java.lang.String |
ASTRONOMY_DOMAIN
Identifies the astronomy domain.
|
static int |
CAN_GROUP |
static int |
CANNOT_GROUP |
static java.lang.String |
CHANNEL
Identifies the Channel dimensional type,
representing a generic channel dimension.
|
static java.lang.String |
CHANNEL_NAME |
static java.lang.String |
CHANNEL_NUM |
static java.lang.String |
DATE
Date on which this release was built.
|
static int |
DOUBLE
Identifies the DOUBLE data type used to store pixel values.
|
static java.lang.String |
EM_DOMAIN
Identifies the electron microscopy domain.
|
static java.lang.String |
FLIM_DOMAIN
Identifies the fluorescence-lifetime domain.
|
static int |
FLOAT
Identifies the FLOAT data type used to store pixel values.
|
static java.lang.String |
FREQUENCY
Identifies the Frequency dimensional type,
representing a dimension consisting of frequencies.
|
static java.lang.String |
GEL_DOMAIN
Identifies the gel and blot imaging domain.
|
static java.lang.String |
GRAPHICS_DOMAIN
Identifies the graphics domain.
|
static java.lang.String |
HCS_DOMAIN
Identifies the high content screening domain.
|
static java.lang.String |
HISTOLOGY_DOMAIN
Identifies the histology domain.
|
static java.lang.String |
ILLUMINATION
Identifies the Illumination dimensional type,
representing a dimension consisting of illuminations.
|
static int |
INT16
Identifies the INT16 data type used to store pixel values.
|
static int |
INT32
Identifies the INT32 data type used to store pixel values.
|
static int |
INT8
Identifies the INT8 data type used to store pixel values.
|
static java.lang.String |
LIFETIME
Identifies the Lifetime dimensional type,
representing a dimension consisting of a lifetime histogram.
|
static java.lang.String |
LM_DOMAIN
Identifies the light microscopy domain.
|
protected static org.slf4j.Logger |
LOGGER |
static java.lang.String |
MEDICAL_DOMAIN
Identifies the medical imaging domain.
|
static int |
MUST_GROUP
File grouping options.
|
static java.lang.String[] |
NON_GRAPHICS_DOMAINS
List of non-graphics domains.
|
static java.lang.String[] |
NON_HCS_DOMAINS
List of non-HCS domains.
|
static java.lang.String[] |
NON_SPECIAL_DOMAINS
List of domains that do not require special handling.
|
static java.lang.String |
PHASE
Identifies the Phase dimensional type,
representing a dimension consisting of phases.
|
static java.lang.String |
POLARIZATION
Identifies the Polarization dimensional type,
representing a dimension consisting of polarization states.
|
static java.lang.String |
PROPERTY_FILE |
static java.lang.String |
ROTATION
Identifies the Rotation dimensional type,
representing a dimension consisting of rotations.
|
static java.lang.String |
SEM_DOMAIN
Identifies the scanning electron microscopy domain.
|
static java.lang.String |
SERIES_NAME |
static java.lang.String |
SERIES_NUM
Patterns to be used when constructing a pattern for output filenames.
|
static java.lang.String |
SPECTRA
Identifies the Spectra dimensional type,
representing a dimension consisting of spectral channels.
|
static java.lang.String |
SPM_DOMAIN
Identifies the scanning probe microscopy domain.
|
static java.lang.String |
T_NUM |
static java.lang.String |
TIMESTAMP |
static int |
UINT16
Identifies the UINT16 data type used to store pixel values.
|
static int |
UINT32
Identifies the UINT32 data type used to store pixel values.
|
static int |
UINT8
Identifies the UINT8 data type used to store pixel values.
|
static java.lang.String |
UNKNOWN_DOMAIN
Identifies an unknown domain.
|
static java.lang.String |
URL_BIO_FORMATS
URL of Bio-Formats web page.
|
static java.lang.String |
URL_BIO_FORMATS_LIBRARIES
URL of 'Bio-Formats as a Java Library' web page.
|
static java.lang.String |
URL_OME_TIFF
URL of OME-TIFF web page.
|
static java.lang.String |
VCS_REVISION
Current VCS revision.
|
static java.lang.String |
VERSION
Version number of this release.
|
static java.util.Properties |
VERSION_PROPERTIES |
static java.lang.String |
YEAR
Year in which this release was built.
|
static java.lang.String |
Z_NUM |
Modifier and Type | Method and Description |
---|---|
static void |
assertId(java.lang.String currentId,
boolean notNull,
int depth)
Asserts that the current file is either null, or not, according to the
given flag.
|
static void |
checkBufferSize(IFormatReader r,
int len) |
static void |
checkBufferSize(IFormatReader r,
int len,
int w,
int h)
Checks that the given buffer size is large enough to hold a w * h
image as returned by the given reader.
|
static void |
checkPlaneNumber(IFormatReader r,
int no)
Checks that the given plane number is valid for the given reader.
|
static void |
checkPlaneParameters(IFormatReader r,
int no,
int bufLength,
int x,
int y,
int w,
int h)
Convenience method for checking that the plane number, tile size and
buffer sizes are all valid for the given reader.
|
static void |
checkTileSize(IFormatReader r,
int x,
int y,
int w,
int h)
Checks that the given tile size is valid for the given reader.
|
static void |
convert(IFormatReader input,
IFormatWriter output,
java.lang.String outputFile)
Convenience method for writing all of the images and metadata obtained
from the specified IFormatReader into the specified IFormatWriter.
|
static void |
convert(java.lang.String input,
java.lang.String output)
Convenience method for converting the specified input file to the
specified output file.
|
static long[] |
defaultMinMax(int pixelType)
Get the default range for the specified pixel type.
|
static boolean |
equalReaders(IFormatReader a,
IFormatReader b)
Check if the two given readers are equal.
|
static int |
getBytesPerPixel(int pixelType)
Retrieves how many bytes per pixel the current plane or section has.
|
static int |
getBytesPerPixel(java.lang.String pixelType)
Retrieves the number of bytes per pixel in the current plane.
|
static PositiveInteger |
getCutIn(java.lang.Integer value) |
static PositiveInteger |
getCutOut(java.lang.Integer value) |
static PositiveInteger |
getEmissionWavelength(java.lang.Integer value) |
static PositiveInteger |
getExcitationWavelength(java.lang.Integer value) |
static java.lang.String |
getFilename(int series,
int image,
IFormatReader r,
java.lang.String pattern) |
static java.lang.String[] |
getFilenames(java.lang.String pattern,
IFormatReader r) |
static NonNegativeInteger |
getFontSize(java.lang.Integer value) |
static int |
getImagesPerFile(java.lang.String pattern,
IFormatReader r) |
static int |
getIndex(IFormatReader reader,
int z,
int c,
int t)
Gets the rasterized index corresponding
to the given Z, C and T coordinates.
|
static int |
getIndex(java.lang.String order,
int zSize,
int cSize,
int tSize,
int num,
int z,
int c,
int t)
Gets the rasterized index corresponding
to the given Z, C and T coordinates.
|
static PositiveInteger |
getMaxFieldCount(java.lang.Integer value) |
static PositiveFloat |
getPhysicalSizeX(java.lang.Double value) |
static PositiveFloat |
getPhysicalSizeY(java.lang.Double value) |
static PositiveFloat |
getPhysicalSizeZ(java.lang.Double value) |
static java.lang.String |
getPixelTypeString(int pixelType)
Takes a pixel type value and gets a corresponding string representation.
|
static int |
getPlaneSize(IFormatReader r)
Returns the size in bytes of a single plane.
|
static int |
getPlaneSize(IFormatReader r,
int w,
int h)
Returns the size in bytes of a w * h tile.
|
static int |
getRasterLength(int[] lengths)
Computes the number of raster values for a positional array
with the given lengths.
|
static IFormatReader |
getReader(IFormatReader r,
java.lang.Class<? extends IFormatReader> c)
Recursively look for the first underlying reader that is an
instance of the given class.
|
static int |
getReorderedIndex(IFormatReader reader,
java.lang.String newOrder,
int newIndex)
Converts index from the given dimension order to the reader's native one.
|
static int |
getReorderedIndex(java.lang.String origOrder,
java.lang.String newOrder,
int zSize,
int cSize,
int tSize,
int num,
int newIndex)
Converts index from one dimension order to another.
|
static PositiveInteger |
getWavelength(java.lang.Integer value) |
static int[] |
getZCTCoords(IFormatReader reader,
int index)
Gets the Z, C and T coordinates corresponding
to the given rasterized index value.
|
static int[] |
getZCTCoords(java.lang.String order,
int zSize,
int cSize,
int tSize,
int num,
int index)
Gets the Z, C and T coordinates corresponding to the given rasterized
index value.
|
static boolean |
isFloatingPoint(int pixelType)
Determines whether the given pixel type is floating point or integer.
|
static boolean |
isSigned(int pixelType)
Determines whether the given pixel type is signed or unsigned.
|
static byte[] |
openThumbBytes(IFormatReader reader,
int no)
Default implementation for
IFormatReader.openThumbBytes(int) . |
static int |
pixelTypeFromBytes(int bytes,
boolean signed,
boolean fp)
Returns an appropriate pixel type given the number of bytes per pixel.
|
static int |
pixelTypeFromString(java.lang.String pixelTypeAsString)
Takes a string value and maps it to one of the pixel type enumerations.
|
static int |
positionToRaster(int[] lengths,
int[] pos)
Computes a unique 1-D index corresponding
to the given multidimensional position.
|
static int[] |
rasterToPosition(int[] lengths,
int raster)
Computes a unique N-D position corresponding
to the given rasterized index value.
|
static int[] |
rasterToPosition(int[] lengths,
int raster,
int[] pos)
Computes a unique N-D position corresponding
to the given rasterized index value.
|
static boolean |
validStream(RandomAccessInputStream stream,
int len,
boolean littleEndian)
Returns true if the given RandomAccessInputStream conatins at least
'len' bytes.
|
protected static final org.slf4j.Logger LOGGER
public static final int INT8
public static final int UINT8
public static final int INT16
public static final int UINT16
public static final int INT32
public static final int UINT32
public static final int FLOAT
public static final int DOUBLE
public static final java.lang.String CHANNEL
public static final java.lang.String SPECTRA
public static final java.lang.String LIFETIME
public static final java.lang.String POLARIZATION
public static final java.lang.String PHASE
public static final java.lang.String FREQUENCY
public static final java.lang.String ROTATION
public static final java.lang.String ILLUMINATION
public static final int MUST_GROUP
public static final int CAN_GROUP
public static final int CANNOT_GROUP
public static final java.lang.String SERIES_NUM
public static final java.lang.String SERIES_NAME
public static final java.lang.String CHANNEL_NUM
public static final java.lang.String CHANNEL_NAME
public static final java.lang.String Z_NUM
public static final java.lang.String T_NUM
public static final java.lang.String TIMESTAMP
public static final java.util.Properties VERSION_PROPERTIES
public static final java.lang.String VCS_REVISION
public static final java.lang.String DATE
public static final java.lang.String YEAR
public static final java.lang.String VERSION
public static final java.lang.String PROPERTY_FILE
public static final java.lang.String HCS_DOMAIN
public static final java.lang.String LM_DOMAIN
public static final java.lang.String EM_DOMAIN
public static final java.lang.String SPM_DOMAIN
public static final java.lang.String SEM_DOMAIN
public static final java.lang.String FLIM_DOMAIN
public static final java.lang.String MEDICAL_DOMAIN
public static final java.lang.String HISTOLOGY_DOMAIN
public static final java.lang.String GEL_DOMAIN
public static final java.lang.String ASTRONOMY_DOMAIN
public static final java.lang.String GRAPHICS_DOMAIN
public static final java.lang.String UNKNOWN_DOMAIN
public static final java.lang.String[] NON_GRAPHICS_DOMAINS
public static final java.lang.String[] NON_HCS_DOMAINS
public static final java.lang.String[] NON_SPECIAL_DOMAINS
GRAPHICS_DOMAIN
and
HCS_DOMAIN
.public static final java.lang.String[] ALL_DOMAINS
public static final java.lang.String URL_BIO_FORMATS
public static final java.lang.String URL_BIO_FORMATS_LIBRARIES
public static final java.lang.String URL_OME_TIFF
public static int getIndex(IFormatReader reader, int z, int c, int t)
public static int getIndex(java.lang.String order, int zSize, int cSize, int tSize, int num, int z, int c, int t)
order
- Dimension order.zSize
- Total number of focal planes.cSize
- Total number of channels.tSize
- Total number of time points.num
- Total number of image planes (zSize * cSize * tSize),
specified as a consistency check.z
- Z coordinate of ZCT coordinate triple to convert to 1D index.c
- C coordinate of ZCT coordinate triple to convert to 1D index.t
- T coordinate of ZCT coordinate triple to convert to 1D index.public static int[] getZCTCoords(IFormatReader reader, int index)
public static int[] getZCTCoords(java.lang.String order, int zSize, int cSize, int tSize, int num, int index)
order
- Dimension order.zSize
- Total number of focal planes.cSize
- Total number of channels.tSize
- Total number of time points.num
- Total number of image planes (zSize * cSize * tSize),
specified as a consistency check.index
- 1D (rasterized) index to convert to ZCT coordinate triple.public static int getReorderedIndex(IFormatReader reader, java.lang.String newOrder, int newIndex) throws FormatException
DimensionSwapper
does).FormatException
- Never actually thrown.public static int getReorderedIndex(java.lang.String origOrder, java.lang.String newOrder, int zSize, int cSize, int tSize, int num, int newIndex)
DimensionSwapper
does).origOrder
- Original dimension order.newOrder
- New dimension order.zSize
- Total number of focal planes.cSize
- Total number of channels.tSize
- Total number of time points.num
- Total number of image planes (zSize * cSize * tSize),
specified as a consistency check.newIndex
- 1D (rasterized) index according to new dimension order.public static int positionToRaster(int[] lengths, int[] pos)
lengths
- the maximum value for each positional dimensionpos
- position along each dimensional axispublic static int[] rasterToPosition(int[] lengths, int raster)
lengths
- the maximum value at each positional dimensionraster
- rasterized index valuepublic static int[] rasterToPosition(int[] lengths, int raster, int[] pos)
lengths
- the maximum value at each positional dimensionraster
- rasterized index valuepos
- preallocated position array to populate with the resultpublic static int getRasterLength(int[] lengths)
public static int pixelTypeFromString(java.lang.String pixelTypeAsString)
pixelTypeAsString
- the pixel type as a string.public static java.lang.String getPixelTypeString(int pixelType)
pixelType
- the pixel type.public static int getBytesPerPixel(int pixelType)
pixelType
- the pixel type as retrieved from
IFormatReader.getPixelType()
.IFormatReader.getPixelType()
public static int getBytesPerPixel(java.lang.String pixelType)
pixelType
- the pixel type, as a String.pixelTypeFromString(String)
,
getBytesPerPixel(int)
public static boolean isFloatingPoint(int pixelType)
pixelType
- the pixel type as retrieved from
IFormatReader.getPixelType()
.IFormatReader.getPixelType()
public static boolean isSigned(int pixelType)
pixelType
- the pixel type as retrieved from
IFormatReader.getPixelType()
.IFormatReader.getPixelType()
public static int pixelTypeFromBytes(int bytes, boolean signed, boolean fp) throws FormatException
bytes
- number of bytes per pixel.signed
- whether or not the pixel type should be signed.fp
- whether or not these are floating point pixels.FormatException
public static void assertId(java.lang.String currentId, boolean notNull, int depth)
currentId
- File name to test.notNull
- True iff id should be non-null.depth
- How far back in the stack the calling method is; this name
is reported as part of the exception message, if available. Use zero
to suppress output of the calling method name.public static void checkPlaneParameters(IFormatReader r, int no, int bufLength, int x, int y, int w, int h) throws FormatException
FormatException
public static void checkPlaneNumber(IFormatReader r, int no) throws FormatException
FormatException
public static void checkTileSize(IFormatReader r, int x, int y, int w, int h) throws FormatException
FormatException
public static void checkBufferSize(IFormatReader r, int len) throws FormatException
FormatException
public static void checkBufferSize(IFormatReader r, int len, int w, int h) throws FormatException
FormatException
- if the buffer is too smallpublic static boolean validStream(RandomAccessInputStream stream, int len, boolean littleEndian) throws java.io.IOException
java.io.IOException
public static int getPlaneSize(IFormatReader r)
public static int getPlaneSize(IFormatReader r, int w, int h)
public static java.lang.String getFilename(int series, int image, IFormatReader r, java.lang.String pattern) throws FormatException, java.io.IOException
FormatException
- Never actually thrown.java.io.IOException
- Never actually thrown.public static java.lang.String[] getFilenames(java.lang.String pattern, IFormatReader r) throws FormatException, java.io.IOException
FormatException
java.io.IOException
public static int getImagesPerFile(java.lang.String pattern, IFormatReader r) throws FormatException, java.io.IOException
FormatException
java.io.IOException
public static IFormatReader getReader(IFormatReader r, java.lang.Class<? extends IFormatReader> c)
public static boolean equalReaders(IFormatReader a, IFormatReader b)
public static byte[] openThumbBytes(IFormatReader reader, int no) throws FormatException, java.io.IOException
IFormatReader.openThumbBytes(int)
.
At the moment, it uses BufferedImage
objects
to resize thumbnails, so it is not safe for use in headless contexts.
In the future, we may reimplement the image scaling logic purely with
byte arrays, but handling every case would be substantial effort, so
doing so is currently a low priority item.FormatException
java.io.IOException
public static void convert(java.lang.String input, java.lang.String output) throws FormatException, java.io.IOException
input
- the full path name of the existing input fileoutput
- the full path name of the output file to be createdFormatException
- if there is a general problem reading from or
writing to one of the files.java.io.IOException
- if there is an I/O-related error.convert(IFormatReader, IFormatWriter, String).
public static void convert(IFormatReader input, IFormatWriter output, java.lang.String outputFile) throws FormatException, java.io.IOException
input
- the pre-initialized IFormatReader used for reading data.output
- the uninitialized IFormatWriter used for writing data.outputFile
- the full path name of the output file to be created.FormatException
- if there is a general problem reading from or
writing to one of the files.java.io.IOException
- if there is an I/O-related error.public static long[] defaultMinMax(int pixelType)
pixelType
- the pixel type.java.io.IOException
- if the pixel type is floating point or invalid.public static PositiveFloat getPhysicalSizeX(java.lang.Double value)
public static PositiveFloat getPhysicalSizeY(java.lang.Double value)
public static PositiveFloat getPhysicalSizeZ(java.lang.Double value)
public static PositiveInteger getEmissionWavelength(java.lang.Integer value)
public static PositiveInteger getExcitationWavelength(java.lang.Integer value)
public static PositiveInteger getWavelength(java.lang.Integer value)
public static PositiveInteger getMaxFieldCount(java.lang.Integer value)
public static PositiveInteger getCutIn(java.lang.Integer value)
public static PositiveInteger getCutOut(java.lang.Integer value)
public static NonNegativeInteger getFontSize(java.lang.Integer value)
Copyright © 2014 Open Microscopy Environment