Convert multi-image TIFF file to directory of images.


Updated 27 May 2016

View License

TIFF2DIR Convert multi-image TIFF file to directory of images.
TIFF2DIR(TIFF) reads the input image volume, creates a new directory
with the same name as the input file, and writes each slice of the
image volume to that directory.

TIFF2DIR() with no input arguments opens a dialog box and queries the
user to select an input file.

FILES = TIFF2DIR(___) returns a cell array containing the fullpath of
each generated image file.

TIFF2DIR(___,Name,Value,___) uses additional parameter name-value
pairs. Valid parameters include:

'Binary' Logical scalar indicating whether to convert the TIFF
image slices to binary images, if possible. This
parameter is useful for image masks that are stored as
{0,255} instead of {0,1}. Note that this parameter has
no effect on multi-color (more than two colors) images.

Default: true

'Format' String indicating the format of the output images. This
is used as the third input argument to IMWRITE, so any
supported image type of that function is valid here.

Default: 'png'

'Indices' Positive integer or vector of integers specifying which
images to read from the input file. Can also be set to
the string 'all', which will read all available images
from the input file.

Default: 'all'

'Parent' String indicating the parent directory for the output
subdirectory of images.

Default: the parent directory of the input file

1) Unpack MRI TIFF file into directory of PNG images:


2) Unpack 10 MRI image slices into named directory of JPEG images and
return the filenames as output:

files = tiff2dir('mri.tif','format','jpg','indices',1:10,'parent','data')

>> files =

Cite As

Matthew Eicholtz (2023). tiff2dir (https://www.mathworks.com/matlabcentral/fileexchange/57379-tiff2dir), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Added optional output of image filenames.