external.tifffile
¶skimage.external.tifffile.imread (files, **kwargs) |
Return image data from TIFF file(s) as numpy array. |
skimage.external.tifffile.imsave (filename, ...) |
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 (filename) |
Write image data to TIFF file. |
skimage.external.tifffile.
imread
(files, **kwargs)[source]¶Return image data from TIFF file(s) as numpy array.
The first image series is returned if no arguments are provided.
Parameters: | files : str or list
key : int, slice, or sequence of page indices
series : int
multifile : bool
pattern : str
kwargs : dict
|
---|
Examples
>>> im = imread('test.tif', key=0)
>>> im.shape
(256, 256, 4)
>>> ims = imread(['test.tif', 'test.tif'])
>>> ims.shape
(2, 256, 256, 4)
skimage.external.tifffile.
imsave
(filename, data, **kwargs)[source]¶Write image data to TIFF file.
Refer to the TiffWriter class and member functions for documentation.
Parameters: | filename : str
data : array_like
kwargs : dict
|
---|
Examples
>>> data = numpy.random.rand(2, 5, 3, 301, 219)
>>> description = u'{"shape": %s}' % str(list(data.shape))
>>> imsave('temp.tif', data, compress=6,
... extratags=[(270, 's', 0, description, True)])
skimage.external.tifffile.
imshow
(data, title=None, vmin=0, vmax=None, cmap=None, bitspersample=None, photometric='rgb', interpolation='nearest', 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)[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’ statement.
Examples
>>> with TiffFile('test.tif') as tif:
... data = tif.asarray()
... data.shape
(256, 256, 4)
Attributes
pages | (list) All TIFF pages in file. |
series | (list of Records(shape, dtype, axes, TiffPages)) 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)[source]¶Initialize instance from file.
Parameters: | arg : str or open file
name : str
offset : int
size : int
multifile : bool
multifile_close : bool
|
---|
asarray
(key=None, series=None, memmap=False)[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
memmap : bool
|
---|
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_fluoview
¶Lazy object attribute whose value is computed on first access.
is_imagej
¶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_palette
¶Lazy object attribute whose value is computed on first access.
is_rgb
¶Lazy object attribute whose value is computed on first access.
is_stk
¶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.
Examples
>>> tifs = TiffSequence("test.oif.files/*.tif")
>>> tifs.shape, tifs.axes
((2, 100), 'CT')
>>> data = tifs.asarray()
>>> data.shape
(2, 100, 256, 256)
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
|
---|
ParseError
[source]¶Bases: exceptions.Exception
TiffSequence.
asarray
(memmap=False, *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 don’t match.
TiffWriter
¶skimage.external.tifffile.
TiffWriter
(filename, bigtiff=False, byteorder=None, software='tifffile.py')[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’ statement.
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__
(filename, bigtiff=False, byteorder=None, software='tifffile.py')[source]¶Create a new TIFF file for writing.
Use bigtiff=True when creating files greater than 2 GB.
Parameters: | filename : str
bigtiff : bool
byteorder : {‘<’, ‘>’}
software : str
|
---|
TAGS
= {'strip_byte_counts': 279, 'strip_offsets': 273, 'resolution_unit': 296, 'x_resolution': 282, 'photometric': 262, 'y_resolution': 283, 'subfile_type': 255, 'tile_byte_counts': 325, 'tile_offsets': 324, 'tile_width': 322, 'image_depth': 32997, 'bits_per_sample': 258, 'tile_depth': 32998, 'image_length': 257, 'datetime': 306, 'document_name': 269, 'orientation': 274, 'planar_configuration': 284, 'sample_format': 339, 'compression': 259, 'image_description': 270, 'fill_order': 266, 'image_width': 256, 'rows_per_strip': 278, 'color_map': 320, 'page_name': 285, 'samples_per_pixel': 277, 'new_subfile_type': 254, 'tile_length': 323, 'extra_samples': 338, 'predictor': 317, 'software': 305}¶TYPES
= {'B': 1, 'I': 4, 'H': 3, 'Q': 16, '2I': 5, 'b': 6, 'd': 12, 'f': 11, 'i': 9, 'h': 8, 'q': 17, 's': 2}¶save
(data, photometric=None, planarconfig=None, resolution=None, description=None, volume=False, writeshape=False, compress=0, extratags=())[source]¶Write image data to TIFF file.
Image data are written in one stripe per plane. 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’ TIFF tags are derived from the data type.
Parameters: | data : array_like
photometric : {‘minisblack’, ‘miniswhite’, ‘rgb’}
planarconfig : {‘contig’, ‘planar’}
resolution : (float, float) or ((int, int), (int, int))
description : str
compress : int
volume : bool
writeshape : bool
extratags: sequence of tuples
|
---|