LEADTOOLS Medical (Leadtools.Dicom assembly)
LEAD Technologies, Inc

OverlayCount Property

Example 







Gets the number of overlays in the Data Set. .NET support WinRT support Silverlight support
Syntax
public int OverlayCount {get;}
'Declaration
 
Public ReadOnly Property OverlayCount As Integer
'Usage
 
Dim instance As DicomDataSet
Dim value As Integer
 
value = instance.OverlayCount
public int OverlayCount {get;}
ObjectiveC Syntax
Java Syntax
 get_OverlayCount(); 
public:
property int OverlayCount {
   int get();
}

Property Value

The number of overlays in the Data Set.
Remarks
This property gets the number of overlays inside a Data Set by counting the number of repeating groups in the range (6000-601E).
Example
Copy CodeCopy Code  
Public Sub TestOverlay()
      Dim dicomFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Overlay.dcm")
      'Make sure to initialize the DICOM engine, this needs to be done only once 
      'In the whole application
      DicomEngine.Startup()

      Dim ds As DicomDataSet = New DicomDataSet()
      Using (ds)
         'Load DICOM File
         ds.Load(dicomFileName, DicomDataSetLoadFlags.None)

         If ds.OverlayCount > 0 Then
            Dim attributes As RasterOverlayAttributes = ds.GetOverlayAttributes(0)
            If Not attributes Is Nothing Then
               ' We can call in here methods like GetOverlayGroupNumber, IsOverlayInDataset 
               ' and GetOverlayActivationLayer to get some further infromation about the overlay

               'Let's get the overlay Image, If RasterOverlayAttributes.NumFramesInOverlay 
               'Is greater than 1 we can call GetOverlayImages to extract all the frames
               Dim overlayImage As RasterImage = ds.GetOverlayImage(0)
               If Not overlayImage Is Nothing Then

                  Dim ds1 As DicomDataSet = New DicomDataSet()
                  Using (ds1)
                     ds1.Initialize(DicomClassType.DXImageStoragePresentation, DicomDataSetInitializeType.ExplicitVRLittleEndian)
                     ds1.SetOverlayAttributes(0, attributes, DicomSetOverlayFlags.None)
                     ds1.SetOverlayImage(0, overlayImage) 'We can call SetOverlayImages if the overlay has more than one frame
                     ds1.Save(Path.Combine(LEAD_VARS.ImagesDir, "NewOverlay.dcm"), DicomDataSetSaveFlags.None)
                  End Using

               End If
            End If
         End If
      End Using

      DicomEngine.Shutdown()
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void TestOverlay()
   {
      string dicomFileName = Path.Combine(LEAD_VARS.ImagesDir, "Overlay.dcm");
      //Make sure to initialize the DICOM engine, this needs to be done only once 
      //In the whole application
      DicomEngine.Startup();
      using (DicomDataSet ds = new DicomDataSet())
      {
         //Load DICOM File
         ds.Load(dicomFileName, DicomDataSetLoadFlags.None);

         if (ds.OverlayCount > 0)
         {
            RasterOverlayAttributes attributes = ds.GetOverlayAttributes(0);
            if (attributes != null)
            {
               // We can call in here methods like GetOverlayGroupNumber, IsOverlayInDataset 
               // and GetOverlayActivationLayer to get some further infromation about the overlay

               //Let's get the overlay Image, If RasterOverlayAttributes.NumFramesInOverlay 
               //Is greater than 1 we can call GetOverlayImages to extract all the frames
               RasterImage overlayImage = ds.GetOverlayImage(0);
               if (overlayImage != null)
               {
                  using (DicomDataSet ds1 = new DicomDataSet())
                  {
                     ds1.Initialize(DicomClassType.DXImageStoragePresentation, DicomDataSetInitializeType.ExplicitVRLittleEndian);
                     ds1.SetOverlayAttributes(0, attributes, DicomSetOverlayFlags.None);
                     ds1.SetOverlayImage(0, overlayImage);//We can call SetOverlayImages if the overlay has more than one frame
                     ds1.Save(Path.Combine(LEAD_VARS.ImagesDir, "NewOverlay.dcm"), DicomDataSetSaveFlags.None);
                  }
               }
            }
         }
      }
      DicomEngine.Shutdown();
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
[TestMethod]
public async Task TestOverlay()
{
   //Make sure to initialize the DICOM engine, this needs to be done only once 
   //In the whole application
   DicomEngine.Startup();
   using (DicomDataSet ds = new DicomDataSet())
   {
      //Load DICOM File
      string filePath = @"Assets\Overlay.dcm";
      StorageFile file = await Tools.AppInstallFolder.GetFileAsync(filePath);
      ILeadStream stream = LeadStreamFactory.Create(file);
      bool success = await ds.LoadAsync(stream, DicomDataSetLoadFlags.None);
      Debug.Assert(success); 
      if (ds.OverlayCount > 0)
      {
         RasterOverlayAttributes attributes = ds.GetOverlayAttributes(0);
         if (attributes != null)
         {
            // We can call in here methods like GetOverlayGroupNumber, IsOverlayInDataset 
            // and GetOverlayActivationLayer to get some further infromation about the overlay

            //Let's get the overlay Image, If RasterOverlayAttributes.NumFramesInOverlay 
            //Is greater than 1 we can call GetOverlayImages to extract all the frames
            RasterImage overlayImage = ds.GetOverlayImage(0);
            if (overlayImage != null)
            {
               using (DicomDataSet ds1 = new DicomDataSet())
               {
                  ds1.Initialize(DicomClassType.DXImageStoragePresentation, DicomDataSetInitializeType.ExplicitVRLittleEndian);
                  ds1.SetOverlayAttributes(0, attributes, DicomSetOverlayFlags.None);
                  ds1.SetOverlayImage(0, overlayImage);//We can call SetOverlayImages if the overlay has more than one frame

                  string dicomFileNameOutput = "NewOverlay.dcm";
                  StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(dicomFileNameOutput);
                  ILeadStream streamOutput = LeadStreamFactory.Create(saveFile);
                  using (IDisposable disposableOUT = streamOutput as IDisposable)
                  {
                     await ds.SaveAsync(streamOutput, DicomDataSetSaveFlags.None);
                  }
               }
            }
         }
      }
   }
   DicomEngine.Shutdown();
}
public void TestOverlay(Stream dicomStream, Stream outputStream)
{
   //Make sure to initialize the DICOM engine, this needs to be done only once 
   //In the whole application
   DicomEngine.Startup();
   using (DicomDataSet ds = new DicomDataSet())
   {
      //Load DICOM File
      ds.Load(dicomStream, DicomDataSetLoadFlags.None);
      if (ds.OverlayCount > 0)
      {
         RasterOverlayAttributes attributes = ds.GetOverlayAttributes(0);
         if (attributes != null)
         {
            // We can call in here methods like GetOverlayGroupNumber, IsOverlayInDataset 
            // and GetOverlayActivationLayer to get some further infromation about the overlay

            //Let's get the overlay Image, If RasterOverlayAttributes.NumFramesInOverlay 
            //Is greater than 1 we can call GetOverlayImages to extract all the frames
            RasterImage overlayImage = ds.GetOverlayImage(0);
            if (overlayImage != null)
            {
               using (DicomDataSet ds1 = new DicomDataSet())
               {
                  ds1.Initialize(DicomClassType.DXImageStoragePresentation, DicomDataSetInitializeType.ExplicitVRLittleEndian);
                  ds1.SetOverlayAttributes(0, attributes, DicomSetOverlayFlags.None);
                  ds1.SetOverlayImage(0, overlayImage);//We can call SetOverlayImages if the overlay has more than one frame
                  ds1.Save(outputStream, DicomDataSetSaveFlags.None);
               }
            }
         }
      }
   }
   DicomEngine.Shutdown();
}
Public Sub TestOverlay(ByVal dicomStream As Stream, ByVal outputStream As Stream)
   'Make sure to initialize the DICOM engine, this needs to be done only once 
   'In the whole application
   DicomEngine.Startup()
   Using ds As DicomDataSet = New DicomDataSet()
      'Load DICOM File
      ds.Load(dicomStream, DicomDataSetLoadFlags.None)
      If ds.OverlayCount > 0 Then
         Dim attributes As RasterOverlayAttributes = ds.GetOverlayAttributes(0)
         If Not attributes Is Nothing Then
            ' We can call in here methods like GetOverlayGroupNumber, IsOverlayInDataset 
            ' and GetOverlayActivationLayer to get some further infromation about the overlay

            'Let's get the overlay Image, If RasterOverlayAttributes.NumFramesInOverlay 
            'Is greater than 1 we can call GetOverlayImages to extract all the frames
            Dim overlayImage As RasterImage = ds.GetOverlayImage(0)
            If Not overlayImage Is Nothing Then
               Using ds1 As DicomDataSet = New DicomDataSet()
                  ds1.Initialize(DicomClassType.DXImageStoragePresentation, DicomDataSetInitializeType.ExplicitVRLittleEndian)
                  ds1.SetOverlayAttributes(0, attributes, DicomSetOverlayFlags.None)
                  ds1.SetOverlayImage(0, overlayImage) 'We can call SetOverlayImages if the overlay has more than one frame
                  ds1.Save(outputStream, DicomDataSetSaveFlags.None)
               End Using
            End If
         End If
      End If
   End Using
   DicomEngine.Shutdown()
End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

DicomDataSet Class
DicomDataSet Members
GetOverlayAttributes Method
GetOverlayActivationLayer Method
GetOverlayImage Method
GetOverlayImages(Int32,Int32,Int32) Method
SetOverlayAttributes Method
SetOverlayImage Method
SetOverlayImages Method
DeleteOverlay Method

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Dicom requires a Medical toolkit server license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features