Enrollment 28.2.0
Loading...
Searching...
No Matches

Image representation. More...

#include <Image.h>

Collaboration diagram for Image:

Classes

class  ImageResampler
 Image resampler for DPI-change operations, including upsampling and downsampling. More...
class  BicubicImageResampler
 Image resampler for DPI-change operations, including upsampling and downsampling using bicubic interpolation resampling algorithm. More...
class  AreaImageResampler
 Image resampler for DPI-change operations, including upsampling and downsampling using area interpolation resampling algorithm. More...
class  NISTImageResampler
 Image resampler for DPI-change operations, including upsampling and downsampling using NIST-compliant resampling algorithm provided by NFIR library. More...

Public Types

enum class  Intersection : uint8_t {
  PARTIAL , INSIDE , OUTSIDE , NO ,
  SAME
}
 Enum define possible intersection of Image and some Object e.g. Rectangle, Circle. More...

Public Member Functions

Intersection RectangleIntersection (const Rectangle &rectangle) const
 Check intersection between rectangle and image.
Intersection CircleIntersection (const Circle &circle) const
 Check intersection between circle and image.
Intersection PointIntersection (const Point &point) const
 Checks intersection between point and image.
ImageDpi Dpi () const
 Returns image dpi.
ImageWidth Width () const
 Returns image width.
ImageHeight Height () const
 Returns image height.
std::shared_ptr< ImageEncoder > OriginalEncoder () const
 Provides original encoder to encode image to original format.
RawImage AsRawImage () const
 Converts image to RAW format that has been originally used.
RawImage AsRawGrayscale () const
 Converts image to raw grayscale format.
RawImage AsRawBGR () const
 Converts image to raw BGR format.
std::shared_ptr< Image > AsBGR () const
 Converts image to BGR format.
RawImage AsRawBGRA () const
 Converts image to raw BGRA format.
std::shared_ptr< Image > AsBGRA () const
 Converts image to BGRA format.
std::vector< uint8_t > EncodeIn (ImageEncoder &encoder) const
 Encode image in given ImageEncoder.
void SaveIn (ImageSaver &saver) const
 Save Image in given ImageSaver.
void SaveAs (const std::string &path) const
 Save Image in given path.
bool operator== (const Image &right) const
 Images are equal when has same dimensions and same content.
std::shared_ptr< Image > DrawShape (const ImageShape &shape) const
 Draws shape to new image.
std::shared_ptr< Image > CropRectangle (const Rectangle &r) const
 Crops a rectangle from the image, using a white background for any extra space.
std::shared_ptr< Image > CropRectangle (const Rectangle &r, const RGBA &background) const
 Crops a rectangle from the image, using a white background for any extra space.
std::shared_ptr< Image > CropRectangle (const Rectangle &r, const RGBA &background, const ImageDimensions &dimension) const
 Crops a rectangle and places it on a canvas of specified dimensions, using a specified background color.
std::shared_ptr< Image > ChangeDpiTo (const ImageResampler &resampler) const
 Create image using provided DPI-change configuration.
std::shared_ptr< Image > ChangeDpiTo (ImageDpi targetDpi) const
 Create image with given DPI.
std::shared_ptr< Image > Resize (float factor) const
 Resize image to new image.
std::shared_ptr< Image > ResizeToMaxDimension (ImageDimension maxDimension) const
 Resize image to new image with given max dimension.
std::shared_ptr< Image > CropAlignedRectangle (const Rectangle &r) const
 Crop rectangle and align given top left rectangle point to coordinates [0,0] in new image.
std::shared_ptr< Image > CropAlignedRectangle (const Rectangle &r, const RGBA &background) const
 Crop rectangle and align given top left rectangle point to coordinates [0,0] in new image.
std::shared_ptr< Image > CropAlignedRectangle (const Rectangle &r, const RGBA &background, const ImageDimensions &dimension) const
 Crop rectangle and align given top left rectangle point to coordinates [0,0] in new image.
std::shared_ptr< Image > CropCircle (const Circle &circle, const RGBA &background=Colors::White) const
 Copy circle to new image.
