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 arefatal,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 (-90degrees).+Rr,--rotate-rightβ rotate image right (+90degrees).+Rtd,--rotate-top-downβ rotate image top-down (180degrees).
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 with16bits/pixel have been observed "in the wild" that are compressed with lossless JPEG and need special handling because the encoder produced an16-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 for16-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 toLINEAR.+Wfs,--sigmoid-functionβ set VOI LUT function toSIGMOID.
presentation LUT transformation:
+Pid,--identity-shapeβ set presentation LUT shape toIDENTITY.+Piv,--inverse-shapeβ set presentation LUT shape toINVERSE.+Pod,--lin-od-shapeβ set presentation LUT shape toLIN 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 predictor1(no prediction).+Ph,--predictor-horzβ LZW predictor2(horizontal differencing).+Rs,--rows-per-strip[r]ows: integer (default: 0) β rows per strip, default8Kper 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-rangeor--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 toolkit2= free scaling algorithm with interpolation from c't magazine3= magnification algorithm with bilinear interpolation from Eduard Stanescu4= 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.2LittleEndianExplicitTransferSyntaxβ1.2.840.10008.1.2.1DeflatedExplicitVRLittleEndianTransferSyntaxβ1.2.840.10008.1.2.1.99(*)BigEndianExplicitTransferSyntaxβ1.2.840.10008.1.2.2JPEGLSLosslessTransferSyntaxβ1.2.840.10008.1.2.4.80JPEGLSLossyTransferSyntaxβ1.2.840.10008.1.2.4.81JPEGProcess10_12TransferSyntaxβ1.2.840.10008.1.2.4.55JPEGProcess14SV1TransferSyntaxβ1.2.840.10008.1.2.4.70JPEGProcess14TransferSyntaxβ1.2.840.10008.1.2.4.57JPEGProcess1TransferSyntaxβ1.2.840.10008.1.2.4.50JPEGProcess2_4TransferSyntaxβ1.2.840.10008.1.2.4.51JPEGProcess6_8TransferSyntaxβ1.2.840.10008.1.2.4.53RLELosslessTransferSyntaxβ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 π
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
- arch rolling: dcmtk 3.7.1-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