dcm2img(1)

🌈 dcm2img β€” bestie's guide to the DICOM-to-image glow-up πŸ’…

okay so first things first: this is a page from OFFIS DCMTK, and the tool we're stanning is dcm2img(1). she takes your crusty DICOM files and turns them into actual pictures you can look at. no cap. let's get into it. ✨


🌸 NAME 🌸

dcm2img β€” convert a DICOM image into a standard image format πŸŽ€

✨ SYNOPSIS ✨

dcm2img [options] dcmfile-in [bitmap-out]

πŸ’– DESCRIPTION πŸ’–

so here's the vibe: dcm2img reads a DICOM image, converts the pixel data based on whatever image processing options you picked, and writes out an image in one of these general purpose formats, like, your choice bestie: BMP, PGM/PPM, PNG, TIFF, JPEG, or JPEG-LS. πŸ”₯

and yes she's flexible β€” this utility supports uncompressed DICOM images as well as JPEG, JPEG-LS and RLE compressed DICOM images. she contains multitudes. πŸ¦‹

🧚 PARAMETERS 🧚

  • dcmfile-in β€” the DICOM input filename to be converted. and hey, pass "-" if you want her to read from stdin. iconic. πŸ’œ
  • bitmap-out β€” the output filename to be written. default is stdout, so if you don't say anything she just yaps the image straight out. πŸ“€

πŸ‘‘ OPTIONS πŸ‘‘

general options 🫢

  • -h, --help β€” print this help text and exit. the classic "what does anything do" move.
  • --version β€” print version information and exit.
  • --arguments β€” print the expanded command line arguments.
  • -q, --quiet β€” quiet mode, print no warnings and errors. she's on mute, respectfully. 🀐
  • -v, --verbose β€” verbose mode, print processing details. she will tell you everything. πŸ’¬
  • -d, --debug β€” debug mode, print debug information.
  • -ll, --log-level [l]evel: string constant β€” use level l for the logger. the valid levels are fatal, error, warn, info, debug, trace.
  • -lc, --log-config [f]ilename: string β€” use config file f for the logger.

input options πŸ“₯

input file format:

  • +f, --read-file β€” read file format or data set (default).
  • +fo, --read-file-only β€” read file format only.
  • -f, --read-dataset β€” read data set without file meta information.

input transfer syntax:

  • -t=, --read-xfer-auto β€” use TS recognition (default).
  • -td, --read-xfer-detect β€” ignore TS specified in the file meta header.
  • -te, --read-xfer-little β€” read with explicit VR little endian TS.
  • -tb, --read-xfer-big β€” read with explicit VR big endian TS.
  • -ti, --read-xfer-implicit β€” read with implicit VR little endian TS.

image processing options 🎨

frame selection:

  • +F, --frame [n]umber: integer β€” select specified frame (default: 1).
  • +Fr, --frame-range [n]umber [c]ount: integer β€” select c frames beginning with frame n.
  • +Fa, --all-frames β€” select all frames. go off, get every single one. 🎞️

rotation:

  • +Rl, --rotate-left β€” rotate image left (-90 degrees).
  • +Rr, --rotate-right β€” rotate image right (+90 degrees).
  • +Rtd, --rotate-top-down β€” rotate image top-down (180 degrees).

flipping:

  • +Lh, --flip-horizontally β€” flip image horizontally.
  • +Lv, --flip-vertically β€” flip image vertically.
  • +Lhv, --flip-both-axes β€” flip image horizontally and vertically.

scaling:

  • +a, --recognize-aspect β€” recognize pixel aspect ratio when scaling (default).
  • -a, --ignore-aspect β€” ignore pixel aspect ratio when scaling.
  • +i, --interpolate [n]umber of algorithm: integer β€” use interpolation when scaling (1..4, default: 1).
  • -i, --no-interpolation β€” no interpolation when scaling.
  • -S, --no-scaling β€” no scaling, ignore pixel aspect ratio (default).
  • +Sxf, --scale-x-factor [f]actor: float β€” scale x axis by factor, auto-compute y axis.
  • +Syf, --scale-y-factor [f]actor: float β€” scale y axis by factor, auto-compute x axis.
  • +Sxv, --scale-x-size [n]umber: integer β€” scale x axis to n pixels, auto-compute y axis.
  • +Syv, --scale-y-size [n]umber: integer β€” scale y axis to n pixels, auto-compute x axis.