std::shared_ptr< Image > MaskImageBy (const ImageMask &mask) const
 Applies the specified mask to the image, creating a new masked image.
size_t Channels () const
 Returns the number of channels in the image.

Static Public Member Functions

static std::shared_ptr< Image > Decode (const std::vector< uint8_t > &imageData)
 Creates Image from image data with 500 DPI.
static std::shared_ptr< Image > Decode (const std::vector< uint8_t > &imageData, unsigned int dpi)
 Creates Image from image data with given dpi.
static std::shared_ptr< Image > Decode (const std::vector< uint8_t > &imageData, std::shared_ptr< ImageExecutor > executor)
 Creates Image from image data with 500 DPI.
static std::shared_ptr< Image > Decode (const std::vector< uint8_t > &imageData, unsigned int dpi, std::shared_ptr< ImageExecutor > executor)
 Creates Image from image data with given DPI.
static std::shared_ptr< Image > DecodeRawImage (const RawImage &raw, std::shared_ptr< ImageEncoder > originalEncoder=nullptr, std::shared_ptr< ImageExecutor > executor=GlobalImageExecutor::Get())
 Creates Image from raw data.
static ImageType DeduceType (const std::vector< uint8_t > &imageData)
 Deduce image type from image content.

Detailed Description

Image representation.

Member Enumeration Documentation

◆ Intersection

enum class Intersection : uint8_t
strong

Enum define possible intersection of Image and some Object e.g. Rectangle, Circle.

Enumerator
PARTIAL 

The Object and Image has intersection.

Partial intersection
INSIDE 

Object is fully in Image.

Inside intersection
OUTSIDE 

Image is fully in Object.

Outside intersection
NO 

Image and Object has no intersection.

No intersection
SAME 

Image has same dimensions and vertices coordinates as Object.

Same intersection

Member Function Documentation

◆ AsBGR()

std::shared_ptr< Image > AsBGR ( ) const
inlinenodiscard

Converts image to BGR format.

Returns
Image.
Exceptions
ImageExceptionwhen there is an processing error

References AsRawBGR(), and DecodeRawImage().

Here is the call graph for this function:

◆ AsBGRA()

std::shared_ptr< Image > AsBGRA ( ) const
inlinenodiscard

Converts image to BGRA format.

Returns
Image.
Exceptions
ImageExceptionwhen there is an processing error

References AsRawBGRA(), and DecodeRawImage().

Here is the call graph for this function:

◆ AsRawBGR()

RawImage AsRawBGR ( ) const
inlinenodiscard

Converts image to raw BGR format.

Returns
RawImage.
Exceptions
ImageExceptionwhen there is an processing error

References RawImage::BGR, Dpi(), Height(), and Width().

Referenced by AsBGR().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AsRawBGRA()

RawImage AsRawBGRA ( ) const
inlinenodiscard

Converts image to raw BGRA format.

Returns
RawImage.
Exceptions
ImageExceptionwhen there is an processing error

References RawImage::BGRA, Dpi(), Height(), and Width().

Referenced by AsBGRA().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AsRawGrayscale()

RawImage AsRawGrayscale ( ) const
inlinenodiscard

Converts image to raw grayscale format.

Returns
RawImage.
Exceptions
ImageExceptionwhen there is an processing error

References Dpi(), RawImage::GRAYSCALE, Height(), and Width().

Here is the call graph for this function:

◆ AsRawImage()

RawImage AsRawImage ( ) const
inlinenodiscard

Converts image to RAW format that has been originally used.

Returns
RawImage.
Exceptions
ImageExceptionwhen there is an processing error

References Dpi(), Height(), and Width().

Referenced by EncodeIn(), operator==(), SaveAs(), and SaveIn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ChangeDpiTo() [1/2]

std::shared_ptr< Image > ChangeDpiTo ( const ImageResampler & resampler) const
inlinenodiscard

Create image using provided DPI-change configuration.

It creates new image as result of resizing this image using a customized resizing strategy with factor targetDpi/originalDPI.

