DCMTK: DJLSEncoderBase Class Reference

DCMTK Version 3.6.9 OFFIS DICOM Toolkit

Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Static Private Member Functions | List of all members
DJLSEncoderBase Class Referenceabstract

abstract codec class for JPEG-LS encoders. More...

Inheritance diagram for DJLSEncoderBase:

## Public Member Functions
| DJLSEncoderBase ()
| default constructor
virtual | ~DJLSEncoderBase ()
| 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.
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.
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.
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.
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
virtual OFCondition | determineDecompressedColorModel (const DcmRepresentationParameter *fromParam, DcmPixelSequence *fromPixSeq, const DcmCodecParameter *cp, DcmItem *dataset, OFString &decompressedColorModel) const
| determine color model of the decompressed image
Public Member Functions inherited from DcmCodec
| DcmCodec ()
| default constructor
virtual | ~DcmCodec ()
| destructor

## Private Member Functions
virtual E_TransferSyntax | supportedTransferSyntax () const =0
| returns the transfer syntax that this particular codec is able to encode
OFCondition | losslessRawEncode (const Uint16 *pixelData, const Uint32 length, DcmItem *dataset, const DJLSRepresentationParameter *djrp, DcmPixelSequence *&pixSeq, const DJLSCodecParameter *djcp, double &compressionRatio) const
| lossless encoder that compresses the complete pixel cell (very much like the RLE encoder in module dcmdata).
OFCondition | losslessCookedEncode (const Uint16 *pixelData, const Uint32 length, DcmItem *dataset, const DJLSRepresentationParameter *djrp, DcmPixelSequence *&pixSeq, const DJLSCodecParameter *djcp, double &compressionRatio, Uint16 nearLosslessDeviation) const
| lossless encoder that moves Overlays to (60xx,3000) and only compresses the stored bits of the pixel cell.
OFCondition | adjustOverlays (DcmItem *dataset, DicomImage &image) const
| for all overlay groups create (60xx,3000) Overlay Data.
OFCondition | updateLossyCompressionRatio (DcmItem *dataset, double ratio) const
| create Lossy Image Compression and Lossy Image Compression Ratio.
OFCondition | updateDerivationDescription (DcmItem *dataset, const DJLSRepresentationParameter *djrp, double ratio) const
| create Derivation Description.
OFCondition | compressRawFrame (const Uint8 *framePointer, Uint16 bitsAllocated, Uint16 columns, Uint16 rows, Uint16 samplesPerPixel, Uint16 planarConfiguration, const OFString &photometricInterpretation, DcmPixelSequence *pixelSequence, DcmOffsetList &offsetList, unsigned long &compressedSize, const DJLSCodecParameter *djcp) const
| perform the lossless raw compression of a single frame
OFCondition | compressCookedFrame (DcmPixelSequence *pixelSequence, DicomImage *dimage, const OFString &photometricInterpretation, DcmOffsetList &offsetList, unsigned long &compressedSize, const DJLSCodecParameter *djcp, Uint32 frame, Uint16 nearLosslessDeviation) const
| perform the lossless cooked compression of a single frame
OFCondition | convertToUninterleaved (Uint8 *target, const Uint8 *source, Uint16 components, Uint32 width, Uint32 height, Uint16 bitsAllocated) const
| Convert an image from sample interleaved to uninterleaved.
OFCondition | convertToSampleInterleaved (Uint8 *target, const Uint8 *source, Uint16 components, Uint32 width, Uint32 height, Uint16 bitsAllocated) const
| Convert an image from uninterleaved to sample interleaved.

## Static Private Member Functions
static void | fixPaddingIfNecessary (Uint8 *buffer, size_t bufSize, unsigned long &bytesWritten, OFBool useFFpadding)
| Adjust the padding of the JPEG-LS bitstream in the buffer if it has odd length, such that the End of Image (EOI) marker ends on an even byte boundary.
static void | setCustomParameters (JlsCustomParameters &custom, Uint16 bitsAllocated, Uint16 nearLosslessDeviation, const DJLSCodecParameter *djcp)
| compute the parameters for the CharLS JlsCustomParameters struct, which maintains the JPEG-LS encoding process parameters T1, T2, T3, MAXVAL and RESET.

