DCMTK Version 3.6.7
OFFIS DICOM Toolkit
Public Member Functions | Static Protected Member Functions | Private Member Functions | Static Private Member Functions | List of all members
DJCodecEncoder Class Referenceabstract

abstract codec class for JPEG encoders. More...

+ Inheritance diagram for DJCodecEncoder:

Public Member Functions

 DJCodecEncoder ()
 default constructor
 
virtual ~DJCodecEncoder ()
 destructor
 
virtual OFCondition decode (const DcmRepresentationParameter *fromRepParam, DcmPixelSequence *pixSeq, DcmPolymorphOBOW &uncompressedPixelData, const DcmCodecParameter *cp, const DcmStack &objStack, OFBool &removeOldRep) const
 decompresses the given pixel sequence and stores the result in the given uncompressedPixelData element. More...
 
virtual OFCondition decodeFrame (const DcmRepresentationParameter *fromParam, DcmPixelSequence *fromPixSeq, const DcmCodecParameter *cp, DcmItem *dataset, Uint32 frameNo, Uint32 &startFragment, void *buffer, Uint32 bufSize, OFString &decompressedColorModel) const
 decompresses a single frame from the given pixel sequence and stores the result in the given buffer. More...
 
virtual OFCondition encode (const Uint16 *pixelData, const Uint32 length, const DcmRepresentationParameter *toRepParam, DcmPixelSequence *&pixSeq, const DcmCodecParameter *cp, DcmStack &objStack, OFBool &removeOldRep) const
 compresses the given uncompressed DICOM image and stores the result in the given pixSeq element. More...
 
virtual OFCondition encode (const E_TransferSyntax fromRepType, const DcmRepresentationParameter *fromRepParam, DcmPixelSequence *fromPixSeq, const DcmRepresentationParameter *toRepParam, DcmPixelSequence *&toPixSeq, const DcmCodecParameter *cp, DcmStack &objStack, OFBool &removeOldRep) const
 transcodes (re-compresses) the given compressed DICOM image and stores the result in the given toPixSeq element. More...
 
virtual OFBool canChangeCoding (const E_TransferSyntax oldRepType, const E_TransferSyntax newRepType) const
 checks if this codec is able to convert from the given current transfer syntax to the given new transfer syntax More...
 
virtual OFCondition determineDecompressedColorModel (const DcmRepresentationParameter *fromParam, DcmPixelSequence *fromPixSeq, const DcmCodecParameter *cp, DcmItem *dataset, OFString &decompressedColorModel) const
 determine color model of the decompressed image More...
 
virtual E_TransferSyntax supportedTransferSyntax () const =0
 returns the transfer syntax that this particular codec is able to encode and decode. More...
 
- Public Member Functions inherited from DcmCodec
 DcmCodec ()
 default constructor
 
virtual ~DcmCodec ()
 destructor
 
virtual OFCondition decode (const DcmRepresentationParameter *fromRepParam, DcmPixelSequence *pixSeq, DcmPolymorphOBOW &uncompressedPixelData, const DcmCodecParameter *cp, const DcmStack &objStack, OFBool &removeOldRep) const =0
 decompresses the given pixel sequence and stores the result in the given uncompressedPixelData element. More...
 
virtual OFCondition decodeFrame (const DcmRepresentationParameter *fromParam, DcmPixelSequence *fromPixSeq, const DcmCodecParameter *cp, DcmItem *dataset, Uint32 frameNo, Uint32 &startFragment, void *buffer, Uint32 bufSize, OFString &decompressedColorModel) const =0
 decompresses a single frame from the given pixel sequence and stores the result in the given buffer. More...
 
virtual OFCondition encode (const Uint16 *pixelData, const Uint32 length, const DcmRepresentationParameter *toRepParam, DcmPixelSequence *&pixSeq, const DcmCodecParameter *cp, DcmStack &objStack, OFBool &removeOldRep) const =0
 compresses the given uncompressed DICOM image and stores the result in the given pixSeq element. More...
 
