Lossless DICOM compression: codec comparison
A free tool to compare the lossless codecs JPEG-LS, JPEG 2000 and HTJ2K on your own DICOM studies. Everything runs locally in the browser: files are never uploaded, and every file is checked against the original by SHA-256 after decompression.
Compresses DICOM files into a lossless .dca archive and checks that every file restores byte for byte (matching SHA-256). Files never leave the browser.
Pick .dcm files, a .zip, or several files
Pick a .dca created on this page
How it works
- Pick DICOM files or a zip archive with a study, and a codec.
- Press Compress: the browser compresses the pixels of every frame with the chosen codec, decodes them right away and compares the result byte for byte. DICOM headers are kept unchanged.
- Download the .dca archive and decompress it in the Decompress and verify block: the table shows whether the SHA-256 of every restored file matches the original.
How the compression works
The tool does not re-encode the whole DICOM file. It separates the pixels from the headers, compresses only the pixels and verifies every step, so the original file can be rebuilt byte for byte.
Compression
- DICOM file
Read in the browser; its SHA-256 is computed as the fingerprint of the original.
- Split
The file is split into three parts: the header before the pixels, the pixels, and the tail after them.
- Encode and verify
Every frame is compressed with the chosen codec, decoded right away and compared with the original byte for byte.
- .dca archive
Headers, compressed frames and a manifest with SHA-256 hashes go into one file.
- If the codec fails or the check does not match, the frame is stored with deflate, so no data is lost.
- If the pixels in the source are already compressed (JPEG 2000, JPEG-LS, JPEG, RLE), they are kept as is.
What a .dca holds
- Manifest
The file list: name, size, SHA-256, storage method and the offset of every frame.
- Headers
All DICOM headers as one compressed stream: within a series they are nearly identical and take a fraction of a percent.
- Frame data
Frame codestreams back to back: JPEG-LS, JPEG 2000 or HTJ2K, or deflate for the fallback.
Restore and verification
- Read .dca
Format, version and the bounds of every block are checked, so a damaged archive never turns into garbage data.
- Decode
Frames are decoded with the codec they were compressed with, which is recorded in the archive.
- Rebuild the file
Header, restored pixels and tail are joined in their original order.
- SHA-256 check
The hash of the rebuilt file is compared with the original hash from the manifest. A match proves the file is restored unchanged.
Which codec to choose
All three codecs are part of the DICOM standard and are lossless. They differ in ratio and speed, so it is best to test them on your own data. The figures below are our measurement on one MR and one CT study, single-threaded.
| Codec | Transfer syntax (lossless) | When to choose |
|---|---|---|
| JPEG-LS | 1.2.840.10008.1.2.4.80 | Fast (about 5 ms per 512×512 slice) and the most compact on CT. A good default for an archive. |
| JPEG 2000 | 1.2.840.10008.1.2.4.90 | Strongest compression on MR (about ×3.75 versus ×3.5 for JPEG-LS), but encodes roughly 4 times slower. |
| HTJ2K | 1.2.840.10008.1.2.4.201 | High-throughput JPEG 2000: as fast as JPEG-LS with slightly weaker compression. Handy for streaming over DICOMweb. |
Frequently asked questions
Are my files uploaded to a server?
No. Compression, decompression and SHA-256 hashing run in the browser with WebAssembly. Files are not sent to a server and no sign-up is needed.
Is the compression really lossless?
Yes. Every frame is decoded right after encoding and compared with the original pixels byte for byte; if anything differs, the frame is stored with deflate. On decompression the SHA-256 of every restored file is checked against the original hash.
Which codec compresses DICOM best?
It depends on the modality and the data. In our measurements JPEG 2000 wins on MR and JPEG-LS wins on CT while being faster. Compress one study with all three codecs: the chart in the run history shows the ratios side by side.
What happens to files that are already compressed?
Files already compressed with JPEG, JPEG 2000, JPEG-LS or RLE are stored as is: re-encoding them would make a byte-exact restore impossible. The table marks them as already compressed.
What is a .dca file?
The container of this tool: compressed DICOM headers, frame codestreams and a manifest with the SHA-256 of every original file. You can decompress it on this page back into the original files.