color space conversion (JPEG compressed images only):

  • +cp, --conv-photometric β€” convert if YCbCr photometric interpretation (default).
  • +cl, --conv-lossy β€” convert YCbCr to RGB if lossy JPEG.
  • +cg, --conv-guess β€” convert to RGB if YCbCr is guessed by library.
  • +cgl, --conv-guess-lossy β€” convert to RGB if lossy JPEG and YCbCr is guessed by the underlying JPEG library.
  • +ca, --conv-always β€” always convert YCbCr to RGB.
  • +cn, --conv-never β€” never convert color space.

bits stored:

  • +bs, --bits-stored-fix β€” correct inconsistent bits stored value (default).
so like β€” if the value of BitsStored in the compressed bitstream is smaller than the value in the DICOM dataset, update the value in the dataset (JPEG compressed images only). 🩹
  • -bs, --bits-stored-keep β€” preserve inconsistent bits stored value.
keep the value of BitsStored even if inconsistent with the compressed bitstream. this may help in correctly decoding some defective images (JPEG compressed images only). πŸ™ˆ

workaround options for incorrect encodings (JPEG compressed images only):

  • +w6, --workaround-pred6 β€” enable workaround for JPEG lossless images with overflow in predictor 6.
DICOM images with 16 bits/pixel have been observed "in the wild" that are compressed with lossless JPEG and need special handling because the encoder produced an 16-bit integer overflow in predictor 6, which needs to be compensated (reproduced) during decompression. this flag enables a correct decompression of such faulty images, but at the same time will cause an incorrect decompression of correctly compressed images. use with care. πŸ’€
  • +wi, --workaround-incpl β€” enable workaround for incomplete JPEG data.
this option causes dcm2img to ignore incomplete JPEG data at the end of a compressed fragment and to start decompressing the next frame from the next fragment (if any). this permits images with incomplete JPEG data to be decoded. 🧩
  • +wc, --workaround-cornell β€” enable workaround for 16-bit JPEG lossless Cornell images with Huffman table overflow.
one of the first open-source implementations of lossless JPEG compression, the "Cornell" library, has a well-known bug that leads to invalid values in the Huffmann table when images with 16 bit/sample are compressed. this flag enables a workaround that permits such images to be decoded correctly. πŸ›

modality LUT transformation:

  • -M, --no-modality β€” ignore stored modality LUT transformation.
  • +M, --use-modality β€” use modality LUT transformation (default).

VOI LUT transformation:

  • -W, --no-windowing β€” no VOI windowing (default).
  • +Wi, --use-window [n]umber: integer β€” use the n-th VOI window from image file.
  • +Wl, --use-voi-lut [n]umber: integer β€” use the n-th VOI look up table from image file.
  • +Wm, --min-max-window β€” compute VOI window using min-max algorithm.
  • +Wn, --min-max-window-n β€” compute VOI window using min-max algorithm, ignoring extreme values.
  • +Wr, --roi-min-max-window [l]eft [t]op [w]idth [h]eight: integer β€” compute ROI window using min-max algorithm, region of interest is specified by l,t,w,h.
  • +Wh, --histogram-window [n]umber: integer β€” compute VOI window using Histogram algorithm, ignoring n percent.
  • +Ww, --set-window [c]enter [w]idth: float β€” compute VOI window using center c and width w.
  • +Wfl, --linear-function β€” set VOI LUT function to LINEAR.
  • +Wfs, --sigmoid-function β€” set VOI LUT function to SIGMOID.

presentation LUT transformation:

  • +Pid, --identity-shape β€” set presentation LUT shape to IDENTITY.
  • +Piv, --inverse-shape β€” set presentation LUT shape to INVERSE.
  • +Pod, --lin-od-shape β€” set presentation LUT shape to LIN OD.

