Number of Overlays in Image

How overlay data is stored

There are two ways of storing overlays in DICOM Image:

  • Overlay data stored in unused bit planes of the Pixel Data (7FE0,0010) with Samples Per Pixel (0028,0002) of 1. This usage has now retired.
  • Overlay data stored in separate "Overlay pixel data" attribute (60xx,3000).

Repeating Groups

Multiple overlay planes are represented by standard data elements with even group numbers (ranging from 6000H to 601EH). In the range of the group numbers, standard data elements that have identical element numbers have the same meaning (and the same VR, VM and Data Element Type). The notation (60xx, eeee) is used for the group number in data element tags when referring to a common data element across the group, which is called Repeating Groups because of these characteristics.

The maximum number of overlays in one Image is 16 ((601E - 6000)/ 2 + 1).

How many overlays

As there are two ways of storing overlay data in DicomImage, the best way to decide the number of overlays in Image is to count the number of none-empty repeating groups, as each represents one overlay in the Image. And to count the none-empty repeating groups, you can check the existence of one or more type 1 attribute values in the Group, except the Overlay Data (60xx, 3000). Below is the list of type 1 overlay module attributes defined in the DICOM standard:

Attribute Name Tag
Overlay Rows (60xx, 0010)
Overlay Columns (60xx, 0011)
Overlay Type (60xx, 0040)
Overlay Origin (60xx, 0050)
Overlay Bits Allocated (60xx, 0100)
Overlay Bit Position (60xx, 0102)
Overlay Data (60xx, 3000)

In the following sample code, we use "Overlay Bits Allocated" to count the number of overlays in Image.

DicomObjects.NET:
 
Dim i As Integer
Dim NumberOfOverLays As Integer = 0
For i = 0 To 15
  If DicomImage.DataSet(&H6000 + i * 2, &H0100).Exists And Not DicomViewer1.CurrentImage.DataSet(&H6000 + i * 2, &H0100).IsNull Then
       NumberOfOverLays = NumberOfOverLays + 1
  End If
Next

DicomObjects.COM:
 
Dim i As Integer
Dim NumberOfOverLays As Integer = 0
For i = 0 To 15
  If DicomImage.Attributes(&H6000 + i * 2, &H0100).Exists And DicomViewer1.CurrentImage.Attributes(&H6000 + i * 2, &H0100).Value <> ""Then
       NumberOfOverLays = NumberOfOverLays + 1
  End If
Next