DCMTK Version 3.6.9 OFFIS DICOM Toolkit

Loading...
Searching...
No Matches
dcmjpeg: a compression/decompression library and utility apps

This module contains classes that convert between uncompressed and JPEG compressed representations (transfer syntaxes) of a DICOM image object. Both lossless and lossy JPEG 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:

- DJEncoderRegistration
- DJDecoderRegistration
- DJCodecEncoder
- DJCodecDecoder

# Tools

This module contains the following command line tools:

- dcmcjpeg: Encode DICOM file to JPEG transfer syntax
- dcmdjpeg: Decode JPEG-compressed DICOM file
- dcmj2pnm: Convert DICOM images to PGM/PPM, PNG, TIFF, JPEG or BMP
- dcmmkdir: Create a DICOMDIR file

# Examples

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

DJEncoderRegistration::registerCodecs(); // register JPEG codecs
DcmFileFormat fileformat;
if (fileformat.loadFile("test.dcm").good())
{
DcmDataset *dataset = fileformat.getDataset();
DcmItem *metaInfo = fileformat.getMetaInfo();
DJ_RPLossless params; // codec parameters, we use the defaults
// this causes the lossless JPEG version of the dataset to be created
if (dataset->chooseRepresentation(EXS_JPEGProcess14SV1, &params).good() &&
dataset->canWriteXfer(EXS_JPEGProcess14SV1))
{
// store in lossless JPEG format
fileformat.saveFile("test_jpeg.dcm", EXS_JPEGProcess14SV1);
}
}
DJEncoderRegistration::cleanup(); // deregister JPEG codecs
DJEncoderRegistration::registerCodecs
static void registerCodecs(E_CompressionColorSpaceConversion pCompressionCSConversion=ECC_lossyYCbCr, E_UIDCreation pCreateSOPInstanceUID=EUC_default, OFBool pOptimizeHuffman=OFFalse, int pSmoothingFactor=0, int pForcedBitDepth=0, Uint32 pFragmentSize=0, OFBool pCreateOffsetTable=OFTrue, E_SubSampling pSampleFactors=ESS_422, OFBool pWriteYBR422=OFTrue, OFBool pConvertToSC=OFFalse, unsigned long pWindowType=0, unsigned long pWindowParameter=0, double pVoiCenter=0.0, double pVoiWidth=0.0, unsigned long pRoiLeft=0, unsigned long pRoiTop=0, unsigned long pRoiWidth=0, unsigned long pRoiHeight=0, OFBool pUsePixelValues=OFTrue, OFBool pUseModalityRescale=OFFalse, OFBool pAcceptWrongPaletteTags=OFFalse, OFBool pAcrNemaCompatibility=OFFalse, OFBool pRealLossless=OFTrue)
registers encoders for all supported JPEG processes.
DJEncoderRegistration::cleanup
static void cleanup()
deregisters encoders.
DJ_RPLossless
representation parameter for lossless JPEG
Definition djrplol.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:44
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::getDataset
DcmDataset * getDataset()
get dataset part of the fileformat
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.
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:312
EXS_JPEGProcess14SV1
@ EXS_JPEGProcess14SV1
JPEG Lossless, Selection Value 1.
Definition dcxfer.h:86

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

DJDecoderRegistration::registerCodecs(); // register JPEG codecs
DcmFileFormat fileformat;
if (fileformat.loadFile("test_jpeg.dcm").good())
{
DcmDataset *dataset = fileformat.getDataset();
// decompress data set if compressed
if (dataset->chooseRepresentation(EXS_LittleEndianExplicit, NULL).good() &&
dataset->canWriteXfer(EXS_LittleEndianExplicit))
{
fileformat.saveFile("test_decompressed.dcm", EXS_LittleEndianExplicit);
}
}
DJDecoderRegistration::cleanup(); // deregister JPEG codecs
DJDecoderRegistration::cleanup
static void cleanup()
deregisters decoders.
DJDecoderRegistration::registerCodecs
static void registerCodecs(E_DecompressionColorSpaceConversion pDecompressionCSConversion=EDC_photometricInterpretation, E_UIDCreation pCreateSOPInstanceUID=EUC_default, E_PlanarConfiguration pPlanarConfiguration=EPC_default, OFBool predictor6WorkaroundEnable=OFFalse, OFBool cornellWorkaroundEnable=OFFalse, OFBool pForceSingleFragmentPerFrame=OFFalse)
registers decoders for all supported JPEG processes.
EXS_LittleEndianExplicit
@ EXS_LittleEndianExplicit
Explicit VR Little Endian.
Definition dcxfer.h:46

Generated on Sat Mar 1 2025 for DCMTK Version 3.6.9 by Doxygen 1.13.2