overlay:

  • -O, --no-overlays β€” do not display overlays.
  • +O, --display-overlay [n]umber: integer β€” display overlay n (0..16, 0=all, default: +O 0).
  • +Omr, --ovl-replace β€” use overlay mode "Replace" (default for Graphic overlays).
  • +Omt, --ovl-threshold β€” use overlay mode "Threshold Replace".
  • +Omc, --ovl-complement β€” use overlay mode "Complement".
  • +Omv, --ovl-invert β€” use overlay mode "Invert Bitmap".
  • +Omi, --ovl-roi β€” use overlay mode "Region of Interest" (default for ROI overlays).
  • +Osf, --set-foreground [d]ensity: float β€” set overlay foreground density (0..1, default: 1).
  • +Ost, --set-threshold [d]ensity: float β€” set overlay threshold density (0..1, default: 0.5).

display LUT transformation:

  • +Dm, --monitor-file [f]ilename: string β€” calibrate output according to monitor characteristics defined in f.
  • +Dp, --printer-file [f]ilename: string β€” calibrate output according to printer characteristics defined in f.
  • +Da, --ambient-light [a]mbient light: float β€” ambient light value (cd/m^2, default: file f).
  • +Di, --illumination [i]llumination: float β€” illumination value (cd/m^2, default: file f).
  • +Dn, --min-density [m]inimum optical density: float β€” Dmin value (default: off, only with +Dp).
  • +Dx, --max-density [m]aximum optical density: float β€” Dmax value (default: off, only with +Dp).
  • +Dg, --gsd-function β€” use GSDF for calibration (default for +Dm/+Dp).
  • +Dc, --cielab-function β€” use CIELAB function for calibration.

compatibility:

  • +Ma, --accept-acr-nema β€” accept ACR-NEMA images without photometric interpretation.
  • +Mp, --accept-palettes β€” accept incorrect palette attribute tags (0028,111x) and (0028,121x).
  • +Mc, --check-lut-depth β€” check 3rd value of the LUT descriptor, compare with expected bit depth based on LUT data.
  • +Mm, --ignore-mlut-depth β€” ignore 3rd value of the modality LUT descriptor, determine bits per table entry automatically.
  • +Mv, --ignore-vlut-depth β€” ignore 3rd value of the VOI LUT descriptor, determine bits per table entry automatically.

TIFF format:

  • +Tl, --compr-lzw β€” LZW compression (default).
  • +Tr, --compr-rle β€” RLE compression.
  • +Tn, --compr-none β€” uncompressed.
  • +Pd, --predictor-default β€” no LZW predictor (default).
  • +Pn, --predictor-none β€” LZW predictor 1 (no prediction).
  • +Ph, --predictor-horz β€” LZW predictor 2 (horizontal differencing).
  • +Rs, --rows-per-strip [r]ows: integer (default: 0) β€” rows per strip, default 8K per strip.

PNG format:

🌸 PNG format

  • +il, --interlace β€” makes an interlaced file, so it progressively reveals itself while loading (this is the default, no cap) ✨
  • -il, --nointerlace β€” nope, no interlacing, regular non-interlaced file
  • +mf, --meta-file β€” writes PNG meta information into the file (also the default, we love a documented queen) πŸŽ€
  • -mf, --meta-none β€” zero PNG meta information, nothing, gone

