How overlay data is stored

There are two ways to store 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:

 int NumberOfOverLays = 0;
 for (int i = 0; i < 16; i++)
 {
	if(image.DataSet[0x6000 + i * 2, 0x100].ExistsWithValue)
	  NumberOfOverLays ++;
 }
 

DicomObjects.COM:

 Dim i As Integer
 Dim NumberOfOverLays As Integer = 0
 For i = 0 To 15
	If Image.Attributes(&H6000 + i * 2, &H100).ExistsWithValue Then
	  NumberOfOverLays = NumberOfOverLays + 1
 End If
 Next

The following code snippet enables overlays in image:

DicomObjects.NET:

 for (int index = 0; index < 16; index++)
 {
	img.OverlayVisible[index] = true;
	img.OverlayColour[index] = Color.Green;
 }

DicomObjects.COM:

 For i = 1 To 16
	img.OverlayVisible(i) = True
	img.OverlayColour(i) = vbYellow
 Next