Parameters
resamplerimage resampler
Returns
image with given DPI
Exceptions
ImageExceptionwhen there is an processing error
EnrollmentInvalidArgumentExceptionwhen resize algorithm is NIST and image is not single-channel grayscale

References Image::ImageResampler::Resample().

Referenced by ChangeDpiTo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ChangeDpiTo() [2/2]

std::shared_ptr< Image > ChangeDpiTo ( ImageDpi targetDpi) const
inlinenodiscard

Create image with given DPI.

It creates new image as result of resizing this image with factor newDPI/originalDPI. The function uses Standard resizing algorithm. See BicubicImageResampler.

Parameters
targetDpiDPI of new image.
Returns
image with given DPI
Exceptions
ImageExceptionwhen there is an processing error
EnrollmentInvalidArgumentExceptionwhen targetDpi is 0

References ChangeDpiTo().

Here is the call graph for this function:

◆ Channels()

size_t Channels ( ) const
inlinenodiscard

Returns the number of channels in the image.

  • A value of 1 typically represents a grayscale image.
  • A value of 3 typically represents a color image (e.g., RGB).
  • A value of 4 typically represents a color image with transparency (e.g., RGBA).
Returns
The number of channels in the image.

◆ CircleIntersection()

Intersection CircleIntersection ( const Circle & circle) const
inlinenodiscard

Check intersection between circle and image.

Parameters
circleCircle
Returns
Image::Intersection type
Exceptions
ImageExceptionwhen there is an processing error

References Circle::center, Circle::radius, Point::x, and Point::y.

Referenced by CropCircle().

Here is the caller graph for this function:

◆ CropAlignedRectangle() [1/3]

std::shared_ptr< Image > CropAlignedRectangle ( const Rectangle & r) const
inlinenodiscard

Crop rectangle and align given top left rectangle point to coordinates [0,0] in new image.

For background outside image it will use Color::White. The dimensions of the output image will be equal to those of the rectangle.

See Description with examples.

Parameters
rRectangle
Returns
copied and aligned Image
Exceptions
ImageExceptionwhen there is an processing error

References CropAlignedRectangle().

Referenced by CropAlignedRectangle(), and CropAlignedRectangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CropAlignedRectangle() [2/3]

std::shared_ptr< Image > CropAlignedRectangle ( const Rectangle & r,
const RGBA & background ) const
inlinenodiscard

Crop rectangle and align given top left rectangle point to coordinates [0,0] in new image.

The function will utilize the provided color for the background outside the image. The dimensions of the output image will be equal to those of the rectangle.

See Description with examples.

Parameters
rRectangle
backgroundcolor of background when rectangle is out of image
Returns
copied and aligned Image
Exceptions
ImageExceptionwhen there is an processing error

References CropAlignedRectangle().

Here is the call graph for this function:

◆ CropAlignedRectangle() [3/3]

std::shared_ptr< Image > CropAlignedRectangle ( const Rectangle & r,
const RGBA & background,
const ImageDimensions & dimension ) const
inlinenodiscard

Crop rectangle and align given top left rectangle point to coordinates [0,0] in new image.

The function will render an image using specified dimensions, incorporating a cropped aligned rectangle within. For areas outside the cropped rectangle, the specified background color will be applied. If the dimensions of the cropped rectangle differ from those of the output image, the function will center the cropped rectangle within the output image. Any additional space in the output image, resulting from a size discrepancy with the cropped rectangle, will be filled with the chosen background color.

See Description with examples.

Parameters
rRectangle
backgroundcolor of background when rectangle is out of image
dimensionrequested dimension of new image.
Returns
copied and aligned Image
Exceptions
ImageExceptionwhen there is an processing error

References RGB::blue, RGBA::color, Rectangle::GetBottomLeft(), Rectangle::GetBottomRight(), Rectangle::GetHeight(), Rectangle::GetTopLeft(), Rectangle::GetTopRight(), Rectangle::GetWidth(), RGB::green, ImageDimensions::height, RGB::red, RGBA::transparency, ImageDimensions::width, Point::x, and Point::y.

Here is the call graph for this function:

◆ CropCircle()

std::shared_ptr< Image > CropCircle ( const Circle & circle,
const RGBA & background = Colors::White ) const
inlinenodiscard

Copy circle to new image.

See Description with examples.

Parameters
circlecircle to cut.
backgroundcolor of background around circle
Returns
copied Image
Exceptions
EnrollmentInvalidArgumentExceptionwhen given circle and image has no intersection
ImageExceptionwhen there is an processing error

References Circle::center, CircleIntersection(), NO, Circle::radius, Point::x, and Point::y.

Here is the call graph for this function:

◆ CropRectangle() [1/3]

std::shared_ptr< Image > CropRectangle ( const Rectangle & r) const
inlinenodiscard

Crops a rectangle from the image, using a white background for any extra space.

This method crops a rectangle from the image. If the rectangle extends beyond the image boundaries, the additional space is filled with a white background. The size of the resulting image matches the dimensions of the specified rectangle.

See Description with examples.

Parameters
rRectangle defining the area to crop.
Returns
A cropped image
Exceptions
EnrollmentInvalidArgumentExceptionif the rectangle does not intersect with the image.
ImageExceptionwhen there is an processing error

References CropRectangle().

Referenced by CropRectangle(), and CropRectangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CropRectangle() [2/3]

std::shared_ptr< Image > CropRectangle ( const Rectangle & r,
const RGBA & background ) const
inlinenodiscard

Crops a rectangle from the image, using a white background for any extra space.

This method crops a rectangle from the image. If the rectangle extends beyond the image boundaries, the additional space is filled with a specified background. The size of the resulting image matches the dimensions of the specified rectangle.

See Description with examples.

Parameters
rRectangle defining the area to crop.
backgroundColor for the background surrounding the rectangle.
Returns
A cropped image.
Exceptions
EnrollmentInvalidArgumentExceptionif the rectangle does not intersect with the image.

References CropRectangle().

Here is the call graph for this function:

◆ CropRectangle() [3/3]

std::shared_ptr< Image > CropRectangle ( const Rectangle & r,
const RGBA & background,
const ImageDimensions & dimension ) const
inlinenodiscard

Crops a rectangle and places it on a canvas of specified dimensions, using a specified background color.

This function crops a rectangle and centers it on a new canvas with the specified dimensions. If the new canvas is larger than the cropped rectangle, the extra space is filled with the specified background color. If the rectangle is larger than the original image, the background color fills the extra space.

See Description with examples.

Parameters
rRectangle defining the area to crop.
backgroundColor for the background.
dimensionDimensions of the new canvas. If width or height is 0, dimensions are set based on the rectangle.
Returns
A cropped image on a new canvas.
Exceptions
EnrollmentInvalidArgumentExceptionif the rectangle does not intersect with the image.

References RGB::blue, RGBA::color, Rectangle::GetBottomLeft(), Rectangle::GetBottomRight(), Rectangle::GetTopLeft(), Rectangle::GetTopRight(), RGB::green, ImageDimensions::height, NO, RectangleIntersection(), RGB::red, RGBA::transparency, ImageDimensions::width, Point::x, and Point::y.

Here is the call graph for this function:

◆ Decode() [1/4]

std::shared_ptr< Image > Decode ( const std::vector< uint8_t > & imageData)
inlinestatic

Creates Image from image data with 500 DPI.

See Description with examples. It uses default dpi (500). It uses GlobalImageExecutor for execution of image functionality.

Parameters
imageDataimage content
Returns
Image object of this class
Exceptions
ImageExceptionwhen type is not supported or image data are corrupted
NullArgumentExceptionwhen executor is null

References Decode(), DefaultDpi, and GlobalImageExecutor::Get().

Referenced by Decode(), Decode(), Decode(), FaceCapture::FromIsoImage(), IrisCapture::FromIsoImage(), and Print::FromIsoImage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Decode() [2/4]

std::shared_ptr< Image > Decode ( const std::vector< uint8_t > & imageData,
std::shared_ptr< ImageExecutor > executor )
inlinestatic

Creates Image from image data with 500 DPI.

