Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

dicomread

Read DICOM image

Syntax

X = dicomread(filename)
X = dicomread(info)
[X,map] = dicomread(...)
[X,map,alpha] = dicomread(...)
[X,map,alpha,overlays] = dicomread(...)
[...] = dicomread(filename,'frames',n)
[...] = dicomread(___,'UseVRHeuristic',TF)

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. To read a group of DICOM files that contain a series of images that comprise a volume, use dicomreadVolume.

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(...) 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.

[...] = dicomread(filename,'frames',n) reads only the frames in the vector n from the image. n must be an integer scalar, a vector of integers, or 'all'. The default value is 'all'.

[...] = dicomread(___,'UseVRHeuristic',TF) instructs the parser to use a heuristic to help read certain noncompliant files which switch value representation (VR) modes incorrectly. dicomread displays a warning if the heuristic is used. When TF is true (the default), a small number of compliant files will not be read correctly. Set TF to false to read these compliant files.

Class Support

X can be uint8, int8, uint16, or int16. map must be double. alpha has the same size and type as X. overlays is a logical array.

Examples

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]);

Read image from DICOM file and display it using imshow.

info = dicominfo('CT-MONO2-16-ankle.dcm');
Y = dicomread(info);
figure
imshow(Y,[]);

Tips

  • 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

Was this topic helpful?