Splitting DICOM file in to HEADER and DATA
What is DICOM?
Digital Imaging and Communications in Medicine (DICOM) is a standard for storing, handling, printing, and transmitting information in medical imaging. DICOM internally defines network communications protocol that uses TCP/IP to communicate between systems. DICOM files can be exchanged between two systems that are capable of receiving image and patient data in DICOM format. Proposed by National Electrical Manufacturers Association (NEMA) (www.nema.org)
A DICOM file contains a header and the image data. The header stores information about the patient’s name, the type of scan, position and dimension of image and lots of other data. The image data part contains all the image information.
SPLITTING DICOM Image:
We can split the DICOM image in to header(Demographics) and data(Image) parts using java with the help of dcm4che API.
HEADER PART:
Ø First we have to open the DICOM image for reading using IOStream.
Ø Create a DICOM Object from the stream we opened for reading.
Ø Remove the Pixel Data from the DICOM Object. Now this DICOM Object only containing header information.
Ø Write the DICOM Object in to a separate file.
DATA PART:
Ø First we have to open the DICOM image for reading using streams.
Ø Create a DICOM Object from the stream we opened for reading.
Ø Read only Pixel Data from the DICOM Object and store in DICOM Element and write it in another file using byte array.
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.
Comments
Hi, Maqbool, nice writeup. I’d like to ask how is it possible to extract the data/image from the DICOM device/scanners into a SQL database on a PC?
What I’m trying to achieve is to integrate the patient images from these devices(dicom compliant scanners) into our hospital EHR software.
In order to do this you nees a tool kit. You can look at DCM4CHE which is a Java based tool kit can do waht you are syaing. You can look at Clear Canvas that does tha same thing in .NET environemt.





Why would some one want to do this type of manipulation? Can you provide some example of why we need this?
If I am on a UNIX machine (I am sure can be done on a Windows machine also), I can simple use very simple tools like od and dd to split this instead of going through this lengthy process. Here is how I would do it with these two simple tools…
1. Using “od” do a dump of the image looking for the “7FE0″ tab and note down the byte offset from the beginning.Assume it is byte 1000.
2. Using the ‘dd’ command, just write 1000 bytes so you get the header and in the next run of the dd command, just skip the 1000 bytes.
With this you will get the pixel and header separated out.
I see that you are using dcm4che toolkit to do your work.