Image Processing Toolbox    
dicomread

Read a DICOM image

Syntax

Description

X = dicomread(filename) reads the image data from the compliant Digital Imaging and Communications in Medicine (DICOM) file, filename. For single-frame grayscale images, X is an M-by-N array. For single-frame true-color images, X is an M-by-N-by-3 array. Multiframe images are always 4-D arrays.

X = dicomread(info) reads the image data from the message referenced in the DICOM metadata structure info. The info structure is produced by the dicominfo function.

[X,map] = dicomread(...) returns the image X and the colormap MAP. If X is a grayscale or true-color image, MAP is empty.

[X,map,alpha] = dicomread(...) returns the image X, the colormap map, and an alpha channel matrix for X. The values of alpha are 0 if the pixel is opaque; otherwise they are row indices into map. The RGB value in map 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.

[X,map,alpha,overlays] = dicomread(...) also returns the image X, the colormap map, an alpha channel matrix for X, and any 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, overlays is a 4-D multiframe image. If no overlays are in the file, overlays is empty.

The first input argument, either filename or info, can be followed by a set of parameter name/value pairs.

Supported parameters names and values include the following.

'Frames', V
dicomread reads only the frames in the vector V from the image. V must be an integer scalar, a vector of integers, or the string 'all'. The default value is 'all'.
'Dictionary', D
dicomread uses the data dictionary file whose filename is in the string D. The default value is 'dicom-dict.txt'.
'Raw', TF
dicomread performs pixel-level transformations depending on whether TF is 1 or 0. If TF is 1 (the default), dicomread reads the exact pixels from the image and no pixel-level transformations are performed. If TF is 0, images are rescaled to use the full dynamic range, and color images are automatically converted to the RGB colorspace.
Note 1: Because the HSV colorspace is inadequately defined in the DICOM standard, dicomread does not automatically convert them to RGB.
Note 2: dicomread never rescales or changes the color spaces of images containing signed data.
Note 3: Rescaling values and applying colorspace conversions does not change the metadata in any way. Consequently, metadata values that refer to pixel values (such as window center/width or LUTs) may not be correct when pixels are scaled or converted.

Examples

Example 1

Use dicomread to retrieve the data matrix, X, and colormap matrix, map, needed to create a montage.

Example 2

Call dicomread with the information retrieved from the DICOM file using dicominfo. Display the image with imshow.

See Also

dicominfo, dicomwrite


  dicominfo dicomwrite