virtual OFCondition encode (const E_TransferSyntax fromRepType, const DcmRepresentationParameter *fromRepParam, DcmPixelSequence *fromPixSeq, const DcmRepresentationParameter *toRepParam, DcmPixelSequence *&toPixSeq, const DcmCodecParameter *cp, DcmStack &objStack, OFBool &removeOldRep) const =0
 transcodes (re-compresses) the given compressed DICOM image and stores the result in the given toPixSeq element. More...
 
virtual OFBool canChangeCoding (const E_TransferSyntax oldRepType, const E_TransferSyntax newRepType) const =0
 checks if this codec is able to convert from the given current transfer syntax to the given new transfer syntax More...
 
virtual OFCondition determineDecompressedColorModel (const DcmRepresentationParameter *fromParam, DcmPixelSequence *fromPixSeq, const DcmCodecParameter *cp, DcmItem *dataset, OFString &decompressedColorModel) const =0
 determine color model of the decompressed image More...
 

Static Protected Member Functions

static void appendCompressionRatio (OFString &arg, double ratio)
 format compression ratio as string and append to given string object. More...
 
static OFCondition togglePlanarConfiguration8 (Uint8 *pixelData, const size_t numValues, const Uint16 samplesPerPixel, const Uint16 oldPlanarConfig)
 toggles Planar Configuration of 8-bit pixel data from "by pixel" to "by plane" and vice versa. More...
 
static OFCondition togglePlanarConfiguration16 (Uint16 *pixelData, const size_t numValues, const Uint16 samplesPerPixel, const Uint16 oldPlanarConfig)
 toggles Planar Configuration of 16-bit pixel data from "by pixel" to "by plane" and vice versa. More...
 

Private Member Functions

virtual OFCondition encodeColorImage (OFBool YBRmode, DcmItem *dataset, const DcmRepresentationParameter *toRepParam, DcmPixelSequence *&pixSeq, const DJCodecParameter *cp, double &compressionRatio) const
 compresses the given uncompressed DICOM color image and stores the result in the given pixSeq element. More...
 
virtual OFCondition encodeMonochromeImage (DcmItem *dataset, const DcmRepresentationParameter *toRepParam, DcmPixelSequence *&pixSeq, const DJCodecParameter *cp, double &compressionRatio) const
 compresses the given uncompressed monochrome DICOM image and stores the result in the given pixSeq element. More...
 
virtual OFCondition encodeTrueLossless (const DcmRepresentationParameter *toRepParam, DcmPixelSequence *&pixSeq, const DcmCodecParameter *cp, DcmStack &objStack) const
 compresses the given uncompressed DICOM image and stores the result in the given pixSeq element. More...
 
virtual OFCondition updateLossyCompressionRatio (DcmItem *dataset, double ratio) const
 create Lossy Image Compression and Lossy Image Compression Ratio. More...
 
virtual OFCondition updateDerivationDescription (DcmItem *dataset, const DcmRepresentationParameter *toRepParam, const DJCodecParameter *cp, Uint8 bitsPerSample, double ratio) const
 create Derivation Description. More...
 
virtual OFCondition adjustOverlays (DcmItem *dataset, DicomImage &image) const
 for all overlay groups create (60xx,3000) Overlay Data. More...
 
virtual OFBool isLosslessProcess () const =0
 returns true if the transfer syntax supported by this codec is lossless. More...
 
virtual void createDerivationDescription (const DcmRepresentationParameter *toRepParam, const DJCodecParameter *cp, Uint8 bitsPerSample, double ratio, OFString &derivationDescription) const =0
 creates 'derivation description' string after encoding. More...
 
virtual DJEncodercreateEncoderInstance (const DcmRepresentationParameter *toRepParam, const DJCodecParameter *cp, Uint8 bitsPerSample) const =0
 creates an instance of the compression library to be used for encoding/decoding. More...
 

Static Private Member Functions

static OFCondition correctVOIWindows (DcmItem *dataset, double voiOffset, double voiFactor)
 modifies all VOI window center/width settings in the image. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from DcmCodec
static OFCondition insertStringIfMissing (DcmItem *dataset, const DcmTagKey &tag, const char *val)
 helper function that inserts a string attribute with a given value into a dataset if missing in the dataset. More...
 
