GDCM2VTK(1)
π GDCM2VTK β DICOM Manipulation β¨
okay so bestie, welcome to gdcm2vtk, one of the little utilities from the DICOM Manipulation fam. this is the one that takes basically any file VTK can read and turns it into a DICOM file. it's giving converter-girlie, it's giving bridge between worlds, and honestly? iconic.
π¦ NAME
gdcm2vtk β convert a file supported by VTK into DICOM. that's the whole assignment, and she ate. π
β¨ SYNOPSIS
gdcm2vtk [options] file-in file-out
π DESCRIPTION
so like, gdcm2vtk takes as input any file supported by VTK (yep, including DICOM files, she's flexible like that πΈ) and will generate as output a DICOM file. no cap.
π PARAMETERS
file-inβ input filename (DICOM or VTK supported)file-outβ output filename (DICOM or VTK supported)
π OPTIONS
specific options
--force-rescaleβ force rescale. like, make it rescale, no arguments. πͺ--force-spacingβ force spacing. same energy, different attribute.--palette-colorβ when supported, generate a PALETTE COLOR file π¨--argbβ when supported, generate a ARGB file--compressβ when supported, generate a compressed file--use-vtkdicomβ usevtkDICOMImageReader(instead of GDCM) π--modalityβ set Modality--lower-leftβ set lower left--shiftβ set shift--scaleβ set scale--compressβ set compression (MetaIO) β yes bestie, she's listed twice in the original, once for the "when supported, generate a compressed file" vibe and once for the MetaIO compression vibe. not a typo on my end, I promise π«Ά-T,--study-uidβ Study UID-S,--series-uidβ Series UID--root-uidβ Root UID--imageformatβ Image Format[1-8](aka PhotometricInterpretation)--ipp-sortβ when input is a directory, sort instances using IOP/IPP π₯
compression options
-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) β lossless only, she said what she said π
general options
-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 π
environment variable
GDCM_ROOT_UIDβ Root UID
π DESCRIPTION (yes, round two, she has two of them and both are valid)
Convert a file supported by VTK into DICOM. simple as that.
typical usage is literally:
$ gdcm2vtk inputfile output.dcm
it uses the internal factory mechanism of VTK to recognize a file (the CanRead function, iykyk). see VTK supported file here:
What image file formats can VTK read and write? http://www.vtk.org/Wiki/VTK_FAQ#What_image_file_formats_can_VTK_read_and_write.3F
here's a thing you need to know bestie: if your input file has 4 components, the 4th comp (alpha) will be removed from the output file, because DICOM does not support alpha component anymore (see --argb option). rip alpha, she's not invited π
special care was taken for the following file format:
- DICOM: Direction Cosines and
vtkMedicalImageInformationare passed to the output - BMP: the file can be saved with a Lookup Table (see
--palette-color) - GE Signa:
vtkMedicalImagePropertiesis passed to the output - MINC: Direction Cosines is passed to the output
- TIFF:
vtkTIFFReaderis currently in bad shape in VTK (different behavior in VTK 5.2 and git/master). Only use it, if you know what you are doing. π¨
π§ CONVERT MetaImage (mhd, mha)
$ gdcm2vtk inputfile output.mha
this command will convert the input DICOM file inputfile into a MetaImage .mha file. same goes for .mhd file. slay.
π CONVERT MHA/MHD
$ gdcm2vtk inputfile output.mha
or
$ gdcm2vtk inputfile output.mhd
this command will convert the input DICOM file inputfile into a MetaImageData .mha/.mhd file. both paths, same destination, we love versatility.
π CONVERT VTI
$ gdcm2vtk inputfile output.vti
this command will convert the input DICOM file inputfile into a XML VTK ImageData .vti file.
β CONVERT VTK
$ gdcm2vtk inputfile output.vtk
this command will convert the input DICOM file inputfile into an old VTK Structured PointSets .vtk file. vintage, but make it fashion.
π₯ CONVERT DICOM
$ gdcm2vtk input.dcm output.dcm
vtkGDCMImageReader will be used to read in a DICOM file, not the default vtkDICOMImageReader. see option --use-vtkdicom to use vtkDICOMImageReader. choose your fighter π₯
πΈ ROUNDTRIP DICOM TO MHD TO DICOM
$ gdcm2vtk input_ybr.dcm output.mhd
$ gdcm2vtk --modality US --imageformat 7 output.mhd output.dcm
the above refsection shows how to convert a DICOM using the Photometric Interpretation of YBR_FULL (or even YBR_FULL_422 is lossy) into another file format: MetaImage (mhd). since this file format does not handle color space, we have to explicitly set it using the --imageformat command line option. the --modality command line option is required in this case, since the default Secondary Capture Image Storage Class family does not allow for YBR Photometric Interpretation. it's giving "you must be this tall to ride" π’
π GDCM2VTK NOTES
IMPORTANT NOTE: the internal VTK structured will be filled from the input DICOM, and then pass to the output DICOM writer. some information might be lost during the conversion DICOM to VTK to DICOM π. this option is mostly used to test thevtkGDCMImageReader/vtkGDCMImageWritercombination. so like, don't be surprised if some metadata ghosts you.
IMPORTANT NOTE: when converting from a lossy format such as JPEG, the information of lossiness is important. the output DICOM will contains the required Lossy Image Compression attribute that indicates that image was lossy-compressed somewhere along the pipeline. see alsogdcmimg(better handling of JPEG in general). ngl, if you're doing lots of JPEG stuff, go hang out withgdcmimg. π«Ά
IMPORTANT NOTE: when using --use-vtkdicom, the output DICOM file will always be written as MR Image Storage, as this information is not available from the reader itself. this allow setting the Image Orientation (Patient) properly. yes, always MR. no, you don't get a say. that's just how she is. π
π SEE ALSO
gdcmdump(1), gdcmviewer(1), gdcmimg(1) β the rest of the squad, go say hi π
π AUTHOR
Mathieu Malaterre Main developer
Β© COPYRIGHT
Copyright Β© 2006, 2011 Mathieu Malaterre
and that's the whole page bestie!! β¨ this was GDCM 3.0.24, dated 12/25/2025 β merry everything, go convert some files, and remember: alpha gets dropped, TIFF is on thin ice, and --rtfm doesn't exist so read the options again π
ππ¦
π¦ where this page comes from
- opensuse-leap 16.0: gdcm-applications 3.0.24-bp160.2.1 Β· BSD-3-Clause
- opensuse-leap 16.0: gdcm-applications 3.0.24-bp160.2.1 Β· BSD-3-Clause
- opensuse-leap 16.0: gdcm-applications 3.0.24-bp160.2.1 Β· BSD-3-Clause
- opensuse-leap 16.0: gdcm-applications 3.0.24-bp160.2.1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms