DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomImage3D Class / SetTransferFunction Method / SetTransferFunction(IEnumerable<KeyValuePair<Int32,Color>>) Method
The list of pixel values and associated colours
Example

In This Topic
    SetTransferFunction(IEnumerable<KeyValuePair<Int32,Color>>) Method
    In This Topic
    Set the transfer function for VR from a dictionary of pixel value to Colour lookups
    Syntax
    'Declaration
     
    
    Public Overloads Sub SetTransferFunction( _
       ByVal ColourList As System.Collections.Generic.IEnumerable(Of KeyValuePair(Of Integer,Color)) _
    ) 
    public void SetTransferFunction( 
       System.Collections.Generic.IEnumerable<KeyValuePair<int,Color>> ColourList
    )

    Parameters

    ColourList
    The list of pixel values and associated colours
    Remarks

    DicomObjects will interpolate between adjacent values, and create a linearised lookup table, which is then passed (alongside the minimum and maximum pixel values to the other override of SetTransferFunction. This method is therefore a "convenience" method to simplify such updates.

    Example
    DicomImage image = new DicomImage("your_3D_dicom_image.dcm");
    DicomVolume volume = new DicomVolume(image);
                        
    RenderMode3D renderMode = RenderMode3D.VR;
    DicomImage3D image3D = new DicomImage3D(volume, renderMode);
                   
    Dictionary<int, Color> transferFunction = new Dictionary<int, Color>
    {
         { 0, Color.Black },        // Lowest intensity → Black (fully transparent)
         { 50, Color.DarkBlue },    // Low intensity → Dark Blue
         { 100, Color.Blue },       // Mid intensity → Blue
         { 150, Color.Green },      // High-mid intensity → Green
         { 200, Color.Yellow },     // High intensity → Yellow
         { 255, Color.Red }         // Highest intensity → Red (Opaque)
    };     
                
    image3D.SetTransferFunction(transferFunction);
    Viewer.Images.Add(image3D);
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also