static OFCondition convertToSecondaryCapture (DcmItem *dataset)
 helper function that converts a dataset containing a DICOM image into a valid (standard extended) Secondary Capture object by inserting all attributes that are type 1/2 in Secondary Capture and missing in the source dataset. More...
 
static OFCondition newInstance (DcmItem *dataset, const char *purposeOfReferenceCodingScheme=NULL, const char *purposeOfReferenceCodeValue=NULL, const char *purposeOfReferenceCodeMeaning=NULL)
 create new SOP instance UID and Source Image Sequence referencing the old SOP instance (if present) More...
 
static OFCondition updateImageType (DcmItem *dataset)
 set first value of Image Type to DERIVED. More...
 
static OFCondition insertCodeSequence (DcmItem *dataset, const DcmTagKey &tagKey, const char *codingSchemeDesignator, const char *codeValue, const char *codeMeaning)
 insert code sequence into the given dataset More...
 
static OFCondition determineStartFragment (Uint32 frameNo, Sint32 numberOfFrames, DcmPixelSequence *fromPixSeq, Uint32 &currentItem)
 determine the index number (starting with zero) of the compressed pixel data fragment corresponding to the given frame (also starting with zero) More...
 

Detailed Description

abstract codec class for JPEG encoders.

This abstract class contains most of the application logic needed for a dcmdata codec object that implements a JPEG encoder using the DJEncoder interface to the underlying JPEG implementation. This class only supports compression, it neither implements decoding nor transcoding.

Member Function Documentation

◆ adjustOverlays()

virtual OFCondition DJCodecEncoder::adjustOverlays ( DcmItem dataset,
DicomImage image 
) const
privatevirtual

for all overlay groups create (60xx,3000) Overlay Data.

Parameters
datasetdataset to be modified
imageDicomImage object for this dataset
Returns
EC_Normal if successful, an error code otherwise

◆ appendCompressionRatio()

static void DJCodecEncoder::appendCompressionRatio ( OFString arg,
double  ratio 
)
staticprotected

format compression ratio as string and append to given string object.

Parameters
argstring to append to
ratiocompression ratio

◆ canChangeCoding()

virtual OFBool DJCodecEncoder::canChangeCoding ( const E_TransferSyntax  oldRepType,
const E_TransferSyntax  newRepType 
) const
virtual

checks if this codec is able to convert from the given current transfer syntax to the given new transfer syntax

Parameters
oldRepTypecurrent transfer syntax
newRepTypedesired new transfer syntax
Returns
true if transformation is supported by this codec, false otherwise.

Implements DcmCodec.

◆ correctVOIWindows()

static OFCondition DJCodecEncoder::correctVOIWindows ( DcmItem dataset,
double  voiOffset,
double  voiFactor 
)
staticprivate

modifies all VOI window center/width settings in the image.

Modifications are based on the pixel value mapping f(x) = (x+voiOffset)*voiFactor

Parameters
datasetdataset to be updated
voiOffsetoffset to be added to each pixel
voiFactorfactor to be multiplied
Returns
EC_Normal if successful, an error code otherwise

◆ createDerivationDescription()

virtual void DJCodecEncoder::createDerivationDescription ( const DcmRepresentationParameter toRepParam,
const DJCodecParameter cp,
Uint8  bitsPerSample,
double  ratio,
OFString derivationDescription 
) const
privatepure virtual

creates 'derivation description' string after encoding.

Parameters
toRepParamrepresentation parameter passed to encode()
cpcodec parameter passed to encode()
bitsPerSamplebits per sample of the original image data prior to compression
ratioimage compression ratio. This is not the "quality factor" but the real effective ratio between compressed and uncompressed image, i. e. 30 means a 30:1 lossy compression.
derivationDescriptionderivation description returned in this parameter which is initially empty

Implemented in DJEncoderBaseline, DJEncoderExtended, DJEncoderLossless, DJEncoderProgressive, DJEncoderSpectralSelection, and DJEncoderP14SV1.

◆ createEncoderInstance()

virtual DJEncoder * DJCodecEncoder::createEncoderInstance ( const DcmRepresentationParameter toRepParam,
const DJCodecParameter cp,
Uint8  bitsPerSample 
) const
privatepure virtual

creates an instance of the compression library to be used for encoding/decoding.

