VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.ImageProcessing Namespace / GetDefaultVoiLutCommand Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    GetDefaultVoiLutCommand Class
    In This Topic
    Calculates the default VOI LUT from a DICOM image.
    Object Model
    DicomImageVoiLookupTable ProcessingCommandResults GetDefaultVoiLutCommand
    Syntax
    'Declaration
    
    Public Class GetDefaultVoiLutCommand
       Inherits ProcessingCommandBase
    
    
    public class GetDefaultVoiLutCommand : ProcessingCommandBase
    
    
    public __gc class GetDefaultVoiLutCommand : public ProcessingCommandBase*
    
    
    public ref class GetDefaultVoiLutCommand : public ProcessingCommandBase^
    
    
    Example

    This C#/VB.NET code shows how to get raw DICOM image, calculate VOI LUT with specified mode, apply calculated VOI LUT to the DICOM image and save DICOM image to an image file.

    
    ''' <summary>
    ''' Gets raw DICOM image, calculates VOI LUT with specified mode,
    ''' applies calculated VOI LUT to the DICOM image,
    ''' saves DICOM image to an image file.
    ''' </summary>
    ''' <param name="dicomFilePath">Path to a DICOM file.</param>
    ''' <param name="dicomVoiLutSearchMode">The DICOM VOI LUT search mode.</param>
    Public Shared Sub ConvertDicomFrameToJpegFile(dicomFilePath As String, dicomVoiLutSearchMode As Vintasoft.Imaging.ImageProcessing.VoiLutSearchMode)
        ' open DICOM file
        Using dicomFile As New Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFile(dicomFilePath)
            ' if DICM file does not have frames
            If dicomFile.Pages.Count = 0 Then
                ' exit
                Return
            End If
    
    
            ' get raw DICOM image
    
            ' create settings for decoding DICOM image
            Dim decodingSettings As New Vintasoft.Imaging.Codecs.Decoders.DicomDecodingSettings()
            ' specify that pixel format of DICOM image should not be changed
            decodingSettings.OutputPixelFormat = Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomImagePixelFormat.Source
            ' 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 image of first DICOM frame
            Using rawImage As Vintasoft.Imaging.VintasoftImage = dicomFile.Pages(0).GetImage(decodingSettings, Nothing)
                ' calculate VOI LUT for raw DICOM image
    
                Dim getDefaultVoiLutCommand As New Vintasoft.Imaging.ImageProcessing.GetDefaultVoiLutCommand()
                getDefaultVoiLutCommand.VoiLutSearchMode = dicomVoiLutSearchMode
                getDefaultVoiLutCommand.ExecuteInPlace(rawImage)
    
    
                ' apply VOI LUT to the DICOM image
    
                Dim applyVoiLutCommand As New Vintasoft.Imaging.ImageProcessing.ApplyDicomImageVoiLutCommand()
                applyVoiLutCommand.VoiLut = getDefaultVoiLutCommand.ResultVoiLut
                applyVoiLutCommand.ExecuteInPlace(rawImage)
    
    
                ' save DICOM image to JPEG file
                rawImage.Save("result.jpg")
            End Using
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Gets raw DICOM image, calculates VOI LUT with specified mode,
    /// applies calculated VOI LUT to the DICOM image,
    /// saves DICOM image to an image file.
    /// </summary>
    /// <param name="dicomFilePath">Path to a DICOM file.</param>
    /// <param name="dicomVoiLutSearchMode">The DICOM VOI LUT search mode.</param>
    public static void ConvertDicomFrameToJpegFile(
        string dicomFilePath,
        Vintasoft.Imaging.ImageProcessing.VoiLutSearchMode dicomVoiLutSearchMode)
    {
        // open DICOM file
        using (Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFile dicomFile =
            new Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFile(dicomFilePath))
        {
            // if DICM file does not have frames
            if (dicomFile.Pages.Count == 0)
                // exit
                return;
    
    
            // get raw DICOM image
    
            // create settings for decoding DICOM image
            Vintasoft.Imaging.Codecs.Decoders.DicomDecodingSettings decodingSettings =
                new Vintasoft.Imaging.Codecs.Decoders.DicomDecodingSettings();
            // specify that pixel format of DICOM image should not be changed
            decodingSettings.OutputPixelFormat = Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomImagePixelFormat.Source;
            // 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 image of first DICOM frame
            using (Vintasoft.Imaging.VintasoftImage rawImage = dicomFile.Pages[0].GetImage(decodingSettings, null))
            {
                // calculate VOI LUT for raw DICOM image
    
                Vintasoft.Imaging.ImageProcessing.GetDefaultVoiLutCommand getDefaultVoiLutCommand =
                    new Vintasoft.Imaging.ImageProcessing.GetDefaultVoiLutCommand();
                getDefaultVoiLutCommand.VoiLutSearchMode = dicomVoiLutSearchMode;
                getDefaultVoiLutCommand.ExecuteInPlace(rawImage);
    
    
                // apply VOI LUT to the DICOM image
    
                Vintasoft.Imaging.ImageProcessing.ApplyDicomImageVoiLutCommand applyVoiLutCommand =
                    new Vintasoft.Imaging.ImageProcessing.ApplyDicomImageVoiLutCommand();
                applyVoiLutCommand.VoiLut = getDefaultVoiLutCommand.ResultVoiLut;
                applyVoiLutCommand.ExecuteInPlace(rawImage);
    
    
                // save DICOM image to JPEG file
                rawImage.Save("result.jpg");
            }
        }
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
          Vintasoft.Imaging.ImageProcessing.GetDefaultVoiLutCommand

    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