tiffreadVolume

Read volume from TIFF file

    Description

    example

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

    V = tiffreadVolume(filename,'PixelRegion',{rows,columns,slices}) reads a subset of the volume 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 string.

    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 volume.

    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, returned as a numeric array.

    Tips

    This function supports the following kinds of TIFF volumes:

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

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

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

    Introduced in R2020b