Parameters
toRepParamrepresentation parameter passed to encode()
cpcodec parameter passed to encode()
bitsPerSamplebits per sample for the image data
Returns
pointer to newly allocated codec object

Implemented in DJEncoderBaseline, DJEncoderExtended, DJEncoderLossless, DJEncoderProgressive, DJEncoderSpectralSelection, and DJEncoderP14SV1.

◆ decode()

virtual OFCondition DJCodecEncoder::decode ( const DcmRepresentationParameter fromRepParam,
DcmPixelSequence pixSeq,
DcmPolymorphOBOW uncompressedPixelData,
const DcmCodecParameter cp,
const DcmStack objStack,
OFBool &  removeOldRep 
) const
virtual

decompresses the given pixel sequence and stores the result in the given uncompressedPixelData element.

Parameters
fromRepParamcurrent representation parameter of compressed data, may be NULL
pixSeqcompressed pixel sequence
uncompressedPixelDatauncompressed pixel data stored in this element
cpcodec parameters for this codec
objStackstack pointing to the location of the pixel data element in the current dataset.
removeOldRepboolean flag that should be set to false before this method call and will be set to true if the codec modifies the DICOM dataset such that the pixel data of the original representation may not be usable anymore.
Returns
EC_Normal if successful, an error code otherwise.

Implements DcmCodec.

◆ decodeFrame()

virtual OFCondition DJCodecEncoder::decodeFrame ( const DcmRepresentationParameter fromParam,
DcmPixelSequence fromPixSeq,
const DcmCodecParameter cp,
DcmItem dataset,
Uint32  frameNo,
Uint32 &  startFragment,
void *  buffer,
Uint32  bufSize,
OFString decompressedColorModel 
) const
virtual

decompresses a single frame from the given pixel sequence and stores the result in the given buffer.

Parameters
fromParamrepresentation parameter of current compressed representation, may be NULL.
fromPixSeqcompressed pixel sequence
cpcodec parameters for this codec
datasetpointer to dataset in which pixel data element is contained
frameNonumber of frame, starting with 0 for the first frame
startFragmentindex of the compressed fragment that contains all or the first part of the compressed bitstream for the given frameNo. Upon successful return this parameter is updated to contain the index of the first compressed fragment of the next frame. When unknown, zero should be passed. In this case the decompression algorithm will try to determine the index by itself, which will always work if frames are decompressed in increasing order from first to last, but may fail if frames are decompressed in random order, multiple fragments per frame and multiple frames are present in the dataset, and the offset table is empty.
bufferpointer to buffer where frame is to be stored
bufSizesize of buffer in bytes
decompressedColorModelupon successful return, the color model of the decompressed image (which may be different from the one used in the compressed images) is returned in this parameter.
Returns
EC_Normal if successful, an error code otherwise.

Implements DcmCodec.

◆ determineDecompressedColorModel()

virtual OFCondition DJCodecEncoder::determineDecompressedColorModel ( const DcmRepresentationParameter fromParam,
DcmPixelSequence fromPixSeq,
const DcmCodecParameter cp,
DcmItem dataset,
OFString decompressedColorModel 
) const
virtual

determine color model of the decompressed image

Parameters
fromParamrepresentation parameter of current compressed representation, may be NULL
fromPixSeqcompressed pixel sequence
cpcodec parameters for this codec
datasetpointer to dataset in which pixel data element is contained
datasetpointer to DICOM dataset in which this pixel data object is located. Used to access photometric interpretation.
decompressedColorModelupon successful return, the color model of the decompressed image (which may be different from the one used in the compressed images) is returned in this parameter
Returns
EC_Normal if successful, an error code otherwise

Implements DcmCodec.

◆ encode() [1/2]

virtual OFCondition DJCodecEncoder::encode ( const E_TransferSyntax  fromRepType,
const DcmRepresentationParameter fromRepParam,
DcmPixelSequence fromPixSeq,
const DcmRepresentationParameter toRepParam,
DcmPixelSequence *&  toPixSeq,
const DcmCodecParameter cp,
DcmStack objStack,
OFBool &  removeOldRep 
) const
virtual

transcodes (re-compresses) the given compressed DICOM image and stores the result in the given toPixSeq element.

