Nail to Nail Fingerprint Capture Challenge
API for participant-specific one-to-many template generation and template matching.
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
BiometricEvaluation::Image::Image Class Referenceabstract

Represent attributes common to all images. More...

#include <be_image_image.h>

+ Inheritance diagram for BiometricEvaluation::Image::Image:

Public Types

using statusCallback_t = std::function< void(const Framework::Status)>
 

Public Member Functions

 Image (const uint8_t *data, const uint64_t size, const Size dimensions, const uint32_t colorDepth, const uint16_t bitDepth, const Resolution resolution, const CompressionAlgorithm compression, const bool hasAlphaChannel, const std::string &identifier="", const statusCallback_t &statusCallback=Image::defaultStatusCallback)
 Parent constructor for all Image classes. More...
 
 Image (const uint8_t *data, const uint64_t size, const CompressionAlgorithm compression, const std::string &identifier="", const statusCallback_t &statusCallback=Image::defaultStatusCallback)
 Parent constructor for all Image classes. More...
 
CompressionAlgorithm getCompressionAlgorithm () const
 Accessor for the CompressionAlgorithm of the image. More...
 
Resolution getResolution () const
 Accessor for the resolution of the image. More...
 
Memory::uint8Array getData () const
 Accessor for the image data. More...
 
virtual Memory::uint8Array getRawData () const =0
 Accessor for the raw image data. More...
 
virtual Memory::uint8Array getRawData (const bool removeAlphaChannelIfPresent) const
 Accessor for the raw image data. More...
 
virtual Memory::uint8Array getRawGrayscaleData (uint8_t depth) const =0
 Accessor for decompressed data in grayscale. More...
 
Size getDimensions () const
 Accessor for the dimensions of the image in pixels. More...
 
uint32_t getColorDepth () const
 Accessor for the color depth of the image in bits. More...
 
uint16_t getBitDepth () const
 Accessor for the number of bits per color component. More...
 
bool hasAlphaChannel () const
 Accessor for the presence of an alpha channel. More...
 
statusCallback_t getStatusCallback () const
 Get handle to status callback function. More...
 
std::string getIdentifier () const
 Obtain the assigned image identifier. More...
 

Static Public Member Functions

static uint64_t valueInColorspace (uint64_t color, uint64_t maxColorValue, uint8_t depth)
 Calculate an equivalent color value for a color in an alternate colorspace. More...
 
static std::shared_ptr< ImageopenImage (const uint8_t *data, const uint64_t size, const std::string &identifier="", const statusCallback_t &statusCallback=Image::defaultStatusCallback)
 Determine the image type of a buffer of image data and create an Image object. More...
 
static std::shared_ptr< ImageopenImage (const Memory::uint8Array &data, const std::string &identifier="", const statusCallback_t &statusCallback=Image::defaultStatusCallback)
 Determine the image type of a buffer of image data and create an Image object. More...
 
static std::shared_ptr< ImageopenImage (const std::string &path, const statusCallback_t &statusCallback=Image::defaultStatusCallback)
 Determine the image type of an image file and create an Image object. More...
 
static CompressionAlgorithm getCompressionAlgorithm (const uint8_t *data, const uint64_t size)
 Determine the compression algorithm of a buffer of image data. More...
 
static CompressionAlgorithm getCompressionAlgorithm (const Memory::uint8Array &data)
 Determine the compression algorithm of a buffer of image data. More...
 
static CompressionAlgorithm getCompressionAlgorithm (const std::string &path)
 Determine the compression algorithm of a file. More...
 
static BiometricEvaluation::Image::Raw getRawImage (const std::shared_ptr< BiometricEvaluation::Image::Image > &image)
 Obtain Image::Raw version of an Image::Image. More...
 
static void defaultStatusCallback (const Framework::Status &status)
 Default handling of statuses sent from image processing libraries. More...
 

Protected Member Functions

void setResolution (const Resolution resolution)
 Mutator for the resolution of the image . More...
 
void setDimensions (const Size dimensions)
 Mutator for the dimensions of the image in pixels. More...
 
void setColorDepth (const uint32_t colorDepth)
 Mutator for the color depth of the image in bits. More...
 
void setBitDepth (const uint16_t bitDepth)
 Mutator for the number of bits per component for color components in the image, in bits. More...
 
const uint8_t * getDataPointer () const
 
uint64_t getDataSize () const
 
void setHasAlphaChannel (const bool hasAlphaChannel)
 Mutator for the presence of an alpha channel. More...
 

Detailed Description

Represent attributes common to all images.

Images are represented by their size, depth, and resolution on the X and Y axes. The image data can be of any format, raw, JPEG, etc. Implementations of this abstraction provide the getRawData method to convert image data to 'raw' format.

Image resolution is in pixels per centimeter, and the coordinate system has the origin at the upper left of the image.

Constructor & Destructor Documentation

◆ Image() [1/2]

BiometricEvaluation::Image::Image::Image ( const uint8_t *  data,
const uint64_t  size,
const Size  dimensions,
const uint32_t  colorDepth,
const uint16_t  bitDepth,
const Resolution  resolution,
const CompressionAlgorithm  compression,
const bool  hasAlphaChannel,
const std::string &  identifier = "",
const statusCallback_t &  statusCallback = Image::defaultStatusCallback 
)

Parent constructor for all Image classes.

Parameters
[in]dataThe image data.
[in]sizeThe size of the image data, in bytes.
[in]dimensionsThe width and height of the image in pixels.
[in]colorDepthThe image color depth, in bits-per-pixel.
[in]bitDepthThe number of bits per color component.
[in]resolutionThe resolution of the image
[in]compressionThe CompressionAlgorithm of data.
[in]hasAlphaChannelPresence of an alpha channel.
identifierIdentifier for the encapsulated data.
statusCallbackFunction to handle statuses sent when processing images.
Exceptions
Error::StrategyErrorError manipulating data.
Error::StrategyErrorError while creating Image.

◆ Image() [2/2]

BiometricEvaluation::Image::Image::Image ( const uint8_t *  data,
const uint64_t  size,
const CompressionAlgorithm  compression,
const std::string &  identifier = "",
const statusCallback_t &  statusCallback = Image::defaultStatusCallback 
)

Parent constructor for all Image classes.

Parameters
[in]dataThe image data.
[in]sizeThe size of the image data, in bytes.
[in]compressionThe CompressionAlgorithm of data.
identifierIdentifier for the encapsulated data.
statusCallbackFunction to handle statuses sent when processing images.
Exceptions
Error::DataErrorError manipulating data.
Error::StrategyErrorError while creating Image.

Member Function Documentation

◆ defaultStatusCallback()

static void BiometricEvaluation::Image::Image::defaultStatusCallback ( const Framework::Status &  status)
static

Default handling of statuses sent from image processing libraries.

Parameters
statusStatus received.
Exceptions
Error::StrategyErrorstatus.type == Framework::Status::Type::Error
Note
Custom implementations of signature statusCallback_t should throw an exception when status.type == Framework::Status::Type::Error.

◆ getBitDepth()

uint16_t BiometricEvaluation::Image::Image::getBitDepth ( ) const

Accessor for the number of bits per color component.

Returns
The bit depth of the image (in bits).

◆ getColorDepth()

uint32_t BiometricEvaluation::Image::Image::getColorDepth ( ) const

Accessor for the color depth of the image in bits.

Returns
The color depth of the image (bit).

◆ getCompressionAlgorithm() [1/4]

CompressionAlgorithm BiometricEvaluation::Image::Image::getCompressionAlgorithm ( ) const

Accessor for the CompressionAlgorithm of the image.

Returns
Type of compression used on the data that will be returned from getData().

◆ getCompressionAlgorithm() [2/4]

static CompressionAlgorithm BiometricEvaluation::Image::Image::getCompressionAlgorithm ( const Memory::uint8Array data)
static

Determine the compression algorithm of a buffer of image data.

Parameters
[in]dataThe image data.
Returns
Compression algorithm used in the buffer.
Attention
CompressionAlgorithm::None is returned if no compression algorithm known to the Biometric Evaluation Framework is found.

◆ getCompressionAlgorithm() [3/4]

static CompressionAlgorithm BiometricEvaluation::Image::Image::getCompressionAlgorithm ( const std::string &  path)
static

Determine the compression algorithm of a file.

