Gdcmconv
From gdcm
Contents |
Intro
Tool to convert DICOM to DICOM.
Doxygen
Lossless conversion
When talking about lossless conversion, there is an ambiguity that need to be understood. To achieve higher compression ratio, the RGB color space is usually not used, in favor of a YBR one. Changing from one color space to the other is (bit level) not lossless.
For more detail, see what are the true lossless transformations as described:
Simple usage
gdcmconv is a great tool to convert broken DICOM implementation into properly parsable DICOM file. Usage is simply:
gdcmconv input.dcm output.dcm
Note, in older release one had to explicitely specified what was the input (-i) and what was the output (-o) file, this way (this is not the case anymore since gdcm 2.0.9):
gdcmconv -i input.dcm -o output.dcm
Eventhough gdcmconv can overwrite directly on the same file (input.dcm = output.dcm), it is recommended that user should first convert into a different file to make sure the bug is properly handled by GDCM.
Typical cases where you would want to use gdcmconv in its simple form:
- convert non-cp246 conforming file into conforming cp246,
- convert implicit little endian transfer syntax file meta header into proper explicit little endian transfer syntax,
- convert the GE-13 bytes bug,
- convert dual syntax file: implicit/explicit,
- convert Philips dual Little Endian/Big Endian file,
- convert GDCM 1.2.0 broken UN-2-bytes fields,
- ...
- All other broken files listed in the supported section.
When no option other is used, only the dataset is inspected. So encapsulated Pixel Data, for instance, is not inspected for well known bugs.
When doing this kind of work, this is usually a good idea to perform some kind of quality control, see Gdcmconv/QC.
File Meta Header note
Running
gdcmconv input.dcm output.dcm
Is not enough to recompute file meta header, when input file is buggy. You may want to use: --check-meta
gdcmconv --check-meta input.dcm output.dcm
See typical cases such as: GE_DLX-8-MONO2-PrivateSyntax.dcm or PICKER-16-MONO2-No_DicomV3_Preamble.dcm from gdcmData.
Converting Encapsulated DICOM to RAW
$ gdcmconv --raw compressed.dcm uncompressed.dcm
For example using data from gdcmData:
$ gdcmconv --raw 012345.002.050.dcm out.dcm
Using gdcmdump + the unix diff program, one can check that only very little changes were done:
--- 1 2009-04-30 17:39:28.000000000 +0200 +++ 2 2009-04-30 17:39:35.000000000 +0200 @@ -2,16 +2,17 @@ # Dicom-Meta-Information-Header # Used TransferSyntax: -(0002,0000) UL 178 # 4,1 File Meta Information Group Length +(0002,0000) UL 222 # 4,1 File Meta Information Group Length (0002,0001) OB 00\01 # 2,1 File Meta Information Version (0002,0002) UI [1.2.840.10008.5.1.4.1.1.4] # 26,1 Media Storage SOP Class UID (0002,0003) UI [1.2.840.113619.2.5.1762386977.1328.985934491.693] # 48,1 Media Storage SOP Instance UID -(0002,0010) UI [1.2.840.10008.1.2.4.70] # 22,1 Transfer Syntax UID -(0002,0012) UI [1.2.840.113619.6.44] # 20,1 Implementation Class UID -(0002,0013) SH [R2.7.3r ] # 8,1 Implementation Version Name +(0002,0010) UI [1.2.840.10008.1.2.1] # 20,1 Transfer Syntax UID +(0002,0012) UI [1.2.826.0.1.3680043.2.1143.107.104.103.115.2.1.0] # 48,1 Implementation Class UID +(0002,0013) SH [GDCM 2.1.0] # 10,1 Implementation Version Name +(0002,0016) AE [gdcmconv] # 8,1 Source Application Entity Title # Dicom-Data-Set -# Used TransferSyntax: 1.2.840.10008.1.2.4.70 +# Used TransferSyntax: 1.2.840.10008.1.2.1 (0008,0000) UL 434 # 4,1 Generic Group Length (0008,0005) CS [ISO_IR 100] # 10,1-n Specific Character Set (0008,0008) CS [ORIGINAL\PRIMARY\OTHER] # 22,2-n Image Type @@ -334,7 +335,4 @@ (0043,1062) SH [XXXX] # 4,1 Scanner Study ID (0043,106f) DS [ 0\0.000000\0.000000] # 20,3-4 Scanner Table Entry (single gradient coil systems only)/Scanner Table Entry + Gradient Coil Selected (7fe0,0000) UL 4294967295 # 4,1 Generic Group Length -(7fe0,0010) OB # u/l,1 Pixel Data - (fffe,e000) ?? [] # 0,1 Item - (fffe,e000) ?? ff\d8\ff\c4\00\24\00\00\02\02\03\01\01\01\01\00\01\05\00\00\00\00\00\03\04\02\05\00\01\06\07\08 # 45466,1 Item -(fffe,e0dd) 0 +(7fe0,0010) OW 01\00\00\00\01\00\00\00\00\00\00\00\00\00\01\00\00\00\00\00\01\00\01\00\01\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\00\00 # 131072,1 Pixel Data
Compressing to JPEG
$ gdcmconv --jpeg uncompressed.dcm compressed.dcm
Compressing to JPEG 2000
Compressing to lossless J2K
$ gdcmconv --j2k uncompressed.dcm compressed.dcm
Compressing to lossy J2K
$ gdcmconv --lossy -q 55,50,45 --j2k uncompressed.dcm lossy_compressed.dcm
note:
- -q is just one of the many way to specify lossy quality, you need to inspect the other cmd line flag to specify lossyness properties.
Compressing to RLE
$ gdcmconv --rle uncompressed.dcm compressed.dcm
| |
