Определяет энкодер для DICOM-изображений.
Вот C#/VB.NET код, который демонстрирует, как загрузить DICOM-изображения из DICOM-файла, прожечь наложенные изображения на DICOM-изображениях и сохранить измененные DICOM-изображения в новый DICOM-файл.
''' <summary>
''' Loads DICOM images from DICOM file, burns the overlay images on DICOM images and saves changed DICOM images to a new DICOM file.
''' </summary>
''' <param name="sourceFilePath">A path to a source DICOM file.</param>
''' <param name="destFilePath">A path to the destination DICOM file.</param>
Public Shared Sub BurnOverlayImagesAndSaveToDicomFile(sourceFilePath As String, destFilePath As String)
' create image collection
Using images As New Vintasoft.Imaging.ImageCollection()
' open DICOM file
images.Add(sourceFilePath)
Try
' create DICOM decoding settings
Dim decodingSettings As New Vintasoft.Imaging.Codecs.Decoders.DicomDecodingSettings()
' specify that DICOM decoder needs to draw overlay images on DICOM image
decodingSettings.ShowOverlayImages = True
' set the DICOM decoding settings for all images in image collection
images.SetDecodingSettings(decodingSettings)
' for each image in image collection
For Each image As Vintasoft.Imaging.VintasoftImage In images
' convert image to BGR24-image
image.ConvertToBgr24()
Next
' create DICOM encoder
Using encoder As New Vintasoft.Imaging.Codecs.Encoders.DicomEncoder()
' save images to the destination DICOM file using DICOM encoder
images.SaveSync(destFilePath, encoder)
End Using
Finally
' remove images
images.ClearAndDisposeItems()
End Try
End Using
End Sub
/// <summary>
/// Loads DICOM images from DICOM file, burns the overlay images on DICOM images and saves changed DICOM images to a new DICOM file.
/// </summary>
/// <param name="sourceFilePath">A path to a source DICOM file.</param>
/// <param name="destFilePath">A path to the destination DICOM file.</param>
public static void BurnOverlayImagesAndSaveToDicomFile(string sourceFilePath, string destFilePath)
{
// create image collection
using (Vintasoft.Imaging.ImageCollection images = new Vintasoft.Imaging.ImageCollection())
{
// open DICOM file
images.Add(sourceFilePath);
try
{
// create DICOM decoding settings
Vintasoft.Imaging.Codecs.Decoders.DicomDecodingSettings decodingSettings = new Vintasoft.Imaging.Codecs.Decoders.DicomDecodingSettings();
// specify that DICOM decoder needs to draw overlay images on DICOM image
decodingSettings.ShowOverlayImages = true;
// set the DICOM decoding settings for all images in image collection
images.SetDecodingSettings(decodingSettings);
// for each image in image collection
foreach (Vintasoft.Imaging.VintasoftImage image in images)
{
// convert image to BGR24-image
image.ConvertToBgr24();
}
// create DICOM encoder
using (Vintasoft.Imaging.Codecs.Encoders.DicomEncoder encoder = new Vintasoft.Imaging.Codecs.Encoders.DicomEncoder())
{
// save images to the destination DICOM file using DICOM encoder
images.SaveSync(destFilePath, encoder);
}
}
finally
{
// remove images
images.ClearAndDisposeItems();
}
}
}
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5