DCMTK Version 3.7.0 OFFIS DICOM Toolkit

dcmjpls: a compression/decompression library and utility apps

This module contains classes that convert between uncompressed and JPEG-LS compressed representations (transfer syntaxes) of a DICOM image object. Both lossless and near-lossless JPEG-LS processes are supported. This module implements a family of codecs that are derived from class DcmCodec and can be registered in the codec list maintained in module dcmdata.

The main interface classes are:

- DJLSEncoderRegistration
- DJLSDecoderRegistration
- DJLSEncoderBase
- DJLSDecoderBase

# Tools

This module contains the following command line tools:

- dcmcjpls: Encode DICOM file to JPEG-LS transfer syntax
- dcmdjpls: Decode JPEG-LS compressed DICOM file
- dcml2pnm: Convert DICOM images to PGM/PPM, PNG, TIFF or BMP

# Examples

The following example shows how to compress a DICOM image file with lossless JPEG-LS:

DJLSEncoderRegistration::registerCodecs(); // register JPEG-LS codecs
DcmFileFormat fileformat;
if (fileformat.loadFile("test.dcm").good())
{
DcmDataset *dataset = fileformat.getDataset();
DcmItem *metaInfo = fileformat.getMetaInfo();
DJLSRepresentationParameter rp(0, OFTrue); // parameters for lossless
// this causes the lossless JPEG-LS version of the dataset to be created
dataset->chooseRepresentation(EXS_JPEGLSLossless, &params);
// check if everything went well
if (dataset->canWriteXfer(EXS_JPEGLSLossless))
{
// store in lossless JPEG-LS format
fileformat.saveFile("test_jpls.dcm", EXS_JPEGLSLossless);
}
}
DJLSEncoderRegistration::cleanup(); // deregister JPEG-LS codecs
DJLSEncoderRegistration::cleanup
static void cleanup()
deregisters encoders.
DJLSEncoderRegistration::registerCodecs
static void registerCodecs(Uint16 jpls_t1=0, Uint16 jpls_t2=0, Uint16 jpls_t3=0, Uint16 jpls_reset=0, OFBool preferCookedEncoding=OFTrue, Uint32 fragmentSize=0, OFBool createOffsetTable=OFTrue, JLS_UIDCreation uidCreation=EJLSUC_default, OFBool convertToSC=OFFalse, DJLSCodecParameter::interleaveMode jplsInterleaveMode=DJLSCodecParameter::interleaveDefault, OFBool useFFbitstreamPadding=OFTrue)
registers encoders for all supported JPEG-LS processes.
DJLSRepresentationParameter
representation parameter for JPEG-LS
Definition: djrparam.h:32
DcmDataset
a class handling the DICOM dataset format (files without meta header)
Definition: dcdatset.h:42
DcmDataset::chooseRepresentation
OFCondition chooseRepresentation(const E_TransferSyntax repType, const DcmRepresentationParameter *repParam)
select a specific representation (compressed or uncompressed) of the dataset and create the represent...
DcmDataset::canWriteXfer
virtual OFBool canWriteXfer(const E_TransferSyntax newXfer, const E_TransferSyntax oldXfer=EXS_Unknown)
check if this DICOM object can be encoded in the given transfer syntax.
DcmFileFormat
a class handling the DICOM file format (with meta header)
Definition: dcfilefo.h:42
DcmFileFormat::saveFile
virtual OFCondition saveFile(const OFFilename &fileName, const E_TransferSyntax writeXfer=EXS_Unknown, const E_EncodingType encodingType=EET_UndefinedLength, const E_GrpLenEncoding groupLength=EGL_recalcGL, const E_PaddingEncoding padEncoding=EPD_noChange, const Uint32 padLength=0, const Uint32 subPadLength=0, const E_FileWriteMode writeMode=EWM_createNewMeta)
save object to a DICOM file.
DcmFileFormat::getMetaInfo
DcmMetaInfo * getMetaInfo()
get file meta information header part of the fileformat
DcmFileFormat::loadFile
virtual OFCondition loadFile(const OFFilename &fileName, const E_TransferSyntax readXfer=EXS_Unknown, const E_GrpLenEncoding groupLength=EGL_noChange, const Uint32 maxReadLength=DCM_MaxReadLength, const E_FileReadMode readMode=ERM_autoDetect)
load object from a DICOM file.
DcmFileFormat::getDataset
DcmDataset * getDataset()
get dataset part of the fileformat
DcmItem
a class representing a list of DICOM elements in which each element has a different tag and elements ...
Definition: dcitem.h:48
OFCondition::good
OFBool good() const
check if the status is OK.
Definition: ofcond.h:313
EXS_JPEGLSLossless
@ EXS_JPEGLSLossless
JPEG-LS (lossless)
Definition: dcxfer.h:94

The following example shows how to decompress a JPEG-LS compressed DICOM image file:

DJLSDecoderRegistration::registerCodecs(); // register JPEG-LS codecs
DcmFileFormat fileformat;
if (fileformat.loadFile("test_jpls.dcm").good())
{
DcmDataset *dataset = fileformat.getDataset();
// decompress data set if compressed
dataset->chooseRepresentation(EXS_LittleEndianExplicit, NULL);
// check if everything went well
if (dataset->canWriteXfer(EXS_LittleEndianExplicit))
{
fileformat.saveFile("test_decompressed.dcm", EXS_LittleEndianExplicit);
}
}
DJLSDecoderRegistration::cleanup(); // deregister JPEG-LS codecs
DJLSDecoderRegistration::registerCodecs
static void registerCodecs(JLS_UIDCreation uidcreation=EJLSUC_default, JLS_PlanarConfiguration planarconfig=EJLSPC_restore, OFBool ignoreOffsetTable=OFFalse, OFBool forceSingleFragmentPerFrame=OFFalse)
registers decoder for all supported JPEG-LS processes.
DJLSDecoderRegistration::cleanup
static void cleanup()
deregisters decoders.
EXS_LittleEndianExplicit
@ EXS_LittleEndianExplicit
Explicit VR Little Endian.
Definition: dcxfer.h:46

# Legal Remark

Please note that Hewlett Packard claims to own patents that apply to JPEG-LS. Hewlett Packard grants free licenses for conformant implementations of JPEG-LS. OFFIS as the author of the DCMTK toolkit has obtained such a license, but depending on your national legislations companies that use DCMTK's JPEG-LS codec may need to also acquire a license. Read more at http://www.hpl.hp.com/loco/ if you intend to use this module for commercial purposes.

Generated on Mon Dec 15 2025 for DCMTK Version 3.7.0 by Doxygen 1.9.1