Imaging classes

Introduction

The classes described in this chapter are used to store and render images.

The following classes are described in this chapter:

C++ class Objective-C/Swift class Description
imebra::Image ImebraImage Stores a decompressed image
imebra::DrawBitmap ImebraDrawBitmap Render an image into a bitmap

Images can be obtained from a DataSet object by calling the getImage or getImageApplyModality methods.

Before being rendered, an image may be processed by one or more Transforms classes.

Image storage

Image

C++

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

Objective-C/Swift

class ImebraImage : public NSObject

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

id ImebraImage::initWithWidth:height:depth:colorSpace:highBit:(unsigned int width, unsigned int height, ImebraBitDepth_t depth, NSString * colorSpace, unsigned int highBit)

Initializer.

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

ImebraReadingDataHandlerNumeric* ImebraImage::getReadingDataHandler:(NSError ** pError)

Retrieve a ImebraReadingDataHandlerNumeric object referencing the image’s memory (read only).

The memory referenced by ImageReadingDataHandlerNumeric contains all the image’s pixels. The color channels are interleaved.

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

ImebraWritingDataHandlerNumeric* ImebraImage::getWritingDataHandler:(NSError ** pError)

Retrieve a ImebraWritingDataHandlerNumeric object referencing the image’s memory (mutable).

The memory referenced by the ImebraWritingDataHandlerNumeric object is uninitialized.

When the ImebraWritingDataHandlerNumeric object is destroyed then the memory managed by the handler replaces the old image’s memory.

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

Property

property ImebraImage::widthMm

Image’s width, in millimiters.

property ImebraImage::heightMm

Image’s height, in millimiters.

property ImebraImage::width

Retrieve the image’s width, in pixels.

property ImebraImage::height

Retrieve the image’s height, in pixels.

property ImebraImage::colorSpace

Retrieve the Image’s color space.

property ImebraImage::getChannelsNumber

Return the number of color channels contained by the image.

property ImebraImage::getDepth

Return the type of the channels’ values.

property ImebraImage::getHighBit

Return the highest bit occupied by the channels’ values.

Image rendering

DrawBitmap

C++

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

Objective-C/Swift

class ImebraDrawBitmap : public NSObject

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

ImebraDrawBitmap 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

id init()

Initializes a ImebraDrawBitmap with no transforms.

The getBitmap() method will not apply any transform to the Image before generating the bitmap (except for the high bit and color space to obtain a 24bpp RGB image).

id ImebraDrawBitmap::initWithTransform:(ImebraTransform * pTransform)

Initializes a ImebraDrawBitmap object that always apply the transform specified in the parameter when calling getBitmap() or getImebraImage().

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

ImebraReadWriteMemory* ImebraDrawBitmap::getBitmap:bitmapType:rowAlignBytes:error:(ImebraImage * pImage, ImebraDrawBitmapType_t drawBitmapType, unsigned int rowAlignBytes, NSError ** pError)

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 ImebraReadWriteMemory object referencing the buffer containing the generated bitmap
Parameters
  • pImage: 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
  • pError: set to a NSError derived class in case of error

NSImage* ImebraDrawBitmap::getImebraImage:error:(ImebraImage * pImage, NSError ** pError)

Apply the transforms defined in the constructor (if any) to the input image, then return a NSImage (on OS-X) or an UIImage (on iOS).

Return
a NSImage on OS-X or an UIImage on iOS
Parameters
  • pImage: the image for which the NSImage or UIImage must be calculated
  • pError: set to a NSError derived class in case of error