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 β€” use vtkDICOMImageReader (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:

  1. DICOM: Direction Cosines and vtkMedicalImageInformation are passed to the output
  2. BMP: the file can be saved with a Lookup Table (see --palette-color)
  3. GE Signa: vtkMedicalImageProperties is passed to the output
  4. MINC: Direction Cosines is passed to the output
  5. TIFF: vtkTIFFReader is 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 the vtkGDCMImageReader/vtkGDCMImageWriter combination. 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 also gdcmimg (better handling of JPEG in general). ngl, if you're doing lots of JPEG stuff, go hang out with gdcmimg. 🫢
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 Β© 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 πŸ’…πŸŽ€πŸ¦‹