## 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.
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.
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)
static OFCondition | updateImageType (DcmItem *dataset)
| update value of the Image Type element (if needed).
static OFCondition | insertCodeSequence (DcmItem *dataset, const DcmTagKey &tagKey, const char *codingSchemeDesignator, const char *codeValue, const char *codeMeaning)
| insert code sequence into the given dataset
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)

## Detailed Description

abstract codec class for JPEG-LS encoders.

This abstract class contains most of the application logic needed for a dcmdata codec object that implements a JPEG-LS encoder This class only supports compression, it neither implements decoding nor transcoding.

## Member Function Documentation

## ◆ adjustOverlays()

OFCondition DJLSEncoderBase::adjustOverlays | ( | DcmItem * | dataset,
|  | DicomImage & | image ) const
| private

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

Parameters

  dataset | dataset to be modified
  image | DicomImage object for this dataset

Returns
  EC_Normal if successful, an error code otherwise

## ◆ canChangeCoding()

virtual OFBool DJLSEncoderBase::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

  oldRepType | current transfer syntax
  newRepType | desired new transfer syntax

Returns
  true if transformation is supported by this codec, false otherwise.

Implements DcmCodec.

## ◆ compressCookedFrame()

OFCondition DJLSEncoderBase::compressCookedFrame | ( | DcmPixelSequence * | pixelSequence,
|  | DicomImage * | dimage,
|  | const OFString & | photometricInterpretation,
|  | DcmOffsetList & | offsetList,
|  | unsigned long & | compressedSize,
|  | const DJLSCodecParameter * | djcp,
|  | Uint32 | frame,
|  | Uint16 | nearLosslessDeviation ) const
| private

perform the lossless cooked compression of a single frame

Parameters

  pixelSequence | object in which the compressed frame is stored
  dimage | DicomImage instance used to process frame
  photometricInterpretation | photometric interpretation of the DICOM dataset
  offsetList | list of frame offsets updated in this parameter
  compressedSize | size of compressed frame returned in this parameter
  djcp | parameters for the codec
  frame | frame index
  nearLosslessDeviation | maximum deviation for near-lossless encoding

Returns
  EC_Normal if successful, an error code otherwise

## ◆ compressRawFrame()

OFCondition DJLSEncoderBase::compressRawFrame | ( | const Uint8 * | framePointer,
|  | Uint16 | bitsAllocated,
|  | Uint16 | columns,
|  | Uint16 | rows,
|  | Uint16 | samplesPerPixel,
|  | Uint16 | planarConfiguration,
|  | const OFString & | photometricInterpretation,
|  | DcmPixelSequence * | pixelSequence,
|  | DcmOffsetList & | offsetList,
|  | unsigned long & | compressedSize,
|  | const DJLSCodecParameter * | djcp ) const
| private

perform the lossless raw compression of a single frame

Parameters

  framePointer | pointer to start of frame
  bitsAllocated | number of bits allocated per pixel
  columns | frame width
  rows | frame height
  samplesPerPixel | image samples per pixel
  planarConfiguration | image planar configuration
  photometricInterpretation | photometric interpretation of the DICOM dataset
  pixelSequence | object in which the compressed frame is stored
  offsetList | list of frame offsets updated in this parameter
  compressedSize | size of compressed frame returned in this parameter
  djcp | parameters for the codec

Returns
  EC_Normal if successful, an error code otherwise

## ◆ convertToSampleInterleaved()

OFCondition DJLSEncoderBase::convertToSampleInterleaved | ( | Uint8 * | target,
|  | const Uint8 * | source,
|  | Uint16 | components,
|  | Uint32 | width,
|  | Uint32 | height,
|  | Uint16 | bitsAllocated ) const
| private

Convert an image from uninterleaved to sample interleaved.

