Imaging classes

Image

class Image

Represents a DICOM image.

The class manages an uncompressed DICOM image. Images are compressed when they are inserted into the DataSet via DataSet::setImage() and are decompressed when they are referenced by the Image class.

The image is stored in a contiguous area of memory: each channel’s value can occupy 1, 2 or 4 bytes, according to the Image’s data type.

Channels’ values are always interleaved in the Image class, regardless of how they are stored in the DataSet object.

Public Functions

Image(std::uint32_t width, std::uint32_t height, bitDepth_t depth, const std::string &colorSpace, std::uint32_t highBit)

Constructor.

The memory for the image is not allocated by the constructor but only when a WritingDataHandler is requested with getWritingDataHandler().

Parameters
  • width: the image width, in pixels
  • height: the image height, in pixels
  • depth: the channel values data types
  • colorSpace: the Image’s color space
  • highBit: the highest bit occupied by the channels’ values

virtual ~Image()

Destructor.

double getWidthMm() const

Retrieve the image’s width, in millimiters.

Return
the image’s width, in millimiters

double getHeightMm() const

Retrieve the image’s height, in millimiters.

Return
the image’s height, in millimiters

void setSizeMm(double width, double height)

Set the image’s size, in millimiters.

Parameters
  • width: the image’s width, in millimiters
  • height: the image’s height, in millimiters

std::uint32_t getWidth() const

Retrieve the image’s width, in pixels.

Return
the image’s width, in pixels

std::uint32_t getHeight() const

Retrieve the image’s height, in pixels.

Return
the image’s height, in pixels

ReadingDataHandlerNumeric *getReadingDataHandler() const

Retrieve a ReadingDataHandlerNumeric object referencing the Image’s memory (read only).

The memory referenced by ReadingDataHandlerNumeric contains all the image’s values. The color channels are interleaved.

Return
a ReadingDataHandlerNumeric object referencing the Image’s memory in read-only mode

WritingDataHandlerNumeric *getWritingDataHandler()

Retrieve a WritingDataHandlerNumeric object referencing the Image’s memory (mutable).

The memory referenced by the WritingDataHandlerNumeric object is uninitialized.

When the WritingDataHandlerNumeric is destroyed then the memory managed by the WritingDataHandlerNumeric object replaces the old Image’s memory.

Return
a WritingDataHandlerNumeric object referencing an uninitialized memory buffer that the client has to fill the the image’s data

std::string getColorSpace() const

Retrieve the Image’s color space.

Return
the Image’s color space

std::uint32_t getChannelsNumber() const

Return the number of color channels contained by the image.

Return
the number of color channel contained by the image

bitDepth_t getDepth() const

Return the type of the channels’ values.

Return
the type of the channels’ values

std::uint32_t getHighBit() const

Return the highest bit occupied by the channels’ values.

Return
the highest bit occupied by the channels’ values

DrawBitmap

class DrawBitmap

DrawBitmap takes care of converting an Image object into an array of bytes that can be displayed by the operating system facilities.

DrawBitmap can apply several transformations to the Image before generating the bitmap.

DrawBitmap applies automatically the necessary color transform and high bit shift in order to obtain a 8 bits per channel RGB image.

Public Functions

DrawBitmap()

Construct a DrawBitmap with no transforms.

The getBitmap() method will not apply any Transform to the Image before generating the bitmap.

DrawBitmap(const Transform &transformsChain)

Construct a DrawBitmap object that always apply the transforms in the specified TransformsChain before calculating the bitmap of the Image in the getBitmap() method.

Parameters
  • transformsChain: the transforms to apply to the Image in the getBitmap() method

virtual ~DrawBitmap()

Destructor.

size_t getBitmap(const Image &image, drawBitmapType_t drawBitmapType, std::uint32_t rowAlignBytes, char *destination, size_t destinationSize)

Apply the transforms defined in the constructor (if any) to the input image, then calculate an array of bytes containing a bitmap that can be rendered by the operating system.

Return
the number of bytes occupied by the bitmap in the pre-allocated buffer. If the number of occupied bytes is bigger than the value of the parameter bufferSize then the method doesn’t generate the bitmap
Parameters
  • image: the image for which the bitmap must be calculated
  • drawBitmapType: the type of bitmap to generate
  • rowAlignBytes: the number of bytes on which the bitmap rows are aligned
  • destination: a pointer to the pre-allocated buffer where getBitmap() will store the generated bitmap
  • destinationSize: the size of the allocated buffer

ReadWriteMemory *getBitmap(const Image &image, drawBitmapType_t drawBitmapType, std::uint32_t rowAlignBytes)

Apply the transforms defined in the constructor (if any) to the input image, then calculate an array of bytes containing a bitmap that can be rendered by the operating system.

Return
a ReadWriteMemory object referencing the buffer containing the generated bitmap
Parameters
  • image: the image for which the bitmap must be calculated
  • drawBitmapType: the type of bitmap to generate
  • rowAlignBytes: the number of bytes on which the bitmap rows are aligned