Parameters
[in]pathPath to file.
Returns
Compression algorithm used in the file.
Exceptions
Error::ObjectDoesNotExistpath does not exist.
Error::StrategyErrorAn error occurred when using the underlying storage system.
Attention
CompressionAlgorithm::None is returned if no compression algorithm known to the Biometric Evaluation Framework is found.

◆ getCompressionAlgorithm() [4/4]

static CompressionAlgorithm BiometricEvaluation::Image::Image::getCompressionAlgorithm ( const uint8_t *  data,
const uint64_t  size 
)
static

Determine the compression algorithm of a buffer of image data.

Parameters
[in]dataThe image data.
[in]sizeThe size of the image data, in bytes.
Returns
Compression algorithm used in the buffer.
Attention
CompressionAlgorithm::None is returned if no compression algorithm known to the Biometric Evaluation Framework is found.

◆ getData()

Memory::uint8Array BiometricEvaluation::Image::Image::getData ( ) const

Accessor for the image data.

The data returned is likely encoded in a specialized format.

Returns
AutoArray holding image data.

◆ getDataPointer()

const uint8_t * BiometricEvaluation::Image::Image::getDataPointer ( ) const
protected
Returns
Const pointer to buffer underlying _data.

◆ getDataSize()

uint64_t BiometricEvaluation::Image::Image::getDataSize ( ) const
protected
Returns
Size of _data.

◆ getDimensions()

Size BiometricEvaluation::Image::Image::getDimensions ( ) const

Accessor for the dimensions of the image in pixels.

Returns
Coordinate object containing dimensions in pixels.

◆ getIdentifier()

std::string BiometricEvaluation::Image::Image::getIdentifier ( ) const

Obtain the assigned image identifier.

Returns
Image identifier.

◆ getRawData() [1/2]

virtual Memory::uint8Array BiometricEvaluation::Image::Image::getRawData ( ) const
pure virtual

Accessor for the raw image data.

The data returned should not be compressed or encoded.

@important Bit depth of data returned from this method is at least 8. If getBitDepth() < 8, data is losslessly converted to use 8 bits to represent a single color channel.

Returns
AutoArray holding raw image data.
Exceptions
Error::DataErrorError decompressing image data.

Implemented in BiometricEvaluation::Image::Raw.

◆ getRawData() [2/2]

virtual Memory::uint8Array BiometricEvaluation::Image::Image::getRawData ( const bool  removeAlphaChannelIfPresent) const
virtual

Accessor for the raw image data.

The data returned should not be compressed or encoded.

@important Bit depth of data returned from this method is at least 8. If getBitDepth() < 8, data is losslessly converted to use 8 bits to represent a single color channel.

Parameters
[in]removeAlphaChannelIfPresentWhether or not to remove an alpha channel if one exists.
Returns
AutoArray holding raw image data, without an alpha channel if requested.
Exceptions
Error::DataErrorError decompressing image data.
Error::ParameterErrorPropagated from Image::removeComponents.
Error::StrategyErrorPropagated from Image::removeComponents.

◆ getRawGrayscaleData()

virtual Memory::uint8Array BiometricEvaluation::Image::Image::getRawGrayscaleData ( uint8_t  depth) const
pure virtual

Accessor for decompressed data in grayscale.

Parameters
depthThe desired bit depth of the resulting raw image. This value may either be 16, 8, or 1.
Returns
AutoArray holding raw grayscale image data.
Exceptions
Error::DataErrorError decompressing image data.
Error::NotImplementedUnsupported conversion based on source color depth.
Error::ParameterErrorInvalid value for depth.
Note
This method does not save a cached copy of the decompressed image because the bit depth of the image can be changed between calls.
When depth is 1, this method returns an image that uses 8 bits to represent a single pixel. The depth parameter is used to adjust the number of gray levels. When depth is 1, there are only 2 gray levels (black and white), despite using 8 bits to represent each pixel.
Alpha channels are completely ignored when converting to grayscale.

Implemented in BiometricEvaluation::Image::Raw.

◆ getRawImage()

static BiometricEvaluation::Image::Raw BiometricEvaluation::Image::Image::getRawImage ( const std::shared_ptr< BiometricEvaluation::Image::Image > &  image)
static

Obtain Image::Raw version of an Image::Image.

Parameters
[in]imageShared pointer to an Image::Image.
Returns
Shared pointer to an Image::Raw version of image.
Note
If image is already an Image::Raw, image is returned to avoid a copy.

◆ getResolution()

Resolution BiometricEvaluation::Image::Image::getResolution ( ) const

Accessor for the resolution of the image.

Returns
Resolution struct

◆ getStatusCallback()

statusCallback_t BiometricEvaluation::Image::Image::getStatusCallback ( ) const

Get handle to status callback function.

Returns
Status callback function.

◆ hasAlphaChannel()

bool BiometricEvaluation::Image::Image::hasAlphaChannel ( ) const
inline

Accessor for the presence of an alpha channel.

Returns
Whether or not an alpha channel is present.

◆ openImage() [1/3]

static std::shared_ptr< Image > BiometricEvaluation::Image::Image::openImage ( const Memory::uint8Array data,
const std::string &  identifier = "",
const statusCallback_t &  statusCallback = Image::defaultStatusCallback 
)
static

Determine the image type of a buffer of image data and create an Image object.

Parameters
[in]dataThe image data.
identifierIdentifier for the encapsulated data.
statusCallbackFunction to handle statuses sent when processing images.
Returns
Image representation of the input data buffer.
Exceptions
Error::DataErrorError manipulating data.
Error::StrategyErrorError while creating Image.

◆ openImage() [2/3]

static std::shared_ptr< Image > BiometricEvaluation::Image::Image::openImage ( const std::string &  path,
const statusCallback_t &  statusCallback = Image::defaultStatusCallback 
)
static

Determine the image type of an image file and create an Image object.

Parameters
[in]pathPath to image data.
statusCallbackFunction to handle statuses sent when processing images.
Returns
Image representation of the input data buffer.
Exceptions
Error::DataErrorError manipulating data.
Error::ObjectDoesNotExistNo file at specified path.
Error::StrategyErrorError while creating Image.

◆ openImage() [3/3]

static std::shared_ptr< Image > BiometricEvaluation::Image::Image::openImage ( const uint8_t *  data,
const uint64_t  size,
const std::string &  identifier = "",
const statusCallback_t &  statusCallback = Image::defaultStatusCallback 
)
static

Determine the image type of a buffer of image data and create an Image object.

Parameters
[in]dataThe image data.
[in]sizeThe size of the image data, in bytes.
identifierIdentifier for the encapsulated data.
statusCallbackFunction to handle statuses sent when processing images.
Returns
Image representation of the input data buffer.
Exceptions
Error::DataErrorError manipulating data.
Error::StrategyErrorError while creating Image.

◆ setBitDepth()

void BiometricEvaluation::Image::Image::setBitDepth ( const uint16_t  bitDepth)
protected

Mutator for the number of bits per component for color components in the image, in bits.

Parameters
[in]bitDepthThe number of bits per color component.

◆ setColorDepth()

void BiometricEvaluation::Image::Image::setColorDepth ( const uint32_t  colorDepth)
protected

Mutator for the color depth of the image in bits.

Parameters
[in]colorDepthThe color depth of the image (bit).

◆ setDimensions()

void BiometricEvaluation::Image::Image::setDimensions ( const Size  dimensions)
protected

Mutator for the dimensions of the image in pixels.

Parameters
[in]dimensionsDimensions of image (pixel).

◆ setHasAlphaChannel()

void BiometricEvaluation::Image::Image::setHasAlphaChannel ( const bool  hasAlphaChannel)
inlineprotected

Mutator for the presence of an alpha channel.

Parameters
[in]hasAlphaChannelWhether or not image has an alpha channel.

◆ setResolution()

void BiometricEvaluation::Image::Image::setResolution ( const Resolution  resolution)
protected

Mutator for the resolution of the image .

Parameters
[in]resolutionResolution struct.

◆ valueInColorspace()

static uint64_t BiometricEvaluation::Image::Image::valueInColorspace ( uint64_t  color,
uint64_t  maxColorValue,
uint8_t  depth 
)
static

Calculate an equivalent color value for a color in an alternate colorspace.

Parameters
colorValue for color in original colorspace.
maxColorValueMaximum value for colors in original colorspace.
depthDesired bit-depth of the new colorspace.
Returns
A value equivalent to color in depth-bit space.