See Description with examples. It uses default dpi (500).

Parameters
imageDataimage content
executorimage functionality executor (the execution strategy)
Returns
Image object of this class
Exceptions
ImageExceptionwhen type is not supported or image data are corrupted
NullArgumentExceptionwhen executor is null

References Decode(), and DefaultDpi.

Here is the call graph for this function:

◆ Decode() [3/4]

std::shared_ptr< Image > Decode ( const std::vector< uint8_t > & imageData,
unsigned int dpi )
inlinestatic

Creates Image from image data with given dpi.

See Description with examples. It uses GlobalImageExecutor for execution of image functionality.

Parameters
imageDataimage content
dpidpi of image
Returns
Image object of this class
Exceptions
ImageExceptionwhen type is not supported or image data are corrupted
NullArgumentExceptionwhen executor is null

References Decode(), and GlobalImageExecutor::Get().

Here is the call graph for this function:

◆ Decode() [4/4]

std::shared_ptr< Image > Decode ( const std::vector< uint8_t > & imageData,
unsigned int dpi,
std::shared_ptr< ImageExecutor > executor )
inlinestatic

Creates Image from image data with given DPI.

See Description with examples.

Parameters
imageDataimage content
dpidpi of image
executorimage functionality executor (the execution strategy)
Returns
Image object of this class
Exceptions
ImageExceptionwhen type is not supported or image data are corrupted
NullArgumentExceptionwhen executor is null

References ImageEncoder::Create(), ImageException::DECODE_IMAGE, and DeduceType().

Here is the call graph for this function:

◆ DecodeRawImage()

std::shared_ptr< Image > DecodeRawImage ( const RawImage & raw,
std::shared_ptr< ImageEncoder > originalEncoder = nullptr,
std::shared_ptr< ImageExecutor > executor = GlobalImageExecutor::Get() )
inlinestatic

Creates Image from raw data.

See Description with examples.

Parameters
rawRawImage
originalEncoderoriginal encoder
executorimage functionality executor (the execution strategy)
Returns
Image object of this class
Exceptions
ImageExceptionwhen type is not supported or image data are corrupted

References RawImage::Data(), RawImage::dpi, GlobalImageExecutor::Get(), RawImage::height, RawImage::type, and RawImage::width.

Referenced by AsBGR(), AsBGRA(), CroppedFace::FaceAreaMask(), CroppedFace::FaceAreaSegment(), CroppedFace::FaceAreaSegment(), IrisCapture::FromIsoImage(), Print::FromIsoImage(), and CroppedFace::GetFaceCapture().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeduceType()

ImageType DeduceType ( const std::vector< uint8_t > & imageData)
inlinestatic

Deduce image type from image content.

Parameters
imageDataimage content
Returns
ImageType image type
Exceptions
ImageExceptionwhen image type is unknown
ImageExceptionwhen there is an processing error

Referenced by Decode().

Here is the caller graph for this function:

◆ Dpi()

ImageDpi Dpi ( ) const
inlinenodiscard

Returns image dpi.

Returns
ImageDpi

Referenced by AsRawBGR(), AsRawBGRA(), AsRawGrayscale(), and AsRawImage().

Here is the caller graph for this function:

◆ DrawShape()

std::shared_ptr< Image > DrawShape ( const ImageShape & shape) const
inlinenodiscard

Draws shape to new image.

See Description with examples.

Parameters
shapeImageShape
Returns
Image image with drown shape
Exceptions
ImageExceptionwhen there is an processing error

References ImageShape::DrawIn().

Here is the call graph for this function:

◆ EncodeIn()

std::vector< uint8_t > EncodeIn ( ImageEncoder & encoder) const
inlinenodiscard

Encode image in given ImageEncoder.

Parameters
encoderspecific ImageEncoder
Returns
encoded image
Exceptions
ImageExceptionwhen ImageEncoder throws
ImageExceptionwhen it is not possible convert image to raw data

References AsRawImage(), and ImageEncoder::Encode().

Here is the call graph for this function:

◆ Height()

