Image Processing Toolbox    
dicomwrite

Write images as DICOM file

Syntax

Description

dicomwrite(X,filename) writes the binary, grayscale, or truecolor image, X, to the file, filename, where filename is a string specifying the name of the Digital Imaging and Communications in Medicine (DICOM) file to create.

dicomwrite(X,map,filename) writes the indexed image, X, with colormap, map.

dicomwrite(...,param1,value1,param2,value2,...) specifies additional metadata to write to the DICOM file. The parameters (param1, param2, etc.) are either names of DICOM file attributes or options that affect how the file is written. Each attribute or option has a corresponding value (value1, value2, etc.).

To find a list of the names of DICOM attributes, see the data dictionary file, dicom-dict.txt, included with the Image Processing Toolbox.

This table lists the options supported by the dicomwrite function.

Option Name
Description
Values
'Endian'
Specifies the byte-ordering for the file.
'Little' [Default]
'Big'
'VR'
Specifies whether the two-letter value representation (VR) code should be written to the file ('explicit') or inferred from the data dictionary ('implicit').
'Implicit' [Default] 'Explicit'
Note: If you specify the 'Endian' value 'Big', you can only specify the 'VR' value of 'Explicit'.
'CompressionMode'
Specifies the type of compression to use when storing the image.
'None' [Default]
'JPEG lossy'
'RLE'

'TransferSyntax'
A DICOM UID specifying the DICOM Transfer Syntax.
Note: If you specify the 'TransferSyntax' option, dicomwrite ignores the other three options, if they are specified. The 'TransferSyntax' option encodes the settings for the 'Endian', 'VR' and 'CompressionMode' options in a single value.
A DICOM Transfer Syntax that specifies the default values for 'Endian', 'VR', and 'CompressionMode' options.

dicomwrite(...,meta_struct,...) specifies metadata in a structure, meta_struct. The structure's field names must be the names of DICOM file attributes or options. The field's value is the value of that attribute or option.

dicomwrite(...,info,...) specifies metadata in the metadata structure, info, which is produced by the dicominfo function. For more information about this structure, see dicominfo.

status = dicomwrite(...) returns a structure that lists three types of metadata that were passed to dicomwrite:

This syntax can be useful when you specify an info structure that was created by dicominfo to the dicomwrite function. An info structure can contain many fields. If no metadata was specified, dicomwrite returns an empty matrix ([]).

The structure returned by dicomwrite contains these three fields.

Field
Description
'dicominfo_fields'

A cell array containing the names of metadata passed to dicomwrite that does not affect how the file is written.

'wrong_IOD'

A cell array containing the names of attributes passed to dicomwrite that do not pertain to the type of image being written. (IOD=Information Object Definition)

'not_modifiable'

A cell array containing the names of valid metadata fields for the image that cannot be modified by the user.

Example

This example uses dicominfo to retrieve information about the contents of the sample DICOM file included with the Image Processing Toolbox. The example uses dicomread to read the data from the file and then writes the data into a new DICOM file, including the metadata from the original file.

See Also

dicomread, dicominfo


  dicomread dilate