1GDCMIMG(1) DICOM Manipulation. GDCMIMG(1)
2
3
4
6 gdcmimg - Manipulate DICOM image file.
7
8 gdcmimg is a low level tool to allow de-/encapsulation from/to DICOM
9 image. This tool does not understand Transfer Syntax conversion. It
10 will encapsulate the raw data as-is. This has some impact in some
11 cases, see special warnings below.
12
13 It is important to note that gdcmimg can only encapsulate proper input
14 file, for instance JPG and or JP2 are accepted since an associated
15 DICOM Transfer Syntax can be found. However input such as TIFF and/or
16 PNG are not, since DICOM does not support those. See instead a tool
17 such as gdcm2vtk.
18
20 gdcmimg [options] file-in file-out
21
23 The gdcmimg command line tool can be used in two fashions:
24
25 · 1. Converting a recognized file format into its encapsulated DICOM
26 counterpart,
27
28 · 2. Anonymizing a rectangular portion of a DICOM file.
29
30
32 file-in input filename (non-DICOM)
33
34 file-out DICOM output filename
35
37 -i --input Input filename
38 -o --output Output filename
39
41 --endian %s Endianness (LSB/MSB).
42 -d --depth %d Depth (Either 8/16/32 or BitsAllocated eg. 12 when known).
43 --sign %s Pixel sign (0/1).
44 --spp %d Sample Per Pixel (1/3).
45 -s --size %d,%d Size.
46 -C --sop-class-uid SOP Class UID (name or value).
47 -T --study-uid Study UID.
48 -S --series-uid Series UID.
49 --template Template DICOM file.
50 --root-uid Root UID.
51
53 -R --region %d,%d Region.
54 -F --fill %d Fill with pixel value specified.
55
57 -h --help
58 print this help text and exit
59
60 -v --version
61 print version information and exit
62
63 -V --verbose
64 verbose mode (warning+error).
65
66 -W --warning
67 warning mode, print warning information
68
69 -E --error
70 error mode, print error information
71
72 -D --debug
73 debug mode, print debug information
74
76 GDCM_ROOT_UID Root UID
77
79 gdcmimg will base it's conversion process based on the file extension.
80 Follows the list of recognized file extension. When no extension is
81 found, DICOM file is assumed.
82
83 input format
84
85 * RAW (raw, rawl, gray, rgb)
86 * RLE (rle)
87 * PNM (pgm, pnm, ppm)
88 * JPEG-LS (jls)
89 * JPEG 2000 (jp2, j2k, j2c, jpx, jpc)
90 * JPEG (jpg, jpeg, ljpg, ljpeg)
91 * DICOM ()
92
93 output format:
94
95 * PGM (pgm, pnm, ppm)
96 * DICOM ()
97
98 For RAW file format, you should take special care of the –endian
99 option. For the (old) JPEG file format, both the lossy and lossless
100 format are supported, user should pay attention to the –sign option.
101 For file format such as RLE or RAW, user is expected to fill in
102 information required to find the dimension and type of input data as
103 there is no other way to find this information. For all other file
104 format, the properties are derived from the file format itself.
105
106 PNM file are supposed to be big endian (important for depth > 8)
107
109 Remove a rectangular part of the image
110 To fill the region [0,100]x[0,100] of a DICOM image simply do:
111
112 $ gdcmimg --fill 0 --region 0,100,0,100 -i input.dcm -o output_black.dcm
113
114 Warning: if the Pixel Data is compressed, the image is first
115 decompressed so that pixel can be set to 0, but it is not
116 re-compressed.
117
118 Convert RAW to DICOM
119 Recognized extension is .raw, .rawl, .gray or .rgb (case insensitive)
120
121 $ gdcmimg --size 512,512 --depth 16 -i input.raw -o output.dcm
122
123 the image will be a Secondary Capture.
124
125 When the input is 3 component, one need to specify explicitly the
126 Samples Per Pixel:
127
128 $ gdcmimg --size 512,512 --spp 3 input_rgb.raw output_rgb.dcm
129
130 When the filename contains .rgb as file extension output is
131 automatically recognized as RGB no need to specify –spp
132
133 $ gdcmimg --size 512,512 input.rgb output_rgb.dcm
134
135 You can use the dd cmd line to skip any header you would like to
136 discard, for instance, if you would like to skip the first 108 bytes,
137 simply do:
138
139 $ dd skip=108 bs=1 if=input.raw of=output.raw
140
141 .raw and .rawl extension are equivalent. You need to explicitly specify
142 the endianness manually:
143
144 $ gdcmimg --endian MSB --size 512,512 --depth 16 -i input.raw -o output.dcm
145
146 or
147
148 $ gdcmimg --endian LSB --size 512,512 --depth 16 -i input.raw -o output.dcm
149
150 Convert PGM/PNM/PPM to DICOM
151 Recognized extensions are .pgm, .pnm, .ppm (case insensitive)
152
153 $ gdcmimg -i input.pgm -o output.dcm
154
155 the image will be a Secondary Capture
156
157 Convert RLE to DICOM
158 Recognized extension is .rle (case insensitive)
159
160 $ gdcmimg --size 512,512 --depth 16 -i input.rle -o output.dcm
161
162 the image will be a Secondary Capture
163
164 Convert JPEG to DICOM
165 Recognized extensions are .jpg, .jpeg, .ljpg, .ljpeg (case insensitive)
166
167 $ gdcmimg -i input.ljpeg -o output.dcm
168
169 the image will be a Secondary Capture
170
171 Convert J2K to DICOM
172 Recognized extensions are .j2k, .jp2, .jpc, jpx, j2c (case insensitive)
173
174 $ gdcmimg -i input.j2k -o output.dcm
175
176 the image will be a Secondary Capture.
177
178 All Pixel information (Bits Stored/Allocated...) will be derived from
179 the image itself, and not from the command line options.
180
181 Specifying a SOP Class UID
182 Instead of the default Secondary Capture Image Storage, one may want to
183 specify, say VL Photographic Image Storage.
184
185 $ gdcmimg --sop-class-uid 1.2.840.10008.5.1.4.1.1.77.1.4 input.jpg output.dcm
186
187 Specifying a template DICOM file
188 Instead of the default Secondary Capture Image Storage, generated with
189 default values, one may want to specify a DICOM file that will serve as
190 template to fill in the DICOM attributes.
191
192 $ gdcmimg --sign 1 --template template.dcm input.jpg output.dcm
193
194 Pay attention that any values from template.dcm that are not consistent
195 with what is found inside the reference image will be overriden (eg.
196 image size). On particular case should be of concern: the Pixel
197 Representation for the JPEG family.
198
200 gdcmimg handle nicely a set of files (for instance jpeg):
201
202 $ gdcmimg -C 1.2.840.10008.5.1.4.1.1.12.1 1.jpg 2.jpg 3.jpg 4.jpg output.dcm
203
204 It is important to specify an SOP Class that supports multi-frames
205 images otherwise gdcmimg will fail.
206
208 In some case, one may want to create a 2D slice from an arbitrary
209 volume (e.g 3D). In which case –offset becomes handy:
210
211 $ gdcmimg --offset 4954104330 --size 1673,1673 Input3D_1673_1673_1775.raw slice_1770.dcm
212
214 There are a couple of issues with gdcmimg implementation:
215
216 For RAW file, one should pay attention that when using –endian MSB the
217 Pixel Data will be encapsulated as is (not touched by gdcmimg).
218 Therefore the only possible transfer syntax available is Implicit VR
219 Big Endian DLX (G.E Private). GDCM does handle this private Transfer
220 Syntax. So if you need to convert this Transfer Syntax to another one
221 (and allow Pixel Data manipulation), you can use:
222
223 $ gdcmconv --raw --force input_big_endian_dlx.raw -o output_implicit_vr_little_endian.dcm
224
225 For JFIF file and JP2 file (with header) the header is copied into the
226 Pixel Data element which is illegal for JP2. Use gdcmconv to properly
227 re-encode a JP2/JFIF file into J2K/JPG.
228
229 $ gdcmimg input.jp2 output_jp2.dcm
230 $ gdcmconv --j2k --force output_jp2.dcm output_j2k.dcm
231
232 For RLE file, no check is done for crossing the row boundary. It is
233 recommended to use gdcmconv –rle to re-encode into a proper RLE file in
234 case of doubt.
235
236 Of course if the compression is not ok with your setup, you can always
237 de-encapsulated the DICOM file (typically JPEG) to a non-encapsulated
238 form, using gdcmconv:
239
240 $ gdcmconv --raw input_jpeg.dcm output_raw.dcm
241
243 gdcmdump(1), gdcm2vtk(1), gdcmraw(1), convert(1), dd(1)
244
246 Mathieu Malaterre
247 Main developer
248
250 Copyright © 2006, 2011 Mathieu Malaterre
251
252
253
254GDCM 2.8.9 11/23/2019 GDCMIMG(1)