Create New DICOM Series
This example shows how to create a new DICOM series for a modified DICOM image.
In the DICOM standard, images can be organized into series. By default, when you write an image with metadata to a DICOM file,dicomwrite
puts the image in the same series. You typically only start a new DICOM series when you modify the image in some way. To make the modified image the start of a new series, assign a new DICOM unique identifier to theSeriesInstanceUID
metadata field.
Read an image from a DICOM file into the workspace.
I = dicomread('CT-MONO2-16-ankle.dcm');
Display the image. Because the DICOM image data is signed 16-bit data, automatically scale the display range so that the minimum pixel value is black and the maximum pixel value is white.
imshow(I,'DisplayRange',[])
Read the metadata from the DICOM file.
info = dicominfo('CT-MONO2-16-ankle.dcm');
To identify the series an image belongs to, view the value of theSeriesInstanceUID
metadata field.
info.SeriesInstanceUID
ans = '1.2.840.113619.2.1.2411.1031152382.365.736169244'
This example modifies the image by removing all of the text from the image. Text in the image appears white. Find the maximum value of all pixels in the image, which corresponds to the white text.
textValue = max(I(:));
The background of the image appears black. Find the minimum value of all pixels in the image, which corresponds to the background.
backgroundValue = min(I(:));
To remove the text, set all pixels with the maximum value to the minimum value.
Imodified = I; Imodified(Imodified == textValue) = backgroundValue;
View the processed image.
imshow(Imodified,'DisplayRange',[])
要将修改后的图像写为新系列,您需要一个新的DICOM唯一标识符(UID)。使用dicomuid
function.dicomuid
is guaranteed to generate a unique UID.
uid = dicomuid
uid = '1.3.6.1.4.1.9590.100.1.2.159244501229090632122348033341062077923'
设置的值SeriesInstanceUID
field in the metadata associated with the original DICOM file to the generated value.
info.SeriesInstanceUID = uid;
Write the modified image to a new DICOM file, specifying the modified metadata structure,info
, as an argument. Because you set theSeriesInstanceUID
value, the written image is part of a new series.
dicomwrite(Imodified,'ankle_newseries.dcm',info);
To verify this operation, view the image and theSeriesInstanceUID
metadata field in the new file.