DICOM Elements
Let’s start with a useful example. Suppose you are a dermatologist and that you use your Smartphone digital camera to record and track patients’ skin condition. You practice a simple procedure that is basically this:1. Take a photo
2. Send it to yourself by email
3. Open the email on your laptop and save the picture in a folder having the patient name.
As programmers, we don’t have to talk much about the flows of this practice but for a small, one doctor clinic, this might just work.
In this lesson, we’ll take the JPEG image and DICOMIZE it. When we DICOMIZE an Image we wrap the image in a DICOM envelope and add important data that is required by the DICOM standard in order to enable all DICOM enabled applications to read and display the image correctly. It’s true that non DICOM application can display the JPEG image just as it is now without DICOMIZING but that’s another story.
We will use RZDCX DICOM Toolkit to convert the image to a DICOM object. Then we’ll ‘dump’ the content of the DICOM object into a text file in order to see how DICOM objects are structured.
To convert to DICOM using RZDCX we’ll use the following three lines of C# code:
private void Convert()
{
DCXOBJ o = new DCXOBJ();
string jpegImage = "my_image.jpg";
o.SetJpegFrames(jpegImage);
}
Now let’s see what we have in the file after that by adding a small dump to text file so our function now looks like this:
private void Convert()
{
DCXOBJ o = new DCXOBJ();
string jpegImage = "my_image.jpg";
o.SetJpegFrames(jpegImage);
o.Dump("my_image.txt");
}
If we now look at the content of the file my_image.txt we'll see this:
# Dicom-Data-Set
# Used TransferSyntax: UnknownTransferSyntax
(0008,0016) UI =SecondaryCaptureImageStorage # 26, 1 SOPClassUID
(0028,0002) US 3 # 2, 1 SamplesPerPixel
(0028,0004) CS [YBR_FULL_422] # 12, 1 PhotometricInterpretation
(0028,0006) US 0 # 2, 1 PlanarConfiguration
(0028,0010) US 96 # 2, 1 Rows
(0028,0011) US 372 # 2, 1 Columns
(0028,0100) US 8 # 2, 1 BitsAllocated
(0028,0101) US 8 # 2, 1 BitsStored
(0028,0102) US 7 # 2, 1 HighBit
(0028,0103) US 0 # 2, 1 PixelRepresentation
(0028,2110) CS [01] # 2, 1 LossyImageCompression
(0028,2114) CS [ISO_10918_1] # 12, 1 LossyImageCompressionMethod
(7fe0,0010) OB (PixelSequence #=2) # u/l, 1 PixelData
(fffe,e000) pi (no value available) # 0, 1 Item
(fffe,e000) pi ff\d8\ff\db\00\43\00\08\06\06\07\06\05\08\07\07\07\09\09\08\0a\0c... # 9624, 1 Item
(fffe,e0dd) na (SequenceDelimitationItem) # 0, 0 SequenceDelimitationItem
Let’s go over this dump and see what’s in it. The lines starting with a hash (#) are comments and we’ll ignore them.
DICOM Elements
A DICOM object is comprised of DICOM elements or DICOM attributes. Every line in the above dump represents one element.Every DICOM Element has a Tag, a Data Type called VR (acronym for Value Representation), Length and Value. In the dump above the lines starts with the tag number (gggg,eeee), then the VR Code, then the value (strings are printed in square brackets) and then a hash sign (#) followed by the element value length, a comma, then Value multiplicity (which we'll talk about later) and the tag name. The tag name and multiplicity are add by the dump method. The way DICOM encodes elements is shown in this drawing taken from the DICOM standard, chapter 5.
![]() |
| Illustration of DICOM element encoding in a DICOM data stream Image takes from the DICOM standard, Chapter 5. |
Tags
Every DICOM element has a Tag that uniquely defines the element and its properties, much like a bar code defines a product in the supermarket. The DICOM tag is comprised of two short numbers called Group and Element. DICOM Tags that are related to one another sometimes have the same group. In our example you can see many elements from group 0028. This is the Image group. These are attributes of the image and are used to describe the image properties. For example (0028,0010) is Rows element and it is the height of the image. (0028,0011) is the Columns and it is the width of the image in pixels. There are more elements of the image group in our example and we’ll describe them in detail when we talk about interpreting and displaying DICOM Images.Value Representation
The VR is represented as two character code. The VR defines the data type of the element. In our example you can see UI for Unique identifier, US for Unsigned Short, CS for Coded String and OB for Other Byte i.e. a byte stream.Because every element has a Tag, the tag implicitly defines the VR. For example the Rows element (Tag 0028,0010) is always US (Unsigned Short). This is why the VR is usually redundant and can be omitted. However, the common practice and IHE recommendation is to explicitly state the VR when serializing DICOM objects into files or into network buffers. We’ll talk more about that when we discuss Implicit and Explicit Transfer Syntax.
Value Length
Because DICOM is a binary protocol (in contrast to textual protocols such as html and xml) elements have length. DICOM elements length are always even. Even if the element’s value is a single character string like Patient Sex (0010,0040) that is either ‘M’ for Male or ‘F’ for Female or ‘O’ for Other, the element length should be 2 and the value will be padded by a space (ASCII 0x20). String types (like CS and UI) are padded by space and binary types like US are padded by null 0x0.
Summary
- DICOM Elements are the building blocks of the DICOM standards. They are used in DICOM files and in network communication.
- Every element has a unique Tag that specifies what’s in the element and its data type.
- DICOM Elements are typed. The DICOM data types are called VR.
- Every Element has even length, even if it's value length is odd. Strings are padded with a space and binary data with a null.
Adding Elements to an Object
We conclude this example with a short code snippet showing how to add elements to a DICOM object using RZDCX.RZDCX takes care for you about the details so you simply create a new element, initialize it with the Tag and set the value. Here's the code:
DCXOBJ o = new DCXOBJ();
DCXELM e = new DCXELM();
// Manufecturer
e.Init((int)DICOM_TAGS_ENUM.Manufacturer);
e.Value = "RZ - Software Services";
o.insertElement(e);
In the next chapter we'll add more data elements to the DICOM object we've created to make it a valid DICOM object and then save it to a file and we'll discuss the differences between DICOM objects and DICOM files.