Parameters
fromRepTypecurrent transfer syntax of the compressed image
fromRepParamcurrent representation parameter of compressed data, may be NULL
fromPixSeqcompressed pixel sequence
toRepParamrepresentation parameter describing the desired new compressed representation (e.g. JPEG quality)
toPixSeqcompressed pixel sequence (pointer to new DcmPixelSequence object allocated on heap) returned in this parameter upon success.
cpcodec parameters for this codec
objStackstack pointing to the location of the pixel data element in the current dataset.
removeOldRepboolean flag that should be set to false before this method call and will be set to true if the codec modifies the DICOM dataset such that the pixel data of the original representation may not be usable anymore.
Returns
EC_Normal if successful, an error code otherwise.

Implements DcmCodec.

◆ encode() [2/2]

virtual OFCondition DJCodecEncoder::encode ( const Uint16 *  pixelData,
const Uint32  length,
const DcmRepresentationParameter toRepParam,
DcmPixelSequence *&  pixSeq,
const DcmCodecParameter cp,
DcmStack objStack,
OFBool &  removeOldRep 
) const
virtual

compresses the given uncompressed DICOM image and stores the result in the given pixSeq element.

Parameters
pixelDatapointer to the uncompressed image data in OW format and local byte order
lengthof the pixel data field in bytes
toRepParamrepresentation parameter describing the desired compressed representation (e.g. JPEG quality)
pixSeqcompressed pixel sequence (pointer to new DcmPixelSequence object allocated on heap) returned in this parameter upon success.
cpcodec parameters for this codec
objStackstack pointing to the location of the pixel data element in the current dataset.
removeOldRepboolean flag that should be set to false before this method call and will be set to true if the codec modifies the DICOM dataset such that the pixel data of the original representation may not be usable anymore.
Returns
EC_Normal if successful, an error code otherwise.

Implements DcmCodec.

◆ encodeColorImage()

virtual OFCondition DJCodecEncoder::encodeColorImage ( OFBool  YBRmode,
DcmItem dataset,
const DcmRepresentationParameter toRepParam,
DcmPixelSequence *&  pixSeq,
const DJCodecParameter cp,
double &  compressionRatio 
) const
privatevirtual

compresses the given uncompressed DICOM color image and stores the result in the given pixSeq element.

Parameters
YBRmodetrue if the source image has YBR_FULL or YBR_FULL_422 photometric interpretation and can thus be compressed without color space conversion.
datasetDICOM dataset containing the pixel data as well as descriptive attributes
toRepParamrepresentation parameter describing the desired compressed representation (e.g. JPEG quality)
pixSeqcompressed pixel sequence (pointer to new DcmPixelSequence object allocated on heap) returned in this parameter upon success.
cpcodec parameters for this codec
compressionRatiocompression ratio returned in this parameter if successful.
Returns
EC_Normal if successful, an error code otherwise.

◆ encodeMonochromeImage()

virtual OFCondition DJCodecEncoder::encodeMonochromeImage ( DcmItem dataset,
const DcmRepresentationParameter toRepParam,
DcmPixelSequence *&  pixSeq,
const DJCodecParameter cp,
double &  compressionRatio 
) const
privatevirtual

compresses the given uncompressed monochrome DICOM image and stores the result in the given pixSeq element.

Parameters
datasetDICOM dataset containing the pixel data as well as descriptive attributes
toRepParamrepresentation parameter describing the desired compressed representation (e.g. JPEG quality)
pixSeqcompressed pixel sequence (pointer to new DcmPixelSequence object allocated on heap) returned in this parameter upon success.
cpcodec parameters for this codec
compressionRatiocompression ratio returned in this parameter if successful.
Returns
EC_Normal if successful, an error code otherwise.

◆ encodeTrueLossless()

virtual OFCondition DJCodecEncoder::encodeTrueLossless ( const DcmRepresentationParameter toRepParam,
DcmPixelSequence *&  pixSeq,
const DcmCodecParameter cp,
DcmStack objStack 
) const
privatevirtual

compresses the given uncompressed DICOM image and stores the result in the given pixSeq element.

No colorspace conversions, modality or windowing transformations are applied to guarantee, that the quality of the source image is fully preserved.

