VintaSoft Imaging .NET SDK 12.3: Documentation for .NET developer
Vintasoft.Imaging.ImageProcessing Namespace / ApplyDicomOverlaysCommand Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    ApplyDicomOverlaysCommand Class
    In This Topic
    Applies the overlays to a DICOM image.
    Object Model
    DicomOverlayImage Rgb24Color ProcessingCommandResults ApplyDicomOverlaysCommand
    Syntax
    'Declaration
    
    Public Class ApplyDicomOverlaysCommand
       Inherits ProcessingCommandBase
    
    
    public class ApplyDicomOverlaysCommand : ProcessingCommandBase
    
    
    public __gc class ApplyDicomOverlaysCommand : public ProcessingCommandBase*
    
    
    public ref class ApplyDicomOverlaysCommand : public ProcessingCommandBase^
    
    
    Example

    This C#/VB.NET code shows how to get raw DICOM image, apply VOI LUT to DICOM image, add overlays to DICOM image and save DICOM image as PNG file.

    
    ''' <summary>
    ''' Gets raw DICOM image, applies a VOI LUT to the DICOM image,
    ''' draws the overlay objects to the DICOM image, saves DICOM image to a PNG file.
    ''' </summary>
    ''' <param name="filePath">Path to DICOM file.</param>
    ''' <param name="pageIndex">Index of DICOM page.</param>
    Public Sub GetAndSaveDicomImageWithOverlaysAndAdjustImageWindow(filePath As String, pageIndex As Integer)
        ' open DICOM file
        Using dicomFile As New Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFile(filePath)
            ' get DICOM page
            Dim page As Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFrame = dicomFile.Pages(pageIndex)
    
    
            ' get raw DICOM image
    
            ' create settings for decoding DICOM image
            Dim decodingSettings As New Vintasoft.Imaging.Codecs.Decoders.DicomDecodingSettings()
            ' specify that Modality LUT should not be applied to a DICOM image
            decodingSettings.ApplyModalityLut = False
            ' specify that VOI LUT should not be applied to a DICOM image
            decodingSettings.ApplyValueOfInterestLut = False
            ' specify that overlay objects should not be drawn on DICOM image
            decodingSettings.ShowOverlayImages = False
            ' get raw DICOM image
            Using image As Vintasoft.Imaging.VintasoftImage = page.GetImage(decodingSettings, Nothing)
    
    
                ' apply VOI LUT to the DICOM image
    
                Dim applyDicomImageVoiLutCommand As New Vintasoft.Imaging.ImageProcessing.ApplyDicomImageVoiLutCommand()
                applyDicomImageVoiLutCommand.VoiLut = New Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomImageVoiLookupTable(128, 50)
                applyDicomImageVoiLutCommand.ExecuteInPlace(image)
    
    
                ' draw overlay objects on DICOM image
    
                Dim applyDicomOverlaysCommand As New Vintasoft.Imaging.ImageProcessing.ApplyDicomOverlaysCommand()
                applyDicomOverlaysCommand.OverlayImages = page.OverlayImages
                applyDicomOverlaysCommand.OverlayColor = New Vintasoft.Imaging.ImageColors.Rgb24Color(180, 180, 180)
                applyDicomOverlaysCommand.ExecuteInPlace(image)
    
    
                ' save image to a PNG file
                image.Save("E:\DicomImage.png")
            End Using
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Gets raw DICOM image, applies a VOI LUT to the DICOM image,
    /// draws the overlay objects to the DICOM image, saves DICOM image to a PNG file.
    /// </summary>
    /// <param name="filePath">Path to DICOM file.</param>
    /// <param name="pageIndex">Index of DICOM page.</param>
    public void GetAndSaveDicomImageWithOverlaysAndAdjustImageWindow(string filePath, int pageIndex)
    {
        // open DICOM file
        using (Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFile dicomFile =
            new Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFile(filePath))
        {
            // get DICOM page
            Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFrame page = dicomFile.Pages[pageIndex];
    
    
            // get raw DICOM image
    
            // create settings for decoding DICOM image
            Vintasoft.Imaging.Codecs.Decoders.DicomDecodingSettings decodingSettings =
                new Vintasoft.Imaging.Codecs.Decoders.DicomDecodingSettings();
            // specify that Modality LUT should not be applied to a DICOM image
            decodingSettings.ApplyModalityLut = false;
            // specify that VOI LUT should not be applied to a DICOM image
            decodingSettings.ApplyValueOfInterestLut = false;
            // specify that overlay objects should not be drawn on DICOM image
            decodingSettings.ShowOverlayImages = false;
            // get raw DICOM image
            using (Vintasoft.Imaging.VintasoftImage image = page.GetImage(decodingSettings, null))
            {
    
    
                // apply VOI LUT to the DICOM image
    
                Vintasoft.Imaging.ImageProcessing.ApplyDicomImageVoiLutCommand applyDicomImageVoiLutCommand =
                    new Vintasoft.Imaging.ImageProcessing.ApplyDicomImageVoiLutCommand();
                applyDicomImageVoiLutCommand.VoiLut = new Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomImageVoiLookupTable(128, 50);
                applyDicomImageVoiLutCommand.ExecuteInPlace(image);
    
    
                // draw overlay objects on DICOM image
    
                Vintasoft.Imaging.ImageProcessing.ApplyDicomOverlaysCommand applyDicomOverlaysCommand =
                    new Vintasoft.Imaging.ImageProcessing.ApplyDicomOverlaysCommand();
                applyDicomOverlaysCommand.OverlayImages = page.OverlayImages;
                applyDicomOverlaysCommand.OverlayColor = new Vintasoft.Imaging.ImageColors.Rgb24Color(180, 180, 180);
                applyDicomOverlaysCommand.ExecuteInPlace(image);
    
    
                // save image to a PNG file
                image.Save(@"E:\DicomImage.png");
            }
        }
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
          Vintasoft.Imaging.ImageProcessing.ApplyDicomOverlaysCommand

    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also