πŸ”₯ JPEG format

  • +Jq, --compr-quality [q]uality: integer (0..100, default: 90) β€” the compression quality value, in percent
  • +Js4, --sample-444 β€” 4:4:4 sampling, aka no subsampling at all, chroma stays fully booked πŸ’…
  • +Js2, --sample-422 β€” 4:2:2 subsampling: horizontal subsampling of the chroma components (this one's the default)
  • +Js1, --sample-411 β€” 4:1:1 subsampling: horizontal and vertical subsampling of the chroma components, chroma is fighting for its life

πŸ¦‹ JPEG-LS format

  • +Trl, --rendered-lossless β€” lossless compression of the rendered image (default, and yes it's giving iconic)
  • +Tll, --true-lossless β€” lossless compression of the raw image
  • +f8, --force-8-bit β€” forces the output bit depth down to 8 bits, but lowkey not allowed together with --true-lossless

✨ other transformations

  • +G, --grayscale β€” converts a color image to grayscale (monochrome), vintage filter but make it medical imaging
  • +P, --change-polarity β€” flips the polarity, i.e. inverts the pixel output
  • +C, --clip-region [l]eft [t]op [w]idth [h]eight: integer β€” clips an image region, args are (l, t, w, h)

⭐ output options ⭐

general

  • -im, --image-info β€” prints image details (heads up: this one requires verbose mode, it's not optional)
  • -o, --no-output β€” creates literally no output at all (super useful alongside -im)

πŸŽ€ filename generation

Only works with --frame-range or --all-frames, bestie. Otherwise it's just sitting there.
  • +Fc, --use-frame-counter β€” uses a 0-based counter for filenames (the default)
  • +Fn, --use-frame-number β€” uses the absolute frame number for filenames instead

🌈 image format

  • +oa, --write-auto β€” figures out the file format from the filename extension (default for files)
⚠️ If the output filename contains no extension, or an unknown/unsupported one, a warning gets printed and a BMP file gets written anyway (see --write-bmp). It said what it said.
  • +op, --write-raw-pnm β€” writes 8-bit binary PGM/PPM
  • +opb, --write-8-bit-pnm β€” writes 8-bit ASCII PGM/PPM (default when output goes to stdout)
  • +opw, --write-16-bit-pnm β€” writes 16-bit ASCII PGM/PPM
  • +opn, --write-n-bit-pnm [n]umber: integer β€” writes n-bit ASCII PGM/PPM (1..32)
  • +ob, --write-bmp β€” writes 8-bit (monochrome) or 24-bit (color) BMP
  • +obp, --write-8-bit-bmp β€” writes 8-bit palette BMP (monochrome only, sorry color girlies)
  • +obt, --write-24-bit-bmp β€” writes 24-bit truecolor BMP
  • +obr, --write-32-bit-bmp β€” writes 32-bit truecolor BMP
  • +ot, --write-tiff β€” writes 8-bit (monochrome) or 24-bit (color) TIFF
  • +on, --write-png β€” writes 8-bit (monochrome) or 24-bit (color) PNG
  • +on2, --write-16-bit-png β€” writes 16-bit (monochrome) or 48-bit (color) PNG, fancy
  • +oj, --write-jpeg β€” writes 8-bit lossy JPEG (baseline)
  • +ol, --write-jpls β€” writes JPEG-LS

πŸ““ NOTES πŸ““

So these are the preferred interpolation algorithms you can pick with the --interpolate option:

  • 1 = free scaling algorithm with interpolation from pbmplus toolkit
  • 2 = free scaling algorithm with interpolation from c't magazine
  • 3 = magnification algorithm with bilinear interpolation from Eduard Stanescu
  • 4 = magnification algorithm with bicubic interpolation from Eduard Stanescu

The --write-tiff option is only available when DCMTK has been configured and compiled with support for the external libtiff TIFF library β€” like, it literally doesn't exist otherwise. And the availability of the TIFF compression options depends on the libtiff configuration.

The --write-png option is only available when DCMTK has been configured and compiled with support for the external libpng PNG library. Option --interlace enables progressive image view while loading the PNG file. Also fair warning: only a few applications actually take care of the meta info (TEXT) in a PNG file. Most of them simply do not care πŸ’€


πŸ”„ TRANSFER SYNTAXES πŸ”„

dcm2img supports the following transfer syntaxes for input (dcmfile-in), periodt:

  • LittleEndianImplicitTransferSyntax β€” 1.2.840.10008.1.2
  • LittleEndianExplicitTransferSyntax β€” 1.2.840.10008.1.2.1
  • DeflatedExplicitVRLittleEndianTransferSyntax β€” 1.2.840.10008.1.2.1.99 (*)
  • BigEndianExplicitTransferSyntax β€” 1.2.840.10008.1.2.2
  • JPEGLSLosslessTransferSyntax β€” 1.2.840.10008.1.2.4.80
  • JPEGLSLossyTransferSyntax β€” 1.2.840.10008.1.2.4.81
  • JPEGProcess10_12TransferSyntax β€” 1.2.840.10008.1.2.4.55
  • JPEGProcess14SV1TransferSyntax β€” 1.2.840.10008.1.2.4.70
  • JPEGProcess14TransferSyntax β€” 1.2.840.10008.1.2.4.57
  • JPEGProcess1TransferSyntax β€” 1.2.840.10008.1.2.4.50
  • JPEGProcess2_4TransferSyntax β€” 1.2.840.10008.1.2.4.51
  • JPEGProcess6_8TransferSyntax β€” 1.2.840.10008.1.2.4.53
  • RLELosslessTransferSyntax β€” 1.2.840.10008.1.2.5

(*) only if compiled with zlib support enabled 🫢


🧚 LOGGING 🧚

Okay so the level of logging output from all these command line tools and their underlying libraries is fully user-specifiable. By default, only errors and warnings get written to the standard error stream. Using option --verbose also reports informational messages like processing details. Option --debug gets you even more detail on the internal activity, e.g. for debugging purposes. You can pick other logging levels with option --log-level. In --quiet mode only fatal errors get reported β€” and in those very severe error events, the application will usually just terminate, like it's had enough 😭 For more details on the different logging levels, see the documentation of module "oflog".

If you want the logging output written to a file (optionally with logfile rotation), to syslog (Unix) or to the event log (Windows), use option --log-config. This configuration file also lets you direct only certain messages to a particular output stream, and filter certain messages based on the module or application where they're generated. An example configuration file is provided in <etcdir>/logger.cfg.


πŸ’œ COMMAND LINE πŸ’œ

All command line tools use the following notation for parameters: square brackets enclose optional values (0-1), three trailing dots indicate that multiple values are allowed (1-n), and a combination of both means 0 to n values. Simple as.

Command line options are distinguished from parameters by a leading + or - sign respectively. Usually, order and position of command line options are arbitrary (i.e. they can appear anywhere). BUT if options are mutually exclusive, the rightmost appearance is the one that wins β€” rightmost = main character. This behavior conforms to the standard evaluation rules of common Unix shells.

In addition, you can specify one or more command files using an @ sign as a prefix to the filename (e.g. @command.txt). Such a command argument gets replaced by the content of the corresponding text file (multiple whitespaces are treated as a single separator unless they appear between two quotation marks) prior to any further evaluation. Please note that a command file cannot contain another command file β€” no inception, we don't do that here πŸ™ˆ This simple but effective approach allows you to summarize common combinations of options/parameters and avoids longish and confusing command lines (an example is provided in file <datadir>/dumppat.txt).


🌱 ENVIRONMENT 🌱

The dcm2img utility will attempt to load DICOM data dictionaries specified in the DCMDICTPATH environment variable. By default, i.e. if the DCMDICTPATH environment variable is not set, the file <datadir>/dicom.dic will be loaded unless the dictionary is built into the application (default for Windows).

The default behavior should be preferred, and the DCMDICTPATH environment variable only used when alternative data dictionaries are required. The DCMDICTPATH environment variable has the same format as the Unix shell PATH variable in that a colon (":") separates entries. On Windows systems, a semicolon (";") is used as a separator. The data dictionary code will attempt to load each file specified in the DCMDICTPATH environment variable. It is an error if no data dictionary can be loaded β€” like, actual error, not a vibe.


πŸ“ FILES πŸ“

  • <datadir>/camera.lut β€” sample characteristics file of a camera
  • <datadir>/monitor.lut β€” sample characteristics file of a monitor
  • <datadir>/printer.lut β€” sample characteristics file of a printer
  • <datadir>/scanner.lut β€” sample characteristics file of a scanner

πŸ‘‘ SEE ALSO πŸ‘‘

img2dcm(1) β€” the other half of the duo, they're literally the same person in different fonts.


Copyright (C) 2001-2026 by OFFIS e.V., Escherweg 2, 26121 Oldenburg, Germany.


✨ Okay that's the whole page, bestie, go convert some images. This was Version 3.7.1, dated Sat Oct 17 2026 09:34:01, and it's the dcm2img(1) manual β€” slay, bye! πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from