Parameters
toRepParam- [in] representation parameter describing the desired
pixSeq- [out] compressed pixel sequence (pointer to new DcmPixelSequence object allocated on heap) returned in this parameter upon success
cp- [in] codec parameters for this codec
objStack- [in/out] stack pointing to the location of the pixel data element in the current dataset.
Returns
EC_Normal if successful, an error code otherwise.

◆ isLosslessProcess()

virtual OFBool DJCodecEncoder::isLosslessProcess ( ) const
privatepure virtual

returns true if the transfer syntax supported by this codec is lossless.

Returns
lossless flag

Implemented in DJEncoderBaseline, DJEncoderExtended, DJEncoderLossless, DJEncoderProgressive, DJEncoderSpectralSelection, and DJEncoderP14SV1.

◆ supportedTransferSyntax()

virtual E_TransferSyntax DJCodecEncoder::supportedTransferSyntax ( ) const
pure virtual

returns the transfer syntax that this particular codec is able to encode and decode.

Returns
supported transfer syntax

Implemented in DJEncoderBaseline, DJEncoderExtended, DJEncoderLossless, DJEncoderProgressive, DJEncoderSpectralSelection, and DJEncoderP14SV1.

◆ togglePlanarConfiguration16()

static OFCondition DJCodecEncoder::togglePlanarConfiguration16 ( Uint16 *  pixelData,
const size_t  numValues,
const Uint16  samplesPerPixel,
const Uint16  oldPlanarConfig 
)
staticprotected

toggles Planar Configuration of 16-bit pixel data from "by pixel" to "by plane" and vice versa.

Parameters
pixelData- [in/out] Original pixel data (input), contains pixel data with toggled Planar configuration after returning (output).
numValues- [in] The number of 16 bit values in pixelData
samplesPerPixel- [in] Number of components for one pixel
oldPlanarConfig- [in] The old Planar Configuration, that should be toggled. 0 means "by pixel", 1 "by color"
Returns
EC_Normal, if conversion was successful; error else

◆ togglePlanarConfiguration8()

static OFCondition DJCodecEncoder::togglePlanarConfiguration8 ( Uint8 *  pixelData,
const size_t  numValues,
const Uint16  samplesPerPixel,
const Uint16  oldPlanarConfig 
)
staticprotected

toggles Planar Configuration of 8-bit pixel data from "by pixel" to "by plane" and vice versa.

Parameters
pixelData- [in/out] Original pixel data (input), contains pixel data with toggled Planar configuration after returning (output).
numValues- [in] The number of 8 bit values in pixelData
samplesPerPixel- [in] Number of components for one pixel
oldPlanarConfig- [in] The old Planar Configuration, that should be toggled. 0 means "by pixel", 1 "by color"
Returns
EC_Normal, if conversion was successful; error else

◆ updateDerivationDescription()

virtual OFCondition DJCodecEncoder::updateDerivationDescription ( DcmItem dataset,
const DcmRepresentationParameter toRepParam,
const DJCodecParameter cp,
Uint8  bitsPerSample,
double  ratio 
) const
privatevirtual

create Derivation Description.

Parameters
datasetdataset to be modified
toRepParamrepresentation parameter passed to encode()
cpcodec parameter passed to encode()
bitsPerSamplebits per sample of the original image data prior to compression
ratioimage compression ratio. This is not the "quality factor" but the real effective ratio between compressed and uncompressed image, i. e. 30 means a 30:1 lossy compression.
Returns
EC_Normal if successful, an error code otherwise

◆ updateLossyCompressionRatio()

virtual OFCondition DJCodecEncoder::updateLossyCompressionRatio ( DcmItem dataset,
double  ratio 
) const
privatevirtual

create Lossy Image Compression and Lossy Image Compression Ratio.

Parameters
datasetdataset to be modified
ratioimage compression ratio > 1. This is not the "quality factor" but the real effective ratio between compressed and uncompressed image, i. e. 30 means a 30:1 lossy compression.
Returns
EC_Normal if successful, an error code otherwise

The documentation for this class was generated from the following file:


Generated on Wed Jan 4 2023 for DCMTK Version 3.6.7 by Doxygen 1.9.4