Image Processing Toolbox | ![]() ![]() |
Syntax
dicomwrite(X, filename) dicomwrite(X, map, filename) dicomwrite(...,param1,value1,param2,value2,...) dicomwrite(...,meta_struct,...) dicomwrite(...,info,...) status = dicomwrite(...)
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.
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.
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.
info = dicominfo('CT-MONO2-16-ankle.dcm'); Y = dicomread(info); status = dicomwrite(Y,'my_dicomfile.dcm',info); status = dicominfo_fields: {12x1 cell} wrong_IOD: {21x1 cell} not_modifiable: {23x1 cell} status.dicominfo_fields ans = 'BitDepth' 'ColorType' 'FileModDate' 'FileSize' 'FileStruct' 'Filename' 'Format' 'FormatVersion' 'Height' 'SelectedFrames' 'StartOfPixelData' 'Width'
See Also
![]() | dicomread | dilate | ![]() |