I want to write a script to extract the PixelDATA of a DICOM file using c or c ++, I don't want to use external libraries like dicomsdl... if anyone can help me to write algorithm for extract and show image .
-
why wouldn't you want to use an external library? – m.s. Apr 22 '15 at 09:39
-
it 's the supervisor who imposed this – Marouane Apr 22 '15 at 09:44
-
I guess the supervisor doesn't believe that "time is money". – PaulMcKenzie Apr 22 '15 at 09:46
-
1I don't know the file format, but judging from http://gdcm.sourceforge.net/wiki/index.php/Main_Page I guess it will be quite a big effort to reimplement all the functionality ... – m.s. Apr 22 '15 at 09:50
1 Answers
Just extracting the image data under the pixel data is not enough to interpret the DICOM image properly. You will need other attributes from DICOM file such as Rows
, Columns
, Bit Allocated
, Bit Stored
, High Bit
, Photometric Interpretation
, Sample Per Pixel
to Number of Frames
information just to interpret the raw uncompressed image data. Also, stored image data can be in Little Endian
or Big Endian
byte order. In addition, image data can be encapsulated or compressed (e.g. compressed using different compression algorithms such as JPEG
, JPEG 2000
, JPEG LS
, RLE
etc)) and compressed streams are stored differently than the uncompressed image data. Even the PixelData element can exist in multiple locations in a single DICOM file (e.g. one under the Icon Image Sequence (thumbnail) and one at the top level (actual image).
It can get more complicated when you need to account for Palette Color
(segmented vs un-segmented), modality LUT
, VOI LUT
etc. My recommendation is to use an existing DICOM SDK and there are many open source and commercial SDK available for different platforms and programming environments.

- 12,152
- 13
- 89
- 158

- 2,755
- 1
- 12
- 12