Skip to Content
go-dicom(3)
Command line

decompress

Decodes the pixel data of a compressed DICOM file and writes it as Explicit VR Little Endian. Everything else in the file is kept.

When to use it

Use decompress when a tool or viewer cannot read a compressed syntax, to look at the raw samples, or to check that a lossless round trip gave back what went in. It reads RLE, JPEG Baseline, Extended and Lossless, JPEG-LS, JPEG 2000, HTJ2K, JPEG XL and Deflated Image Frame Compression.

Decoding does not undo a loss: a file that was lossy stays marked lossy. To move a file to another compressed syntax, use compress, which decodes first.

The closest dcmtk tools are dcmdrle, dcmdjpeg, dcmdjpls and dcmconv +te; in pydicom, ds.decompress().

Examples

Decode a file

go-dicom decompress ct-jls.dcm ct-back.dcm
Wrote ct-back.dcm: Explicit VR Little Endian (1.2.840.10008.1.2.1)

Check a lossless round trip

go-dicom compress -syntax jpeg-ls ct.dcm ct-jls.dcm
go-dicom decompress ct-jls.dcm ct-back.dcm
go-dicom diff ct.dcm ct-back.dcm --ignore-meta
--- ct.dcm
+++ ct-back.dcm
(0008,0005) Specific Character Set
- CS ISO_IR 100
+ CS ISO_IR 192

Pixel Data is equal, byte for byte. The one difference is the character set: the writer stores text as UTF-8.

Decode a lossy file

go-dicom decompress j2k.dcm j2k-raw.dcm
go-dicom show j2k-raw.dcm::LossyImageCompression
Wrote j2k-raw.dcm: Explicit VR Little Endian (1.2.840.10008.1.2.1)
0028,2110    CS  2       01

In place

go-dicom decompress -in-place inplace.dcm
Wrote inplace.dcm: Explicit VR Little Endian (1.2.840.10008.1.2.1)

Warning

-in-place replaces the input, through a new file renamed over it. The compressed original is gone; for a lossy file the stored codestream cannot be rebuilt from the decoded samples.

Notes

  • What describes the samples changes with them: Planar Configuration 0 for color, YBR_FULL for a 4:2:2 JPEG, RGB for a JPEG 2000 color transform. The SOP Instance UID and Lossy Image Compression are kept.
  • A file that is not compressed is refused: Error: decompress: ct.dcm is not compressed: its transfer syntax is 1.2.840.10008.1.2.1.
  • Naming the input as output without -in-place is refused.
  • Exit status is 0 when the file was written, 1 otherwise.
  • See CONFORMANCE.md, Pixel data.

See also

Options

Write a file's pixel data uncompressed

USAGE:
  go-dicom decompress [options] <input> <output>
  go-dicom decompress [options] -in-place <file>

  Decodes the pixel data of a compressed file, in any syntax this tool
  reads (RLE, JPEG Baseline, Extended and Lossless, JPEG-LS, JPEG 2000, HTJ2K,
  Deflated Image Frame Compression), and writes it as Explicit VR Little
  Endian.

OPTIONS:
  -in-place   Write over the input, through a new file renamed over it.
  -h, -help   Show this help message

WHAT CHANGES:
  The transfer syntax and Pixel Data, and what describes the samples as
  they come out: Planar Configuration 0 for color, YBR_FULL for a 4:2:2
  JPEG, RGB for a JPEG 2000 color transform. The SOP Instance UID is kept,
  and so is Lossy Image Compression: decoding does not undo a loss.

EXAMPLES:
  go-dicom decompress ct-jpeg.dcm ct.dcm
  go-dicom decompress -in-place us.dcm

On this page