porespy.io.folder_to_stack#
- porespy.io.folder_to_stack(target_dir, *, max_bytes=None)#
Read a folder of 2D grayscale images into one 3D array.
- Parameters:
target_dir (str or path object) – Folder containing the image slices. Subfolders are not searched.
max_bytes (int, optional) – Maximum size in bytes of the returned array. The image headers are checked before allocating the array or decoding pixels. This does not include the memory needed to decode an individual slice. By default, no limit is imposed.
- Returns:
im – Array with shape
(rows, columns, number_of_slices)and the slices’ original dtype and values.- Return type:
ndarray
- Raises:
ValueError – If no supported images are found, a slice cannot be read, the slices are not 2D or have differing shapes or dtypes, filenames have ambiguous ordering, or the array exceeds
max_bytes.
Notes
Images are sorted by filename in case-insensitive natural order:
slice2precedesslice10. Zero-padded names such as001.tifalso work. Names equivalent under this ordering, such as1.tifand01.tif, are rejected. Missing sequence numbers are not filled or inferred.TIFF, PNG, JPEG, BMP, GIF, PBM, PGM, PNM and WebP extensions are recognized; the corresponding imageio decoder must be installed. Color images and multi-page images are rejected. Hidden files, subfolders and files with other extensions are ignored. Symbolic links to images are rejected.
See also