Parameters

  target | A buffer where the converted image will be stored
  source | The image buffer to be converted
  components | Color components used in the image
  width | The width of the image.
  height | The height of the image.
  bitsAllocated | The number of bits allocated in the image.

Returns
  EC_Normal if successful, an error code otherwise

## ◆ convertToUninterleaved()

OFCondition DJLSEncoderBase::convertToUninterleaved | ( | Uint8 * | target,
|  | const Uint8 * | source,
|  | Uint16 | components,
|  | Uint32 | width,
|  | Uint32 | height,
|  | Uint16 | bitsAllocated ) const
| private

Convert an image from sample interleaved to uninterleaved.

Parameters

  target | A buffer where the converted image will be stored
  source | The image buffer to be converted
  components | Color components used in the image
  width | The width of the image
  height | The height of the image
  bitsAllocated | The number of bits allocated in the image.

Returns
  EC_Normal if successful, an error code otherwise

## ◆ decode()

virtual OFCondition DJLSEncoderBase::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

  fromRepParam | current representation parameter of compressed data, may be NULL
  pixSeq | compressed pixel sequence
  uncompressedPixelData | uncompressed pixel data stored in this element
  cp | codec parameters for this codec
  objStack | stack pointing to the location of the pixel data element in the current dataset.
  removeOldRep | boolean 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 DJLSEncoderBase::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

  fromParam | representation parameter of current compressed representation, may be NULL.
  fromPixSeq | compressed pixel sequence
  cp | codec parameters for this codec
  dataset | pointer to dataset in which pixel data element is contained
  frameNo | number of frame, starting with 0 for the first frame
  startFragment | index 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.
  buffer | pointer to buffer where frame is to be stored
  bufSize | size of buffer in bytes
  decompressedColorModel | upon 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 DJLSEncoderBase::determineDecompressedColorModel | ( | const DcmRepresentationParameter * | fromParam,
|  | DcmPixelSequence * | fromPixSeq,
|  | const DcmCodecParameter * | cp,
|  | DcmItem * | dataset,
|  | OFString & | decompressedColorModel ) const
| virtual

determine color model of the decompressed image

Parameters

  fromParam | representation parameter of current compressed representation, may be NULL
  fromPixSeq | compressed pixel sequence
  cp | codec parameters for this codec
  dataset | pointer to dataset in which pixel data element is contained
  dataset | pointer to DICOM dataset in which this pixel data object is located. Used to access photometric interpretation.
  decompressedColorModel | upon 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 DJLSEncoderBase::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

  fromRepType | current transfer syntax of the compressed image
  fromRepParam | current representation parameter of compressed data, may be NULL
  fromPixSeq | compressed pixel sequence
  toRepParam | representation parameter describing the desired new compressed representation (e.g. JPEG quality)
  toPixSeq | compressed pixel sequence (pointer to new DcmPixelSequence object allocated on heap) returned in this parameter upon success.
  cp | codec parameters for this codec
  objStack | stack pointing to the location of the pixel data element in the current dataset.
  removeOldRep | boolean 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 DJLSEncoderBase::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

  pixelData | pointer to the uncompressed image data in OW format and local byte order
  length | of the pixel data field in bytes
  toRepParam | representation parameter describing the desired compressed representation (e.g. JPEG quality)
  pixSeq | compressed pixel sequence (pointer to new DcmPixelSequence object allocated on heap) returned in this parameter upon success.
  cp | codec parameters for this codec
  objStack | stack pointing to the location of the pixel data element in the current dataset.
  removeOldRep | boolean 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.

## ◆ fixPaddingIfNecessary()

static void DJLSEncoderBase::fixPaddingIfNecessary | ( | Uint8 * | buffer,
|  | size_t | bufSize,
|  | unsigned long & | bytesWritten,
|  | OFBool | useFFpadding )
| staticprivate

Adjust the padding of the JPEG-LS bitstream in the buffer if it has odd length, such that the End of Image (EOI) marker ends on an even byte boundary.

