TiffWriter
-
class 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
Name of file to write.
bigtiff : bool
If True, the BigTIFF format is used.
byteorder : {‘<’, ‘>’}
The endianness of the data in the file. By default this is the system’s native byte order.
software : str
Name of the software used to create the image. Saved with the first page only.
-
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}
-
close()
[source]
-
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
Input image. The last dimensions are assumed to be image depth, 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.
compress : int
Values from 0 to 9 controlling the level of zlib compression. If 0, data are written uncompressed (default).
volume : bool
If True, volume data are stored in one tile (if applicable) using the SGI image_depth and tile_depth tags. Image width and depth must be multiple of 16. Few software can read this format, e.g. MeVisLab.
writeshape : bool
If True, write the data shape to the image_description tag if necessary and no other description is given.
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.
-
-
Please login to continue.