skimage2.io.MultiImage#

class skimage2.io.MultiImage(filename, conserve_memory=True, dtype=None, **imread_kwargs)[source]#

Bases: ImageCollection

A class containing all frames from multi-frame TIFF images.

Parameters:
load_patternstr or list of str

Pattern glob or filenames to load. The path can be absolute or relative.

conserve_memorybool, optional

Whether to conserve memory by only caching the frames of a single image. Default is True.

Notes

MultiImage returns a list of image-data arrays. In this regard, it is very similar to ImageCollection, but the two differ in their treatment of multi-frame images.

For a TIFF image containing N frames of size WxH, MultiImage stores all frames of that image as a single element of shape (N, W, H) in the list. ImageCollection instead creates N elements of shape (W, H).

For an animated GIF image, MultiImage reads only the first frame, while ImageCollection reads all frames by default.

Examples

>>> from pathlib import Path
>>> from _skimage2.io import ImageCollection

Get directory containing data files.

>>> from _skimage2 import data
>>> data_dir = Path(data.legacy_data_dir)
>>> multipage_tiff = str(data_dir / 'multipage.tif')
>>> multi_img = MultiImage(multipage_tiff)
>>> len(multi_img)  # multi_img contains one element
1
>>> multi_img[0].shape  # this element is a two-frame image of shape:
(2, 15, 10)
>>> image_col = ImageCollection(multipage_tiff)
>>> len(image_col)  # image_col contains two elements
2
>>> for frame in image_col:
...     print(frame.shape)  # each element is a frame of shape (15, 10)
...
(15, 10)
(15, 10)
__init__(filename, conserve_memory=True, dtype=None, **imread_kwargs)[source]#

Load a multi-img.

concatenate()[source]#

Concatenate all images in the collection into an array.

Returns:
arnp.ndarray

An array having one more dimension than the images in self.

Raises:
ValueError

If images in the skimage.io.ImageCollection do not have identical shapes.

property conserve_memory#
property filename#
property files#
reload(n=None)[source]#

Clear the image cache.

Parameters:
nNone or int

Clear the cache for this image only. By default, the entire cache is erased.