Parameters

  buffer | pointer to buffer containing compressed JPEG-LS bitstream
  bufSize | size of the buffer in bytes
  bytesWritten | number of bytes written to buffer; value is increased if this method adds a pad byte.
  useFFpadding | true if a standard-conforming extended EOI marker should be used for padding an odd-length bitstream

## ◆ losslessCookedEncode()

OFCondition DJLSEncoderBase::losslessCookedEncode | ( | const Uint16 * | pixelData,
|  | const Uint32 | length,
|  | DcmItem * | dataset,
|  | const DJLSRepresentationParameter * | djrp,
|  | DcmPixelSequence *& | pixSeq,
|  | const DJLSCodecParameter * | djcp,
|  | double & | compressionRatio,
|  | Uint16 | nearLosslessDeviation ) const
| private

lossless encoder that moves Overlays to (60xx,3000) and only compresses the stored bits of the pixel cell.

Parameters

  pixelData | pointer to the uncompressed image data in OW format and local byte order
  length | of the pixel data field in bytes
  dataset | pointer to dataset containing image pixel module
  djrp | representation parameter
  pixSeq | pixel sequence to write to
  djcp | codec parameter
  compressionRatio | compression ratio returned upon success
  nearLosslessDeviation | maximum deviation for near-lossless encoding

Returns
  EC_Normal if successful, an error code otherwise.

## ◆ losslessRawEncode()

OFCondition DJLSEncoderBase::losslessRawEncode | ( | const Uint16 * | pixelData,
|  | const Uint32 | length,
|  | DcmItem * | dataset,
|  | const DJLSRepresentationParameter * | djrp,
|  | DcmPixelSequence *& | pixSeq,
|  | const DJLSCodecParameter * | djcp,
|  | double & | compressionRatio ) const
| private

lossless encoder that compresses the complete pixel cell (very much like the RLE encoder in module dcmdata).

Parameters

  pixelData | pointer to the uncompressed image data in OW format and local byte order
  length | of the pixel data field in bytes
  dataset | pointer to dataset containing image pixel module
  djrp | representation parameter
  pixSeq | pixel sequence to write to
  djcp | codec parameter
  compressionRatio | compression ratio returned upon success

Returns
  EC_Normal if successful, an error code otherwise.

## ◆ setCustomParameters()

static void DJLSEncoderBase::setCustomParameters | ( | JlsCustomParameters & | custom,
|  | Uint16 | bitsAllocated,
|  | Uint16 | nearLosslessDeviation,
|  | const DJLSCodecParameter * | djcp )
| staticprivate

compute the parameters for the CharLS JlsCustomParameters struct, which maintains the JPEG-LS encoding process parameters T1, T2, T3, MAXVAL and RESET.

Parameters

  custom | reference to initialized JlsCustomParameters object, values filled by this method
  bitsAllocated | number of bits allocated
  nearLosslessDeviation | parameter NEAR of near-lossless mode
  djcp | parameters for the codec

## ◆ supportedTransferSyntax()

virtual E_TransferSyntax DJLSEncoderBase::supportedTransferSyntax | ( |  | ) | const
| privatepure virtual

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

Returns
  supported transfer syntax

Implemented in DJLSLosslessEncoder, and DJLSNearLosslessEncoder.

## ◆ updateDerivationDescription()

OFCondition DJLSEncoderBase::updateDerivationDescription | ( | DcmItem * | dataset,
|  | const DJLSRepresentationParameter * | djrp,
|  | double | ratio ) const
| private

create Derivation Description.

Parameters

  dataset | dataset to be modified
  djrp | representation parameter passed to encode()
  ratio | image compression ratio > 1. This is 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()

OFCondition DJLSEncoderBase::updateLossyCompressionRatio | ( | DcmItem * | dataset,
|  | double | ratio ) const
| private

create Lossy Image Compression and Lossy Image Compression Ratio.

Parameters

  dataset | dataset to be modified
  ratio | image compression ratio > 1. This is 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:

- dcmjpls/include/dcmtk/dcmjpls/djcodece.h

Generated on Wed Apr 30 2025 for DCMTK Version 3.6.9 by Doxygen 1.13.2