Routines (alphabetical) > Routines: R > READ_DICOM

# READ_DICOM

The READ_DICOM function reads an image from a DICOM file along with any associated color table.The return array type depends on the DICOM image pixel type.

This routine is written in the IDL language. Its source code can be found in the file `read_dicom.pro` in the `lib` subdirectory of the IDL distribution.

## Examples

TVSCL,READ_DICOM(FILEPATH('mr_knee.dcm',$
SUBDIR=['examples','data']))

## Syntax

Result = READ_DICOM (Filename [, Red, Green, Blue] [, IMAGE_INDEX=index] [, /DICOMEX] )

## Return Value

The return value can be a 2-D array for grayscale or a 3-D array for TrueColor images. TrueColor images are always returned in pixel interleave format. The return value will be 0 (zero) if Filename is not a valid DICOM file.

## Arguments

### Filename

This argument is a scalar string that contains the full pathname of the file to read.

### Red, Green, Blue

Named variables that will contain the red, green, and blue color vectors from the DICOM file if they exist.

Note: DICOM color vectors contain 16- bit color values that may need to be converted for use with IDL graphics routines.

## Keywords

### IMAGE_INDEX

Set this keyword to the index of the image to read from the file.

### DICOMEX

This keyword is set by default. When an additional cost DICOM Read/Write license or Read/Write runtime license is available, and an IDLffDicomEX object can be created, IDL uses the IDLffDicomEx object to read the DICOM file. (See IDLffDicomEx.)

If these conditions are not met, or if this keyword is set to 0, IDL uses the IDLffDICOMobject to read the DICOM file instead.

READ_DICOM always returns the image array in DICOM format where the first pixel in the returned array is the top left-hand pixel in the frame. By default, the IDLffDicomEx::GetPixelData method returns pixel data in standard IDL format where the first pixel in the returned array is the bottom left-hand pixel in the frame. Set the GetPixelData ORDER keyword to return the array in DICOM format.

## Version History

5.2 | Introduced
6.2 | Added DICOMEX keyword

## See Also

IOPEN, QUERY_DICOM