'\" t .\" Title: gdcmimg .\" Author: Mathieu Malaterre .\" Generator: DocBook XSL Stylesheets v1.79.2 .\" Date: 07/31/2021 .\" Manual: DICOM Manipulation. .\" Source: GDCM 3.0.8 .\" Language: English .\" .TH "GDCMIMG" "1" "07/31/2021" "GDCM 3\&.0\&.8" "DICOM Manipulation\&." .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" gdcmimg \- Manipulate DICOM image file\&. .PP gdcmimg is a low level tool to allow de\-/encapsulation from/to DICOM image\&. This tool does not understand Transfer Syntax conversion\&. It will encapsulate the raw data as\-is\&. This has some impact in some cases, see special warnings below\&. .PP It is important to note that gdcmimg can only encapsulate proper input file, for instance JPG and or JP2 are accepted since an associated DICOM Transfer Syntax can be found\&. However input such as TIFF and/or PNG are not, since DICOM does not support those\&. See instead a tool such as gdcm2vtk\&. .SH "SYNOPSIS" .PP .if n \{\ .RS 4 .\} .nf gdcmimg [options] file\-in file\-out .fi .if n \{\ .RE .\} .SH "DESCRIPTION" .PP The \fBgdcmimg\fR command line tool can be used in two fashions: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 1\&. Converting a recognized file format into its encapsulated DICOM counterpart, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 2\&. Anonymizing a rectangular portion of a DICOM file\&. .RE .sp .SH "PARAMETERS" .PP .if n \{\ .RS 4 .\} .nf file\-in input filename (non\-DICOM) file\-out DICOM output filename .fi .if n \{\ .RE .\} .SH "OPTIONS" .PP .if n \{\ .RS 4 .\} .nf \-i \-\-input Input filename \-o \-\-output Output filename .fi .if n \{\ .RE .\} .SH "SPECIFIC OPTIONS" .PP .if n \{\ .RS 4 .\} .nf \-\-endian %s Endianness (LSB/MSB)\&. \-d \-\-depth %d Depth (Either 8/16/32 or BitsAllocated eg\&. 12 when known)\&. \-\-sign %s Pixel sign (0/1)\&. \-\-spp %d Sample Per Pixel (1/3)\&. \-s \-\-size %d,%d Size\&. \-C \-\-sop\-class\-uid SOP Class UID (name or value)\&. \-T \-\-study\-uid Study UID\&. \-S \-\-series\-uid Series UID\&. \-\-template Template DICOM file\&. \-\-root\-uid Root UID\&. .fi .if n \{\ .RE .\} .SH "FILL OPTIONS" .PP .if n \{\ .RS 4 .\} .nf \-R \-\-region %d,%d Region\&. \-F \-\-fill %d Fill with pixel value specified\&. .fi .if n \{\ .RE .\} .SH "GENERAL OPTIONS" .PP .if n \{\ .RS 4 .\} .nf \-h \-\-help print this help text and exit \-v \-\-version print version information and exit \-V \-\-verbose verbose mode (warning+error)\&. \-W \-\-warning warning mode, print warning information \-E \-\-error error mode, print error information \-D \-\-debug debug mode, print debug information .fi .if n \{\ .RE .\} .SH "ENVIRONMENT VARIABLE" .PP .if n \{\ .RS 4 .\} .nf GDCM_ROOT_UID Root UID .fi .if n \{\ .RE .\} .SH "SUPPORTED FILE FORMAT (APPROPRIATE FILE EXTENSION)" .PP gdcmimg will base it\*(Aqs conversion process based on the file extension\&. Follows the list of recognized file extension\&. When no extension is found, DICOM file is assumed\&. .PP input format .sp .if n \{\ .RS 4 .\} .nf * RAW (raw, rawl, gray, rgb) * RLE (rle) * PNM (pgm, pnm, ppm) * JPEG\-LS (jls) * JPEG 2000 (jp2, j2k, j2c, jpx, jpc) * JPEG (jpg, jpeg, ljpg, ljpeg) * DICOM () .fi .if n \{\ .RE .\} .PP output format: .sp .if n \{\ .RS 4 .\} .nf * PGM (pgm, pnm, ppm) * DICOM () .fi .if n \{\ .RE .\} .PP For RAW file format, you should take special care of the \(enendian option\&. For the (old) JPEG file format, both the lossy and lossless format are supported, user should pay attention to the \(ensign option\&. For file format such as RLE or RAW, user is expected to fill in information required to find the dimension and type of input data as there is no other way to find this information\&. For all other file format, the properties are derived from the file format itself\&. .PP PNM file are supposed to be big endian (important for depth > 8) .SH "TYPICAL USAGE" .SS "Remove a rectangular part of the image" .PP To fill the region [0,100]x[0,100] of a DICOM image simply do: .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg \-\-fill 0 \-\-region 0,100,0,100 \-i input\&.dcm \-o output_black\&.dcm .fi .if n \{\ .RE .\} .PP Warning: if the Pixel Data is compressed, the image is first decompressed so that pixel can be set to 0, but it is not re\-compressed\&. .SS "Convert RAW to DICOM" .PP Recognized extension is \&.raw, \&.rawl, \&.gray or \&.rgb (case insensitive) .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg \-\-size 512,512 \-\-depth 16 \-i input\&.raw \-o output\&.dcm .fi .if n \{\ .RE .\} .PP the image will be a Secondary Capture\&. .PP When the input is 3 component, one need to specify explicitly the Samples Per Pixel: .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg \-\-size 512,512 \-\-spp 3 input_rgb\&.raw output_rgb\&.dcm .fi .if n \{\ .RE .\} .PP When the filename contains \&.rgb as file extension output is automatically recognized as RGB no need to specify \(enspp .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg \-\-size 512,512 input\&.rgb output_rgb\&.dcm .fi .if n \{\ .RE .\} .PP You can use the \fBdd\fR cmd line to skip any header you would like to discard, for instance, if you would like to skip the first 108 bytes, simply do: .PP .if n \{\ .RS 4 .\} .nf $ dd skip=108 bs=1 if=input\&.raw of=output\&.raw .fi .if n \{\ .RE .\} .PP \&.raw and \&.rawl extension are equivalent\&. You need to explicitly specify the endianness manually: .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg \-\-endian MSB \-\-size 512,512 \-\-depth 16 \-i input\&.raw \-o output\&.dcm .fi .if n \{\ .RE .\} .PP or .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg \-\-endian LSB \-\-size 512,512 \-\-depth 16 \-i input\&.raw \-o output\&.dcm .fi .if n \{\ .RE .\} .SS "Convert PGM/PNM/PPM to DICOM" .PP Recognized extensions are \&.pgm, \&.pnm, \&.ppm (case insensitive) .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg \-i input\&.pgm \-o output\&.dcm .fi .if n \{\ .RE .\} .PP the image will be a Secondary Capture .SS "Convert RLE to DICOM" .PP Recognized extension is \&.rle (case insensitive) .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg \-\-size 512,512 \-\-depth 16 \-i input\&.rle \-o output\&.dcm .fi .if n \{\ .RE .\} .PP the image will be a Secondary Capture .SS "Convert JPEG to DICOM" .PP Recognized extensions are \&.jpg, \&.jpeg, \&.ljpg, \&.ljpeg (case insensitive) .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg \-i input\&.ljpeg \-o output\&.dcm .fi .if n \{\ .RE .\} .PP the image will be a Secondary Capture .SS "Convert J2K to DICOM" .PP Recognized extensions are \&.j2k, \&.jp2, \&.jpc, jpx, j2c (case insensitive) .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg \-i input\&.j2k \-o output\&.dcm .fi .if n \{\ .RE .\} .PP the image will be a Secondary Capture\&. .PP All Pixel information (Bits Stored/Allocated\&.\&.\&.) will be derived from the image itself, and not from the command line options\&. .SS "Specifying a SOP Class UID" .PP Instead of the default Secondary Capture Image Storage, one may want to specify, say VL Photographic Image Storage\&. .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg \-\-sop\-class\-uid 1\&.2\&.840\&.10008\&.5\&.1\&.4\&.1\&.1\&.77\&.1\&.4 input\&.jpg output\&.dcm .fi .if n \{\ .RE .\} .SS "Specifying a template DICOM file" .PP Instead of the default Secondary Capture Image Storage, generated with default values, one may want to specify a DICOM file that will serve as template to fill in the DICOM attributes\&. .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg \-\-sign 1 \-\-template template\&.dcm input\&.jpg output\&.dcm .fi .if n \{\ .RE .\} .PP Pay attention that any values from template\&.dcm that are not consistent with what is found inside the reference image will be overriden (eg\&. image size)\&. On particular case should be of concern: the Pixel Representation for the JPEG family\&. .SH "MULTIPLE FILES" .PP gdcmimg handle nicely a set of files (for instance jpeg): .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg \-C 1\&.2\&.840\&.10008\&.5\&.1\&.4\&.1\&.1\&.12\&.1 1\&.jpg 2\&.jpg 3\&.jpg 4\&.jpg output\&.dcm .fi .if n \{\ .RE .\} .PP It is important to specify an SOP Class that supports multi\-frames images otherwise gdcmimg will fail\&. .SH "START OFFSET" .PP In some case, one may want to create a 2D slice from an arbitrary volume (e\&.g 3D)\&. In which case \(enoffset becomes handy: .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg \-\-offset 4954104330 \-\-size 1673,1673 Input3D_1673_1673_1775\&.raw slice_1770\&.dcm .fi .if n \{\ .RE .\} .SH "WARNING" .PP There are a couple of issues with gdcmimg implementation: .PP For RAW file, one should pay attention that when using \(enendian MSB the Pixel Data will be encapsulated as is (not touched by gdcmimg)\&. Therefore the only possible transfer syntax available is Implicit VR Big Endian DLX (G\&.E Private)\&. GDCM does handle this private Transfer Syntax\&. So if you need to convert this Transfer Syntax to another one (and allow Pixel Data manipulation), you can use: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-raw \-\-force input_big_endian_dlx\&.raw \-o output_implicit_vr_little_endian\&.dcm .fi .if n \{\ .RE .\} .PP For JFIF file and JP2 file (with header) the header is copied into the Pixel Data element which is illegal for JP2\&. Use gdcmconv to properly re\-encode a JP2/JFIF file into J2K/JPG\&. .PP .if n \{\ .RS 4 .\} .nf $ gdcmimg input\&.jp2 output_jp2\&.dcm $ gdcmconv \-\-j2k \-\-force output_jp2\&.dcm output_j2k\&.dcm .fi .if n \{\ .RE .\} .PP For RLE file, no check is done for crossing the row boundary\&. It is recommended to use gdcmconv \(enrle to re\-encode into a proper RLE file in case of doubt\&. .PP Of course if the compression is not ok with your setup, you can always de\-encapsulated the DICOM file (typically JPEG) to a non\-encapsulated form, using gdcmconv: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-raw input_jpeg\&.dcm output_raw\&.dcm .fi .if n \{\ .RE .\} .SH "SEE ALSO" .PP \fBgdcmdump\fR(1), \fBgdcm2vtk\fR(1), \fBgdcmraw\fR(1), \fBconvert\fR(1), \fBdd\fR(1) .SH "AUTHOR" .PP \fBMathieu Malaterre\fR .RS 4 Main developer .RE .SH "COPYRIGHT" .br Copyright \(co 2006, 2011 Mathieu Malaterre .br