DICOM (Digital Imaging and Communication in Medicine) is probably the most common standard used for storage and exchange of Medical Images. This article provides a basic introduction on reading a Dicom File using C#.
The basic unit of a Dicom file is called an Element. Dicom Elements consists of 4 components
2. Value Representation
3. Value Length
4. Value Field
Tag uniquely identifies each element in the file. It consists of 2 short numbers representing the group and element.
Value Representation is an optional field, which defines the datatype of the element. For example,
UI – Unique Identifier
CS – Custom String
OS – Other Byte
US – Unsigned Short
This even sized field would contain the length of the field. This field would always be even sized.
Value Field as expected, would contain the actual value.
Reading a Dicom Element is pretty easy in C#. For this example, am using Fellow Oak Dicom Library for .Net.
Following lines of code would read the patient name out of a Dicom File using the Fellow Oak Library
Dicom. DicomFile obj = Dicom.DicomFile .Open(FilePath); var PatientName = obj.Dataset.Get( DicomTag.PatientName, null );
The Fellow Oak Library provides a simple interface to read all Dicom Elements.
More on Dicom in next post.