0
votes

I am NOT looking for a pre-existing library to read DICOM files. I am looking for some sample code that reads a DICOM file and parses it. No bells and whistles. I need to write the code from scratch. I understand that there are many awesome libraries available, but I need to read the DICOM file manually using old-fashioned C or C++ file read methods. Don't waste your time suggesting libraries. Nothing against libraries! I just need to do this manually.

Specifically, I need to know how to access the values from a DICOM file (most importantly: the pixel values). It would help to know the data types, sizes, and formatting (which I know can vary a lot in DICOM).

Thanks! -j

1
Search the web for "DICOM file format". You could also search the web for "DICOM file specification".Thomas Matthews
Reading a DICOM file is the easy part, interpreting the DataSet is the hard part, hence the multiples suggestions to re-use an existing library.malat
Is there a specific, limited set of compression and pixels formats that you want to support instead of trying to support the whole standard? Do you have a representative sample image? I've written my own DICOM viewer and I support much of the standard; it's not a trivial task.BitBank
Hi BitBank: I could potentially hire someone to do this. Let me know.user4586083

1 Answers

3
votes

My inclination is to say "don't do this" but you've indicated that you have your own reasons for wanting to write your own parser - who am I to argue! The "data types,sizes and formatting" of a DICOM file is described in Part 5 (Data Structures and Encoding) and Part 6 (Data Dictionary) of the DICOM Standard. Both Parts are freely available online in a variety of formats at http://www.dclunie.com/dicom-status/status.html#BaseStandard2015a.

The image's pixel data is stored in the attribute with tag (7fe0,0010). The pixel data will be a string of bytes if the image is not compressed. Otherwise the Pixel Data attribute will be a Sequence attribute, and the second sequence item will contain the encapsulated compressed pixel data.

EDIT: there is also some helpful high level information in this answer to a similar question ... https://stackoverflow.com/a/213987/1220389

EDIT 2: The "2014b" release of the DICOM Standard included support for the "Parametric Map Storage IOD". A "Parametric Map" object is a derived image, much like an acquired image object that we're familiar with, but that the pixel values of a Parametric Map have intrinsic quantitative meaning. As part of the changes introduced to support Parametric Maps the DICOM Standard has introduced the Floating Point Image Pixel module and the Double Floating Point Image Pixel module which include the Float Pixel Data (7fe0,0008) and the Double Float Pixel Data (7fe0,0009) attributes, respectively. That is, the pixel data of an image may now be conveyed in the usual Pixel Data (7fe0,0010) attribute for acquired and most derived images, or in Float Pixel Data (7fe0,0008) or Double Float Pixel Data (7fe0,0009) for Parametric Maps. More information on the changes introduced into the DICOM Standard to support the Parametric Maps Storage IOD are available in Supp 172 Parametric Map Storage.