ImageHeight Height ( ) const
inlinenodiscard

Returns image height.

Returns
ImageHeight

Referenced by AsRawBGR(), AsRawBGRA(), AsRawGrayscale(), AsRawImage(), and ResizeToMaxDimension().

Here is the caller graph for this function:

◆ MaskImageBy()

std::shared_ptr< Image > MaskImageBy ( const ImageMask & mask) const
inlinenodiscard

Applies the specified mask to the image, creating a new masked image.

Parameters
maskThe ImageMask to apply to the current image. This mask defines the areas of the image to be modified or preserved according to the mask's specific logic.
Returns
New image instance that represents the result of applying the mask to the current image.

References ImageMask::MaskWith().

Here is the call graph for this function:

◆ operator==()

bool operator== ( const Image & right) const
inline

Images are equal when has same dimensions and same content.

Parameters
rightright image in comparison
Returns
true - images have same dimensions and content
false - images have different dimensions or content
Exceptions
ImageExceptionwhen there is an processing error

References AsRawImage().

Here is the call graph for this function:

◆ OriginalEncoder()

std::shared_ptr< ImageEncoder > OriginalEncoder ( ) const
inlinenodiscard

Provides original encoder to encode image to original format.

Returns
ImageEncoder

◆ PointIntersection()

Intersection PointIntersection ( const Point & point) const
inlinenodiscard

Checks intersection between point and image.

Parameters
pointpoint
Returns
Image::Intersection type

References Point::x, and Point::y.

◆ RectangleIntersection()

Intersection RectangleIntersection ( const Rectangle & rectangle) const
inlinenodiscard

Check intersection between rectangle and image.

Parameters
rectangleRectangle
Returns
Image::Intersection type
Exceptions
ImageExceptionwhen there is an processing error

References Rectangle::GetBottomLeft(), Rectangle::GetBottomRight(), Rectangle::GetTopLeft(), Rectangle::GetTopRight(), Point::x, and Point::y.

Referenced by CropRectangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Resize()

std::shared_ptr< Image > Resize ( float factor) const
inlinenodiscard

Resize image to new image.

Parameters
factorresize factor. Valid values are positive real number except 0.
Returns
resized Image
Exceptions
EnrollmentInvalidArgumentExceptionwhen factor is not positive real number except 0.
ImageExceptionwhen there is an processing error

Referenced by ResizeToMaxDimension().

Here is the caller graph for this function:

◆ ResizeToMaxDimension()

std::shared_ptr< Image > ResizeToMaxDimension ( ImageDimension maxDimension) const
inlinenodiscard

Resize image to new image with given max dimension.

When image has smaller dimension than maxDimension, then image is not resized. Otherwise image is resized to maxDimension with keeping aspect ratio.

Parameters
maxDimensionmax dimension of new image
Returns
resized Image or copy of original image when original image has smaller dimension than maxDimension.
Exceptions
ImageExceptionwhen there is an processing error

References Height(), Resize(), and Width().

Here is the call graph for this function:

◆ SaveAs()

void SaveAs ( const std::string & path) const
inline

Save Image in given path.

The image type is deduced from file extension. The default image encoder parameters are used. If you want to change encoding parameters, then use function EncodeIn with appropriate ImageEncoder.

Parameters
pathpath and file name where to save image on filesystem
Exceptions
ImageExceptionwhen ImageEncoder throws
ImageExceptionwhen it is not possible convert image to raw data

References AsRawImage().

Here is the call graph for this function:

◆ SaveIn()

void SaveIn ( ImageSaver & saver) const
inline

Save Image in given ImageSaver.

Parameters
saverspecific ImageSaver to use to save file
Exceptions
ImageExceptionwhen ImageSaver throws

References AsRawImage(), and ImageSaver::Save().

Here is the call graph for this function:

◆ Width()

ImageWidth Width ( ) const
inlinenodiscard

Returns image width.

Returns
ImageWidth

Referenced by AsRawBGR(), AsRawBGRA(), AsRawGrayscale(), AsRawImage(), and ResizeToMaxDimension().

Here is the caller graph for this function:

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