external.tifffile
¶skimage.external.tifffile.imread (files, **kwargs) |
Return image data from TIFF file(s) as numpy array. |
skimage.external.tifffile.imsave (file, data, …) |
Write image data to TIFF file. |
skimage.external.tifffile.imshow (data[, …]) |
Plot n-dimensional images using matplotlib.pyplot. |
skimage.external.tifffile.TiffFile (arg[, …]) |
Read image and metadata from TIFF, STK, LSM, and FluoView files. |
skimage.external.tifffile.TiffSequence (files) |
Sequence of image files. |
skimage.external.tifffile.TiffWriter (file[, …]) |
Write image data to TIFF file. |
skimage.external.tifffile.tifffile |
Read image and meta data from (bio)TIFF files. |
skimage.external.tifffile.
imread
(files, **kwargs)[source]¶Return image data from TIFF file(s) as numpy array.
Refer to the TiffFile class and member functions for documentation.
Parameters: | files : str, binary stream, or sequence
kwargs : dict
|
---|
Examples
>>> imsave('temp.tif', numpy.random.rand(3, 4, 301, 219))
>>> im = imread('temp.tif', key=0)
>>> im.shape
(4, 301, 219)
>>> ims = imread(['temp.tif', 'temp.tif'])
>>> ims.shape
(2, 3, 4, 301, 219)
skimage.external.tifffile.
imsave
(file, data, **kwargs)[source]¶Write image data to TIFF file.
Refer to the TiffWriter class and member functions for documentation.
Parameters: | file : str or binary stream
data : array_like
kwargs : dict
|
---|
Examples
>>> data = numpy.random.rand(2, 5, 3, 301, 219)
>>> imsave('temp.tif', data, compress=6, metadata={'axes': 'TZCYX'})
skimage.external.tifffile.
imshow
(data, title=None, vmin=0, vmax=None, cmap=None, bitspersample=None, photometric='rgb', interpolation=None, dpi=96, figure=None, subplot=111, maxdim=8192, **kwargs)[source]¶Plot n-dimensional images using matplotlib.pyplot.
Return figure, subplot and plot axis. Requires pyplot already imported from matplotlib import pyplot.
Parameters: | bitspersample : int or None
photometric : {‘miniswhite’, ‘minisblack’, ‘rgb’, or ‘palette’}
title : str
figure : matplotlib.figure.Figure (optional).
subplot : int
maxdim : int
kwargs : optional
|
---|
TiffFile
¶skimage.external.tifffile.
TiffFile
(arg, name=None, offset=None, size=None, multifile=True, multifile_close=True, pages=None, fastij=True, is_ome=None)[source]¶Bases: object
Read image and metadata from TIFF, STK, LSM, and FluoView files.
TiffFile instances must be closed using the ‘close’ method, which is automatically called when using the ‘with’ context manager.
Examples
>>> with TiffFile('temp.tif') as tif:
... data = tif.asarray()
... data.shape
(5, 301, 219)
Attributes
pages | (list of TiffPage) All TIFF pages in file. |
series | (list of TiffPageSeries) TIFF pages with compatible shapes and types. |
micromanager_metadata: dict | Extra MicroManager non-TIFF metadata in the file, if exists. |
All attributes are read-only. |
__init__
(arg, name=None, offset=None, size=None, multifile=True, multifile_close=True, pages=None, fastij=True, is_ome=None)[source]¶Initialize instance from file.
Parameters: | arg : str or open file
name : str
offset : int
size : int
multifile : bool
multifile_close : bool
pages : sequence of int
fastij : bool
is_ome : bool
|
---|
asarray
(key=None, series=None, memmap=False, tempdir=None)[source]¶Return image data from multiple TIFF pages as numpy array.
By default the first image series is returned.
Parameters: | key : int, slice, or sequence of page indices
series : int or TiffPageSeries
memmap : bool
tempdir : str
|
---|
filehandle
¶Return file handle.
filename
¶Return name of file handle.
fstat
¶Lazy object attribute whose value is computed on first access.
is_bigtiff
¶Lazy object attribute whose value is computed on first access.
is_fei
¶Lazy object attribute whose value is computed on first access.
is_fluoview
¶Lazy object attribute whose value is computed on first access.
is_imagej
¶Lazy object attribute whose value is computed on first access.
is_indexed
¶Lazy object attribute whose value is computed on first access.
is_lsm
¶Lazy object attribute whose value is computed on first access.
is_mdgel
¶Lazy object attribute whose value is computed on first access.
is_mediacy
¶Lazy object attribute whose value is computed on first access.
is_micromanager
¶Lazy object attribute whose value is computed on first access.
is_nih
¶Lazy object attribute whose value is computed on first access.
is_ome
¶Lazy object attribute whose value is computed on first access.
is_rgb
¶Lazy object attribute whose value is computed on first access.
is_scn
¶Lazy object attribute whose value is computed on first access.
is_sem
¶Lazy object attribute whose value is computed on first access.
is_stk
¶Lazy object attribute whose value is computed on first access.
is_tvips
¶Lazy object attribute whose value is computed on first access.
is_vista
¶Lazy object attribute whose value is computed on first access.
series
¶Lazy object attribute whose value is computed on first access.
TiffSequence
¶skimage.external.tifffile.
TiffSequence
(files, imread=<class 'skimage.external.tifffile.tifffile.TiffFile'>, pattern='axes', *args, **kwargs)[source]¶Bases: object
Sequence of image files.
The data shape and dtype of all files must match.
Attributes
files | (list) List of file names. |
shape | (tuple) Shape of image sequence. |
axes | (str) Labels of axes in shape. |
__init__
(files, imread=<class 'skimage.external.tifffile.tifffile.TiffFile'>, pattern='axes', *args, **kwargs)[source]¶Initialize instance from multiple files.
Parameters: | files : str, or sequence of str
imread : function or class
pattern : str
|
---|
asarray
(memmap=False, tempdir=None, *args, **kwargs)[source]¶Read image data from all files and return as single numpy array.
If memmap is True, return an array stored in a binary file on disk. The args and kwargs parameters are passed to the imread function.
Raise IndexError or ValueError if image shapes do not match.
TiffWriter
¶skimage.external.tifffile.
TiffWriter
(file, append=False, bigtiff=False, byteorder=None, software='tifffile.py', imagej=False)[source]¶Bases: object
Write image data to TIFF file.
TiffWriter instances must be closed using the ‘close’ method, which is automatically called when using the ‘with’ context manager.
Examples
>>> data = numpy.random.rand(2, 5, 3, 301, 219)
>>> with TiffWriter('temp.tif', bigtiff=True) as tif:
... for i in range(data.shape[0]):
... tif.save(data[i], compress=6)
__init__
(file, append=False, bigtiff=False, byteorder=None, software='tifffile.py', imagej=False)[source]¶Open a TIFF file for writing.
Existing files are overwritten by default. Use bigtiff=True when creating files larger than 2 GB.
Parameters: | file : str, binary stream, or FileHandle
append : bool
bigtiff : bool
byteorder : {‘<’, ‘>’}
software : str
imagej : bool
|
---|
TAGS
= {'photometric': 262, 'planar_configuration': 284, 'smin_sample_value': 340, 'strip_offsets': 273, 'extra_samples': 338, 'color_map': 320, 'y_resolution': 283, 'tile_byte_counts': 325, 'predictor': 317, 'tile_depth': 32998, 'samples_per_pixel': 277, 'page_name': 285, 'image_width': 256, 'compression': 259, 'strip_byte_counts': 279, 'subfile_type': 255, 'software': 305, 'sample_format': 339, 'new_subfile_type': 254, 'tile_offsets': 324, 'bits_per_sample': 258, 'resolution_unit': 296, 'image_depth': 32997, 'image_description': 270, 'x_resolution': 282, 'datetime': 306, 'smax_sample_value': 341, 'image_length': 257, 'tile_length': 323, 'tile_width': 322, 'orientation': 274, 'document_name': 269, 'rows_per_strip': 278}¶TYPES
= {'H': 3, '2I': 5, '2i': 10, 'h': 8, 'd': 12, 'b': 6, 'I': 4, 'B': 1, 'i': 9, 'q': 17, 's': 2, 'Q': 16, 'f': 11}¶save
(data, photometric=None, planarconfig=None, tile=None, contiguous=True, compress=0, colormap=None, description=None, datetime=None, resolution=None, metadata={}, extratags=())[source]¶Write image data and tags to TIFF file.
Image data are written in one stripe per plane by default. Dimensions larger than 2 to 4 (depending on photometric mode, planar configuration, and SGI mode) are flattened and saved as separate pages. The ‘sample_format’ and ‘bits_per_sample’ tags are derived from the data type.
Parameters: | data : numpy.ndarray
photometric : {‘minisblack’, ‘miniswhite’, ‘rgb’, ‘palette’, ‘cfa’}
planarconfig : {‘contig’, ‘planar’}
tile : tuple of int
contiguous : bool
compress : int or ‘lzma’
colormap : numpy.ndarray
description : str
datetime : datetime
resolution : (float, float[, str]) or ((int, int), (int, int)[, str])
metadata : dict
extratags : sequence of tuples
|
---|