DCMTK  Version 3.6.6
OFFIS DICOM Toolkit
Static Public Member Functions | List of all members
DcmSegUtils Class Reference

Class that contains helper functionality for the dcmseg module. More...

Static Public Member Functions

static DcmIODTypes::FramepackBinaryFrame (const Uint8 *pixelData, const Uint16 rows, const Uint16 columns)
 Pack the given segmentation pixel data, provided "unpacked", into the packed format expected by DICOM. More...
 
static size_t getBytesForBinaryFrame (const size_t &numPixels)
 Compute the number of bytes required for a binary pixel data frame, given the number of pixels. More...
 
static DcmIODTypes::FrameunpackBinaryFrame (const DcmIODTypes::Frame *frame, Uint16 rows, Uint16 cols)
 Unpacks a binary segmentation frame into a "sparse" pixel data frame where every resulting byte represents a single bit of the frame being either 0 (not set) or 1 (set). More...
 
static void alignFrameOnBitPosition (Uint8 *buf, const size_t bufLen, const Uint8 numBits)
 Aligns 1 bit per pixel frame data to make the frame start at a specific bit position within the first byte. More...
 
static void alignFrameOnByteBoundary (Uint8 *buf, const size_t bufLen, const Uint8 numBits)
 Aligns 1 bit per pixel frame data starting at a given bit position in the provided buffer with the start of that buffer. More...
 
static OFString debugByte2Bin (Uint8 b)
 Dumps a byte as binary number to a string. More...
 
static void debugDumpBin (Uint8 *buffer, size_t length, const char *what)
 Dumps a memory block byte for byte to the debug log stream. More...
 

Detailed Description

Class that contains helper functionality for the dcmseg module.

Member Function Documentation

◆ alignFrameOnBitPosition()

static void DcmSegUtils::alignFrameOnBitPosition ( Uint8 *  buf,
const size_t  bufLen,
const Uint8  numBits 
)
static

Aligns 1 bit per pixel frame data to make the frame start at a specific bit position within the first byte.

This is used in the context that dcmseg holds the frames in memory aligned to exact byte positions, while the DICOM encoding might require a frame to start at an arbitrary bit position since all (1 bit per pixel) frames are directly concatenated one after another (i.e. if one frame does not occupy a number of bits dividable by 8, not all frames will be aligned at exact byte positions). Note that each byte is filled from the right, i.e. the first pixel will represented by the bit at the very right of the first byte, and the 9th pixel will be in the very right position of the following byte. This is not a regular bit shift operation since the bits from the previous frame are on the left of the byte, but must be aligned at the right. The current frame starts from the first bit, occupying the unused bits of the last frame and then continuing in the next byte at the first bit from the left. Example for two bit shift: Input buffer bytes: hgfedcba 87654321 Result: fedcba00 654321hg The 00 in the first byte must be handled by the caller (will contain the two bits of the previous frame). See also dcmseg/tests/tutils.cc for more examples.

Parameters
bufThe address of the memory buffer to shift
bufLenThe length of the buf memory block in bytes
numBitsThe number of bits to shift. Must be 0 <= numBits <= 7.

◆ alignFrameOnByteBoundary()

static void DcmSegUtils::alignFrameOnByteBoundary ( Uint8 *  buf,
const size_t  bufLen,
const Uint8  numBits 
)
static

Aligns 1 bit per pixel frame data starting at a given bit position in the provided buffer with the start of that buffer.

This is used to create a frame structure where all the bytes (including the first one) only contain data from the frame at hand. Note that each byte is filled from the right, i.e. the first pixel will represented by the bit at the very right of the first byte, and the 9th pixel will be in the very right position of the following byte. Example: 3 bytes input buffer: edcbaZYX mlkjihgf utsrqpon Result after aligning 3 bits: fghedcba ponmlkji 000utsrq The 000 are unused bits and therefore zeroed out in the last byte. Bits ZYX will be shifted out which is ok since it does not belong to the current frame. See also dcmseg/tests/tutils.cc for more examples.

Parameters
bufThe address of the memory buffer to shift
bufLenThe length of the buf memory block in bytes
numBitsThe number of bits to shift. Must be 0 <= numBits <= 7.

◆ debugByte2Bin()

static OFString DcmSegUtils::debugByte2Bin ( Uint8  b)
static

Dumps a byte as binary number to a string.

Only useful for debugging purposes.

Parameters
bThe byte to dump
Returns
A string containing b as a binary number

◆ debugDumpBin()

static void DcmSegUtils::debugDumpBin ( Uint8 *  buffer,
size_t  length,
const char *  what 
)
static

Dumps a memory block byte for byte to the debug log stream.

Only useful for debugging purposes.

Parameters
bufferThe address of the memory block to dump
lengthThe length of memory to be dumped
whatString describing what is dumped.

◆ getBytesForBinaryFrame()

static size_t DcmSegUtils::getBytesForBinaryFrame ( const size_t &  numPixels)
static

Compute the number of bytes required for a binary pixel data frame, given the number of pixels.

Parameters
numPixelsThe total number of pixels
Returns
The number of bytes required to pack the data into a binary segmentation frame

◆ packBinaryFrame()

static DcmIODTypes::Frame* DcmSegUtils::packBinaryFrame ( const Uint8 *  pixelData,
const Uint16  rows,
const Uint16  columns 
)
static

Pack the given segmentation pixel data, provided "unpacked", into the packed format expected by DICOM.

Parameters
pixelDataPixel data in unpacked format
rowsNumber of rows in the pixel data
columnsThe number of columns in the pixel data
Returns
The frame data if successful, NULL if an error occurs

◆ unpackBinaryFrame()

static DcmIODTypes::Frame* DcmSegUtils::unpackBinaryFrame ( const DcmIODTypes::Frame frame,
Uint16  rows,
Uint16  cols 
)
static

Unpacks a binary segmentation frame into a "sparse" pixel data frame where every resulting byte represents a single bit of the frame being either 0 (not set) or 1 (set).

Parameters
frameThe input buffer with the frame in packed format
rowsThe rows of the frame
colsThe cols of the frame
Returns
The segmentation frame in unpacked format. NULL in case of error.

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


Generated on Thu Jan 14 2021 for DCMTK Version 3.6.6 by Doxygen 1.8.18