Main Content


Read DICOM image



X = dicomread(filename) reads the image data from the compliant Digital Imaging and Communications in Medicine (DICOM) file filename. To read a group of DICOM files that contain a series of images that comprise a volume, use dicomreadVolume.

X = dicomread(info) reads DICOM image data from the message referenced in the DICOM metadata structure info.

X = dicomread(___,'frames',f) reads only the frames specified by f from the image.

X = dicomread(___,Name,Value) reads DICOM image data using Name,Value pairs to configure the parser.

[X,cmap] = dicomread(___) also returns the colormap, cmap.

[X,cmap,alpha] = dicomread(___) also returns alpha, an alpha channel matrix for X.

[X,cmap,alpha,overlays] = dicomread(___) also returns any overlays from the DICOM file.


collapse all

Read indexed image from DICOM file and display it using montage.

[X, map] = dicomread('US-PAL-8-10x-echo.dcm');
montage(X, map, 'Size', [2 5]);

Figure contains an axes object. The axes object contains an object of type image.

Read image from DICOM file and display it using imshow.

info = dicominfo('CT-MONO2-16-ankle.dcm');
Y = dicomread(info);

Figure contains an axes object. The axes object contains an object of type image.

Input Arguments

collapse all

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

Data Types: char | string

DICOM metadata, specified as a structure. The info structure is produced by the dicominfo function.

Frames to read, specified as an integer scalar, a vector of integers, or 'all'. When f is numeric, dicomread reads only the specified frame numbers from the image. By default, dicomread reads all frames of the DICOM image.

Name-Value Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: dicomread('CT-MONO2-16-ankle.dcm','UseVRHeuristic',false)

Read noncompliant DICOM files that switch value representation (VR) modes incorrectly, specified as the comma-separated pair consisting of 'UseVRHeuristic' and true or false.

When set to true (the default), dicomread uses a heuristic to help read certain noncompliant DICOM files that switch VR modes incorrectly. dicomread displays a warning if the heuristic is used. A small number of compliant files will not be read correctly. Set UseVRHeuristic to false to read these compliant files.

Data Types: logical

Output Arguments

collapse all

DICOM image, returned as one of the following.

  • An m-by-n matrix representing a single-frame grayscale image or an indexed image

  • An m-by-n-by-3 array representing a single-frame truecolor (RGB) image

  • A 4-D array representing a multiframe image.

Data Types: int8 | int16 | uint8 | uint16

Colormap associated with image X.

  • If X is an indexed image, then cmap is returned as c-by-3 numeric matrix with values in the range [0, 1]. Each row is a three-element RGB triplet that specifies the red, green, and blue components of a single color of the colormap.

  • If X is a grayscale or truecolor image, then cmap is empty ([]).

Data Types: double

Alpha channel matrix for image X, returned as an array of nonnegative integers. The values of alpha are 0 if the pixel is opaque; otherwise they are row indices into cmap. The RGB value in cmap should be substituted for the value in X to use alpha. alpha has the same height and width as X and is 4-D for a multiframe image. alpha has the same data type as X.

Data Types: int8 | int16 | uint8 | uint16

Overlays from the DICOM file. Each overlay is a 1-bit black and white image with the same height and width as X. If multiple overlays are present in the file, then overlays is a 4-D multiframe image. If no overlays are in the file, then overlays is empty ([]).

Data Types: logical


  • This function reads imagery from files with one of these pixel formats:

    • Little-endian, implicit VR, uncompressed

    • Little-endian, explicit VR, uncompressed

    • Big-endian, explicit VR, uncompressed

    • JPEG (lossy or lossless)

    • JPEG2000 (lossy or lossless)

    • Run-length Encoding (RLE)

    • GE implicit VR, LE with uncompressed BE pixels (1.2.840.113619.5.2)

Introduced before R2006a