Main Content

tiffreadVolume

Read volume or time series image stack from TIFF file

Since R2020b

    Description

    V = tiffreadVolume(filename) loads all of the volumetric or time series image data in the multipage TIFF file named filename into V. The spatial and time dimensions in V are first, and color (if present) is in the final dimension.

    example

    V = tiffreadVolume(filename,'PixelRegion',{rows,columns,slices}) reads a subset of the volume or time series V. {rows,columns,slices} is a cell array that specifies the subsampling along each dimension.

    Examples

    collapse all

    This example shows how to read volumetric data stored in a TIFF file.

    Read Entire Volume from File

    Read a volume from a TIFF file into the workspace. In this example, the volume is a stack of 27 MRI images. Each image is 128-by-128 pixels in size.

    V1 = tiffreadVolume('mri.tif');
    whos V1
      Name        Size                 Bytes  Class    Attributes
    
      V1        128x128x27            442368  uint8              
    

    Read Subsection of Volume from File

    Read a subsection of a volume from a TIFF file into the workspace. The example uses the 'PixelRegion' parameter to specify which part of the volume to read. You specify the subsection in a cell array of the form: {rows, columns, slices}. The example specifies to start reading at the first pixel and reads every other pixel in the row and column dimensions. The example reads slices 10 through 15.

    V2 = tiffreadVolume('mri.tif',...
        'PixelRegion', {[1 2 inf], [1 2 inf], [10 15]});
    whos V2
      Name       Size              Bytes  Class    Attributes
    
      V2        64x64x6            24576  uint8              
    

    Input Arguments

    collapse all

    Name of TIFF file, specified as a character vector or a string scalar.

    Example: "mri.tif"

    Data Types: char | string

    Subsampling instructions, specified as a cell array containing three elements: {row,column,slice}. Specifying slice is optional. If you do not specify it, tiffreadVolume reads all the slices in the image stack.

    Each of the elements in the cell array is a numeric vector of the form [start stop] or [start stride stop]. start specifies where to start reading on a particular dimension. stop specifies where to stop reading on a particular dimension. To read to the end of the dimension, specify the value inf for stop. The start and stop values are inclusive. stride specifies whether to read every pixel along a particular dimension or subsample the dimension by skipping over pixels.

    For example, to start reading at the first pixel, read every other pixel, and continue reading until the end of the dimension, specify [1 2 inf].

    Data Types: cell | double | single

    Output Arguments

    collapse all

    Volume or time series image stack, returned as a numeric array.

    Tips

    This function supports reading volumetric and time series data from the following kinds of TIFF stacks:

    • Image data stored in the file as individual Image File Directories (IFDs) of the same size and kind.

    • Image data stored in the file as one image using the TIFF ImageDepth tag.

    • Image data stored as large, non-BigTIFF files, greater than 4GB, created by ImageJ.

    Version History

    Introduced in R2020b