'\" t .\" Title: gdcmconv .\" Author: Mathieu Malaterre .\" Generator: DocBook XSL Stylesheets v1.79.2 .\" Date: 04/08/2024 .\" Manual: DICOM Manipulation. .\" Source: GDCM 3.0.22 .\" Language: English .\" .TH "GDCMCONV" "1" "04/08/2024" "GDCM 3\&.0\&.22" "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" gdcmconv \- Tool to convert DICOM to DICOM\&. .SH "SYNOPSIS" .PP .if n \{\ .RS 4 .\} .nf gdcmconv [options] file\-in file\-out .fi .if n \{\ .RE .\} .SH "DESCRIPTION" .PP The \fBgdcmconv\fR command line program takes as input a DICOM file (file\-in) and process it to generate an output DICOM file (file\-out)\&. The command line option dictate the type of operation(s) gdcmconv will use to generate the output file\&. .SH "PARAMETERS" .PP .if n \{\ .RS 4 .\} .nf file\-in DICOM input filename file\-out DICOM output filename .fi .if n \{\ .RE .\} .SH "OPTIONS" .PP .if n \{\ .RS 4 .\} .nf \-i \-\-input DICOM filename \-o \-\-output DICOM filename .fi .if n \{\ .RE .\} .SH "SPECIFIC OPTIONS" .PP .if n \{\ .RS 4 .\} .nf \-X \-\-explicit Change Transfer Syntax to explicit\&. \-M \-\-implicit Change Transfer Syntax to implicit\&. \-U \-\-use\-dict Use dict for VR (only public by default)\&. \-\-with\-private\-dict Use private dict for VR (advanced user only)\&. \-C \-\-check\-meta Check File Meta Information (advanced user only)\&. \-\-root\-uid Root UID\&. \-\-remove\-gl Remove group length (deprecated in DICOM 2008)\&. \-\-remove\-private\-tags Remove private tags\&. \-\-remove\-retired Remove retired tags\&. .fi .if n \{\ .RE .\} .SH "IMAGE OPTIONS" .PP .if n \{\ .RS 4 .\} .nf \-l \-\-apply\-lut Apply LUT (non\-standard, advanced user only)\&. \-8 \-\-apply\-lut8 Apply LUT/RGB8 (non\-standard, advanced user only)\&. \-\-decompress\-lut Decompress LUT (linearize segmented LUT)\&. \-P \-\-photometric\-interpretation %s Change Photometric Interpretation (when possible)\&. \-w \-\-raw Decompress image\&. \-d \-\-deflated Compress using deflated (gzip)\&. \-J \-\-jpeg Compress image in jpeg\&. \-K \-\-j2k Compress image in j2k\&. \-L \-\-jpegls Compress image in jpeg\-ls\&. \-R \-\-rle Compress image in rle (lossless only)\&. \-F \-\-force Force decompression/merging before recompression/splitting\&. \-\-generate\-icon Generate icon\&. \-\-icon\-minmax %d,%d Min/Max value for icon\&. \-\-icon\-auto\-minmax Automatically compute best Min/Max values for icon\&. \-\-compress\-icon Decide whether icon follows main TransferSyntax or remains uncompressed\&. \-\-planar\-configuration [01] Change planar configuration\&. \-Y \-\-lossy Use the lossy (if possible) compressor\&. \-S \-\-split %d Write 2D image with multiple fragments (using max size) .fi .if n \{\ .RE .\} .SH "JPEG OPTIONS" .PP .if n \{\ .RS 4 .\} .nf \-q \-\-quality %*f set quality\&. .fi .if n \{\ .RE .\} .SH "JPEG\-LS OPTIONS" .PP .if n \{\ .RS 4 .\} .nf \-e \-\-allowed\-error %*i set allowed error\&. .fi .if n \{\ .RE .\} .SH "J2K OPTIONS" .PP .if n \{\ .RS 4 .\} .nf \-r \-\-rate %*f set rate\&. \-q \-\-quality %*f set quality\&. \-t \-\-tile %d,%d set tile size\&. \-n \-\-number\-resolution %d set number of resolution\&. \-\-irreversible set irreversible\&. .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 "SPECIAL OPTIONS" .PP .if n \{\ .RS 4 .\} .nf \-I \-\-ignore\-errors convert even if file is corrupted (advanced users only, see disclaimers)\&. .fi .if n \{\ .RE .\} .SH "ENVIRONMENT VARIABLE" .PP .if n \{\ .RS 4 .\} .nf GDCM_ROOT_UID Root UID .fi .if n \{\ .RE .\} .SH "SIMPLE USAGE" .PP \fBgdcmconv\fR is a great tool to convert broken DICOM implementation into properly parsable DICOM file\&. Usage is simply: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv input\&.dcm output\&.dcm .fi .if n \{\ .RE .\} .PP or if you prefer being explicit: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-i input\&.dcm \-o output\&.dcm .fi .if n \{\ .RE .\} .PP Even though 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\&. .PP Typical cases where you would want to use gdcmconv in its simple form: .PP .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} convert non\-cp246 conforming file into conforming cp246, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} convert implicit little endian transfer syntax file meta header into proper explicit little endian transfer syntax, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} convert the GE\-13 bytes bug, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} convert dual syntax file: implicit/explicit, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} convert Philips dual Little Endian/Big Endian file, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} convert GDCM 1\&.2\&.0 broken UN\-2\-bytes fields, .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \&.\&.\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} All other broken files listed in the supported refsection\&. .RE .sp When no option other is used, only the dataset is inspected\&. So encapsulated Pixel Data, for instance, is not inspected for well known bugs\&. .PP When doing this kind of work, this is usually a good idea to perform some kind of quality control, see gdcmconv Quality Control refsection (down below)\&. .SH "TYPICAL USAGE" .SS "File Meta Header" .PP Running .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv input\&.dcm output\&.dcm .fi .if n \{\ .RE .\} .PP Is not enough to recompute file meta header, when input file is buggy\&. You may want to use: \(encheck\-meta .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-check\-meta input\&.dcm output\&.dcm .fi .if n \{\ .RE .\} .PP See typical cases such as: GE_DLX\-8\-MONO2\-PrivateSyntax\&.dcm or PICKER\-16\-MONO2\-No_DicomV3_Preamble\&.dcm from gdcmData\&. .SS "Conversion to Explicit Transfer Syntax" .PP To convert a file that was written using Implicit Transfer Syntax into Explicit Transfer Syntax simply use: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-explicit uncompressed\&.dcm compressed\&.dcm .fi .if n \{\ .RE .\} .SS "Compressing to lossless JPEG" .PP To compress an uncompressed DICOM file to a JPEG Lossless encapsulated format: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-jpeg uncompressed\&.dcm compressed\&.dcm .fi .if n \{\ .RE .\} .SS "Compressing to lossy JPEG" .PP To compress an uncompressed DICOM file to a JPEG Lossy encapsulated format: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-lossy \-\-jpeg \-q 90 uncompressed\&.dcm compressed\&.dcm .fi .if n \{\ .RE .\} .PP Note: .sp .if n \{\ .RS 4 .\} .nf \-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\&. .fi .if n \{\ .RE .\} .SS "Compressing to lossless JPEG\-LS" .PP To compress an uncompressed DICOM file to a JPEG\-LS Lossless encapsulated format: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-jpegls uncompressed\&.dcm compressed\&.dcm .fi .if n \{\ .RE .\} .SS "Compressing to lossy JPEG\-LS" .PP To compress an uncompressed DICOM file to a JPEG\-LS Lossy encapsulated format: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-lossy \-\-jpegls \-e 2 uncompressed\&.dcm lossy_compressed\&.dcm .fi .if n \{\ .RE .\} .PP Note: .PP \-e (or \(enlossy\-error) means that the maximum tolerate error is 2 for each pixel value .SS "Compressing to lossless J2K" .PP To compress an uncompressed DICOM file to a JPEG\-2000 Lossless encapsulated format: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-j2k uncompressed\&.dcm compressed\&.dcm .fi .if n \{\ .RE .\} .SS "Compressing to lossy J2K" .PP To compress an uncompressed DICOM file to a JPEG\-2000 Lossy encapsulated format: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-lossy \-q 55,50,45 \-\-j2k uncompressed\&.dcm lossy_compressed\&.dcm .fi .if n \{\ .RE .\} .PP Note: .sp .if n \{\ .RS 4 .\} .nf \-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\&. .fi .if n \{\ .RE .\} .SS "Compressing to lossless RLE" .PP To compress an uncompressed DICOM file to a RLE Lossless encapsulated format: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-rle uncompressed\&.dcm compressed\&.dcm .fi .if n \{\ .RE .\} .PP There is no such thing as lossy RLE compression\&. .SS "Split encapsulated DICOM:" .PP To split an encapsulated stream into smaller chunk (1024 bytes each): .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-split 1024 rle\&.dcm rle_1024\&.dcm .fi .if n \{\ .RE .\} .PP If an odd number of bytes is passed it will be rounded down to the next even number (eg\&. 1025 \-> 1024) since DICOM only allow even number for Value Length\&. .SS "Forcing (re)compression" .PP Sometime it is necessary to use the \(enforce option\&. By default when user specify \(enj2k and input file is already in JPEG 2000 encapsulated DICOM format then no operation takes places\&. By using \(enforce you make sure that (re)compression operation takes places\&. .PP Real life example of why you would use \(enforce: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} When Pixel Data is missing data / is padded with junk .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} When you would like to make sure GDCM can handle decompression & recompression cycle .RE .sp .SS "Decompressing a Compressed DICOM" .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-raw compressed\&.dcm uncompressed\&.dcm .fi .if n \{\ .RE .\} .PP In the case of uncompress file (Explicit and Implicit) the behavior is to keep the original Transfer Syntax (so Implicit remains Implit) .SS "Decompressing a Compressed DICOM as implicit" .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-raw \-\-implicit compressed\&.dcm uncompressed_implicit\&.dcm .fi .if n \{\ .RE .\} .PP By symmetry it is also possible to use gdcmconv \-\-raw \-\-explicit to make sure that target file is always Explicit TS\&. .SS "Compressing an uncompressed Icon" .PP By default when compressing a DICOM Image file, gdcmconv will not compress the icon\&. A user option needs to be turned on to explicitly force the compression of the Icon Image Sequence Pixel Data .PP For example, by default we will not compress the Icon Image Sequence Pixel Data attribute: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-jpeg gdcmData/simpleImageWithIcon\&.dcm uncompressed_icon\&.dcm .fi .if n \{\ .RE .\} .PP In the following example we will explicitly compress the Icon Image Sequence Pixel Data attibute\&. In that case the same Transfer Syntax is being used for both the main Pixel Data and the Pixel Data from the Icon Image Sequence: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-jpeg \-\-compress\-icon gdcmData/simpleImageWithIcon\&.dcm compressed_icon\&.dcm .fi .if n \{\ .RE .\} .SS "Generating an Icon" .PP For some application it might be necessary to produce a small preview of the main image to be able to quickly load that short preview instead of the main image\&. In that case: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-raw \-\-generate\-icon gdcmData/test\&.acr test_icon\&.dcm .fi .if n \{\ .RE .\} .PP In some cases the main Pixel Data element is expressed as pixel defined on 16bits\&. Since Icon can only store at most pixel of size 8bits, a rescale operation needs to take place\&. In order to properly select a better interval for doing the rescale operation user can specify the min max used for the rescale operation: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-raw \-\-generate\-icon \-\-icon\-minmax 0,192 gdcmData/012345\&.002\&.050\&.dcm icon_minmax\&.dcm .fi .if n \{\ .RE .\} .SS "Changing the planar Configuration" .PP Often RLE files are compressed using a different Planar Configuration (RRR \&.\&.\&. GGG\&.\&.\&. BBB\&.\&.\&.) instead of the usual triplet (RGB \&.\&.\&. RGB \&.\&.\&. RGB )\&. So upon decompression the Planar Configuration is 1\&. This is perfectly legal in DICOM, however this is unconventional, and thus it may be a good idea to also change the planar configuration and set it to the default : .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-raw \-\-planar\-configuration 0 compressed\&.dcm uncompressed1\&.dcm .fi .if n \{\ .RE .\} .PP To reinvert the planar configuration of file \*(Aquncompressed1\&.dcm\*(Aq, simply do: .PP .if n \{\ .RS 4 .\} .nf $ gdcmconv \-\-raw \-\-planar\-configuration 1 uncompressed1\&.dcm uncompressed2\&.dcm .fi .if n \{\ .RE .\} .SH "LOSSLESS CONVERSION" .PP 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\&. .PP For more detail, see what are the true lossless transformations as described: .PP \m[blue]\fBhttp://gdcm\&.sourceforge\&.net/wiki/index\&.php/Color_Space_Transformations\fR\m[] .SH "QUALITY CONTROL" .PP One important part when using gdcmconv it to have a way to quality control the output\&. .PP You can use 3rd party tool to check the output of gdcmconv is correct\&. .SS "DCMTK / dicom3tools" .PP Using another DICOM implementation such as the one from DCMTK or dicom3tools can be a good process to check the output of gdcmconv\&. .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} For DCMTK use: dcmdump .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} For dicom3tools use: dcdump .RE .sp For reference, gdcmconv \-\-raw will act as dcmdjpeg +cn +px, since it never tries to convert color space\&. .SS "VIM: vimdiff" .PP You can setup your favorite editor to compare the output, for instance in vim: .PP .if n \{\ .RS 4 .\} .nf autocmd BufReadPre *\&.dcm set ro autocmd BufReadPost *\&.dcm silent %!dcmdump \-M +uc "%" .fi .if n \{\ .RE .\} .PP then simply do: .PP .if n \{\ .RS 4 .\} .nf $ vimdiff input\&.dcm output\&.dcm .fi .if n \{\ .RE .\} .SS "vbindiff" .PP On UNIX you can visually compare binary file using the vbindiff command: .PP .if n \{\ .RS 4 .\} .nf $ vbindiff input\&.dcm output\&.dcm .fi .if n \{\ .RE .\} .SH "SEE ALSO" .PP \fBgdcmdump\fR(1), \fBgdcmraw\fR(1), \fBgdcminfo\fR(1), \fBgdcmdiff\fR(1) .SH "AUTHOR" .PP \fBMathieu Malaterre\fR .RS 4 Main developer .RE .SH "COPYRIGHT" .br Copyright \(co 2006, 2011 Mathieu Malaterre .br