Trees | Indices | Help |
|
---|
|
Read and write image data from and to TIFF files.
Image and meta-data can be read from TIFF, BigTIFF, OME-TIFF, STK, LSM, NIH, ImageJ, MicroManager, FluoView, SEQ and GEL files. Only a subset of the TIFF specification is supported, mainly uncompressed and losslessly compressed 2**(0 to 6) bit integer, 16, 32 and 64-bit float, grayscale and RGB(A) images, which are commonly used in bio-scientific imaging. Specifically, reading JPEG/CCITT compressed image data or EXIF/IPTC/GPS/XMP meta-data is not implemented. Only primary info records are read for STK, FluoView, MicroManager, and NIH image formats.
TIFF, the Tagged Image File Format, is under the control of Adobe Systems. BigTIFF allows for files greater than 4 GB. STK, LSM, FluoView, SEQ, GEL, and OME-TIFF, are custom extensions defined by MetaMorph, Carl Zeiss MicroImaging, Olympus, Media Cybernetics, Molecular Dynamics, and the Open Microscopy Environment consortium respectively.
For command line usage run python tifffile.py --help
The API is not stable yet and might change between revisions.
Tested on little-endian platforms only.
Other Python packages and modules for reading bio-scientific TIFF files: * Imread * PyLibTiff * SimpleITK * PyLSM * PyMca.TiffIO.py * BioImageXD.Readers * Cellcognition.io * CellProfiler.bioformats
>>> data = numpy.random.rand(301, 219) >>> imsave('temp.tif', data) >>> image = imread('temp.tif') >>> assert numpy.all(image == data)
>>> tif = TiffFile('test.tif') >>> images = tif.asarray() >>> image0 = tif[0].asarray() >>> for page in tif: ... for tag in page.tags.values(): ... t = tag.name, tag.value ... image = page.asarray() ... if page.is_rgb: pass ... if page.is_palette: ... t = page.color_map ... if page.is_stk: ... t = page.mm_uic_tags.number_planes ... if page.is_lsm: ... t = page.cz_lsm_info >>> tif.close()
Author: Christoph Gohlke
Organization: Laboratory for Fluorescence Dynamics, University of California, Irvine
Version: 2013.11.03
|
|||
lazyattr Lazy object attribute whose value is computed on first access. |
|||
TiffFile Read image and meta-data from TIFF, STK, LSM, and FluoView files. |
|||
TiffPage A TIFF image file directory (IFD). |
|||
TiffTag A TIFF tag structure. |
|||
TiffSequence Sequence of image files. |
|||
Record Dictionary with attribute access. |
|||
TiffTags Dictionary of TiffTags with attribute access. |
|||
TIFF_SUBFILE_TYPES | |||
TIFFfile Read image and meta-data from TIFF, STK, LSM, and FluoView files. |
|||
unicode str(object='') -> string |
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
__version__ =
|
|||
TIFF_PHOTOMETRICS =
|
|||
TIFF_COMPESSIONS =
|
|||
TIFF_DECOMPESSORS =
|
|||
TIFF_DATA_TYPES =
|
|||
TIFF_SAMPLE_FORMATS =
|
|||
TIFF_SAMPLE_DTYPES =
|
|||
TIFF_ORIENTATIONS =
|
|||
AXES_LABELS =
|
|||
NIH_IMAGE_HEADER =
|
|||
MM_TAG_IDS =
|
|||
MM_DIMENSION =
|
|||
MM_HEADER =
|
|||
CZ_LSM_INFO =
|
|||
CZ_LSM_INFO_READERS =
|
|||
CZ_SCAN_TYPES =
|
|||
CZ_DIMENSIONS =
|
|||
CZ_DATA_TYPES =
|
|||
CZ_LSM_SCAN_INFO_ARRAYS =
|
|||
CZ_LSM_SCAN_INFO_STRUCTS =
|
|||
CZ_LSM_SCAN_INFO_ATTRIBUTES =
|
|||
TIFF_TAGS =
|
|||
CUSTOM_TAGS =
|
|||
PRINT_LINE_LEN = 79
|
|||
basestring = str, bytes
|
|||
__package__ =
|
|||
__warningregistry__ =
|
|
Write image data to TIFF file. Image data are written in one stripe per plane. Dimensions larger than 2 or 3 (depending on photometric mode and planar configuration) are flattened and saved as separate pages. The 'sample_format' and 'bits_per_sample' TIFF tags are derived from the data type. Parameters ---------- filename : str Name of file to write. data : array_like Input image. The last dimensions are assumed to be image height, width, and samples. photometric : {'minisblack', 'miniswhite', 'rgb'} The color space of the image data. By default this setting is inferred from the data shape. planarconfig : {'contig', 'planar'} Specifies if samples are stored contiguous or in separate planes. By default this setting is inferred from the data shape. 'contig': last dimension contains samples. 'planar': third last dimension contains samples. resolution : (float, float) or ((int, int), (int, int)) X and Y resolution in dots per inch as float or rational numbers. description : str The subject of the image. Saved with the first page only. software : str Name of the software used to create the image. Saved with the first page only. byteorder : {'<', '>'} The endianness of the data in the file. By default this is the system's native byte order. bigtiff : bool If True, the BigTIFF format is used. By default the standard TIFF format is used for data less than 2000 MB. compress : int Values from 0 to 9 controlling the level of zlib compression. If 0, data are written uncompressed (default). extratags: sequence of tuples Additional tags as [(code, dtype, count, value, writeonce)]. code : int The TIFF tag Id. dtype : str Data type of items in `value` in Python struct format. One of B, s, H, I, 2I, b, h, i, f, d, Q, or q. count : int Number of data values. Not used for string values. value : sequence `Count` values compatible with `dtype`. writeonce : bool If True, the tag is written to the first page only. Examples -------- >>> data = numpy.ones((2, 5, 3, 301, 219), 'float32') * 0.5 >>> imsave('temp.tif', data, compress=6) >>> data = numpy.ones((5, 301, 219, 3), 'uint8') + 127 >>> value = u'{"shape": %s}' % str(list(data.shape)) >>> imsave('temp.tif', data, extratags=[(270, 's', 0, value, True)]) |
Return image data from TIFF file(s) as numpy array. The first image series is returned if no arguments are provided. Parameters
Examples>>> im = imread('test.tif', 0) >>> im.shape (256, 256, 4) >>> ims = imread(['test.tif', 'test.tif']) >>> ims.shape (2, 256, 256, 4) |
Read MicroManager non-TIFF settings from open file and return as dict. The settings can be used to read image data without parsing the TIFF file. Raise ValueError if file does not contain valid MicroManager metadata. |
Decompress PackBits encoded byte string. PackBits is a simple byte-oriented run-length compression scheme.
|
Decompress LZW (Lempel-Ziv-Welch) encoded TIFF strip (byte string). The strip must begin with a CLEAR code and end with an EOI code. This is an implementation of the LZW decoding algorithm described in (1). It is not compatible with old style LZW compressed files like quad-lzw.tif.
|
Decompress byte string to array of integers of any bit size <= 32. Parameters
|
Return array from byte string containing packed samples. Use to unpack RGB565 or RGB555 to RGB888 format. Parameters
Returns
Examples>>> data = struct.pack('BBBB', 0x21, 0x08, 0xff, 0xff) >>> print(unpackrgb(data, '<B', (5, 6, 5), False)) [ 1 1 1 31 63 31] >>> print(unpackrgb(data, '<B', (5, 6, 5))) [ 8 4 8 255 255 255] >>> print(unpackrgb(data, '<B', (5, 5, 5))) [ 16 8 8 255 255 255] |
Return reoriented view of image array. Parameters
|
Return array from data in binary file. Work around numpy issue #2230, "numpy.fromfile does not accept StringIO object" https://github.com/numpy/numpy/issues/2230. |
Plot n-dimensional images using matplotlib.pyplot. Return figure, subplot and plot axis. Requires pyplot already imported from matplotlib import pyplot. Parameters
|
|
TIFF_PHOTOMETRICS
|
TIFF_COMPESSIONS
|
TIFF_DECOMPESSORS
|
TIFF_DATA_TYPES
|
TIFF_SAMPLE_FORMATS
|
TIFF_SAMPLE_DTYPES
|
TIFF_ORIENTATIONS
|
AXES_LABELS
|
NIH_IMAGE_HEADER
|
MM_TAG_IDS
|
MM_DIMENSION
|
MM_HEADER
|
CZ_LSM_INFO
|
CZ_LSM_INFO_READERS
|
CZ_SCAN_TYPES
|
CZ_DIMENSIONS
|
CZ_DATA_TYPES
|
CZ_LSM_SCAN_INFO_ARRAYS
|
CZ_LSM_SCAN_INFO_STRUCTS
|
CZ_LSM_SCAN_INFO_ATTRIBUTES
|
TIFF_TAGS
|
CUSTOM_TAGS
|
__warningregistry__
|
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Dec 15 19:07:38 2017 | http://epydoc.sourceforge.net |