IDS peak ICV v1.5.0
Loading...
Searching...
No Matches
Image Class Reference

#include <peak_icv/types/peak_icv_image.hpp>

Inheritance diagram for Image:

Public Member Functions

 Image (const peak::common::IImageView &imageView)
 Constructs an Image from an IImageView Instance.
 
 Image (const std::string &path)
 Constructs an Image from a file path.
 
 Image (const std::string &path, peak::common::PixelFormat name)
 Constructs an Image from a file path with a specified pixel format.
 
 Image (peak::common::PixelFormat pixelFormat, uint8_t *buffer, size_t bufferSize, const peak::common::Size &imageSize)
 Constructs an Image from a buffer.
 
 Image (peak::common::PixelFormat pixelFormat, const peak::common::Size &imageSize)
 Constructs an Image with a given size and pixel format.
 
 Image (const Image &other)
 
 Image (Image &&other) noexcept
 
Image & operator= (const Image &other)
 
Image & operator= (Image &&other) noexcept
 
 ~Image () override
 
bool operator== (const Image &rhs) const
 
Image Copy () const
 
peak::common::Size GetSize () const
 Provides the size of the image in pixels.
 
uint8_t * GetData () const
 Provides a pointer to the image data buffer.
 
size_t GetSizeInBytes () const
 Provides the size of the image data in bytes.
 
size_t GetBytesPerLine () const
 Computes the number of bytes required to store one line of pixel data (no padding).
 
peak::common::PixelFormat GetPixelFormat () const
 Provides the pixel format of the image.
 
Region GetRegion () const
 Provides the region of the image.
 
void SetRegion (const Region &region) const
 Updates the region on the image.
 
void ResetRegion () const
 Resets the region on the image to the complete image.
 
template<typename DataType >
DataType * At (size_t x, size_t y) const
 Provides a pointer to the data at the specified coordinates.
 
Image ConvertPixelFormat (peak::common::PixelFormat pixelFormat) const
 Converts the image to a different pixel format.
 
void ConvertPixelFormat (Image &destinationImage) const
 Converts the image to the pixel format specified in the previously created destination image.
 
peak::icv::Image ConvertPixelFormatWithFactor (peak::common::PixelFormat pixelFormat, const double factor) const
 Converts an image into another pixel format with a factor multiplied to every pixel.
 
std::vector< Image > Deinterleave () const
 Splits an image with an interleaved pixel format into individual images.
 
void SetMetadata (const peak::common::Metadata &metadata)
 Updates the Metadata of an image which is used to store and manage capture information.
 
peak::common::Metadata GetMetadata () const
 Returns the Metadata of an image which contains information about the image capture information.
 
Image Subtract (const Image &subtrahend) const
 Subtracts the specified subtrahend image pixelwise from the current image and returns the resulting image.
 
Image operator- (const Image &subtrahend) const
 Subtracts the specified subtrahend image pixelwise from the current image and returns the resulting image.
 
Image Crop (const peak::common::Rectangle &rect) const
 Crops the image to the given rectangle.
 
Image Scale (const peak::common::Size &targetImageSize, const Interpolation &interpolation=Interpolation::NearestNeighbor) const
 Returns an image scaled to the given image size.
 

Detailed Description

For detailed information about the use of ids_peak_icv Image refer to the Image Guide.

Since
ids_peak_icv 1.0

Constructor & Destructor Documentation

◆ Image() [1/7]

Image ( const peak::common::IImageView & imageView)
inlineexplicit

Constructs an Image from an IImageView Instance.

This can be a buffer or a possibility to convert other libraries Images into this Image type.

Parameters
imageViewAbstract Image source
Since
ids_peak_icv 1.0

◆ Image() [2/7]

Image ( const std::string & path)
inlineexplicit

Constructs an Image from a file path.

The following image formats are supported:

  • Bitmap (BMP)
  • Joint Photographic Experts Group (JPEG)
  • Portable Network Graphics (PNG)
  • Raw Binary Format (RAW)

Supported image and pixel formats

BMP:

  • Mono8
  • Mono10
  • Mono12
  • Mono16
  • RGBa8
  • RGB10p32
  • BGR8
  • BGRa8
  • BGR10p32
  • BayerRG8
  • BayerRG10
  • BayerRG12
  • BayerGR8
  • BayerGR10
  • BayerGR12
  • BayerGB8
  • BayerGB10
  • BayerGB12
  • BayerBG8
  • BayerBG10
  • BayerBG12
  • Confidence8
  • Confidence16
  • Coord3D_C16
  • Coord3D_C8

JPEG:

  • BayerGB8
  • BayerGR8
  • RGBa8
  • RGB8
  • BayerBG8
  • BayerRG8
  • BGRa8
  • BGR8
  • Mono8

PNG:

  • Mono8
  • Mono10
  • Mono12
  • RGB8
  • RGBa8
  • RGBa10
  • RGBa12
  • BayerRG8
  • BayerRG10
  • BayerRG12
  • BayerGR8
  • BayerGR10
  • BayerGR12
  • BayerGB8
  • BayerGB10
  • BayerGB12
  • BayerBG8
  • BayerBG10
  • BayerBG12
  • Confidence8
  • Confidence16
  • Coord3D_C8
  • Coord3D_C16

RAW:

  • BayerGR8
  • BayerGR10
  • BayerGR12
  • BayerRG8
  • BayerRG10
  • BayerRG12
  • BayerGB8
  • BayerGB10
  • BayerGB12
  • BayerBG8
  • BayerBG10
  • BayerBG12
  • Mono8
  • Mono10
  • Mono12
  • Mono16
  • Confidence8
  • Confidence16
  • Coord3D_C8
  • Coord3D_C16
  • Coord3D_C32f
  • Coord3D_ABC32f
  • YUV420_8_YY_UV_SemiplanarIDS
  • YUV420_8_YY_VU_SemiplanarIDS
  • YUV422_8_UYVY
  • RGB8
  • RGB10
  • RGB12
  • BGR8
  • BGR10
  • BGR12
  • RGBa8
  • RGBa10
  • RGBa12
  • BGRa8
  • BGRa10
  • BGRa12
  • BayerBG10p
  • BayerBG12p
  • BayerGB10p
  • BayerGB12p
  • BayerGR10p
  • BayerGR12p
  • BayerRG10p
  • BayerRG12p
  • Mono10p
  • Mono12p
  • RGB10p32
  • BGR10p32
  • BayerRG10g40IDS
  • BayerGB10g40IDS
  • BayerGR10g40IDS
  • BayerBG10g40IDS
  • BayerRG12g24IDS
  • BayerGB12g24IDS
  • BayerGR12g24IDS
  • BayerBG12g24IDS
  • Mono10g40IDS
  • Mono12g24IDS

See the Pixel and Pixel Format Specifications for a detailed description of the pixel formats.

Parameters
pathThe file path to the image.
Since
ids_peak_icv 1.0

◆ Image() [3/7]

Image ( const std::string & path,
peak::common::PixelFormat name )
inlineexplicit

Constructs an Image from a file path with a specified pixel format.

This constructor loads an image from the given file path and forces the use of the specified pixel format. The function attempts to interpret the file using the provided format. If interpretation fails, an exception is thrown. Explicit conversion between image formats must be handled manually by the user.

The following image formats are supported:

  • Bitmap (BMP)
  • Joint Photographic Experts Group (JPEG)
  • Portable Network Graphics (PNG)
  • Tag Image File Format (TIFF)
  • Raw Binary Format (RAW)
  • High Dynamic Range Format (HDR)

Supported image and pixel formats

BMP:

  • Mono8
  • Mono10
  • Mono12
  • Mono16
  • RGBa8
  • RGB10p32
  • BGR8
  • BGRa8
  • BGR10p32
  • BayerRG8
  • BayerRG10
  • BayerRG12
  • BayerGR8
  • BayerGR10
  • BayerGR12
  • BayerGB8
  • BayerGB10
  • BayerGB12
  • BayerBG8
  • BayerBG10
  • BayerBG12
  • Confidence8
  • Confidence16
  • Coord3D_C16
  • Coord3D_C8

JPEG:

  • BayerGB8
  • BayerGR8
  • RGBa8
  • RGB8
  • BayerBG8
  • BayerRG8
  • BGRa8
  • BGR8
  • Mono8

PNG:

  • Mono8
  • Mono10
  • Mono12
  • RGB8
  • RGBa8
  • RGBa10
  • RGBa12
  • BayerRG8
  • BayerRG10
  • BayerRG12
  • BayerGR8
  • BayerGR10
  • BayerGR12
  • BayerGB8
  • BayerGB10
  • BayerGB12
  • BayerBG8
  • BayerBG10
  • BayerBG12
  • Confidence8
  • Confidence16
  • Coord3D_C8
  • Coord3D_C16

TIFF:

  • Mono8
  • Mono10
  • Mono12
  • Mono16
  • RGB8
  • RGB10
  • RGB12
  • Coord3D_C16
  • Coord3D_C32f
  • Coord3D_ABC32f
  • Mono32fIDS
  • RGB32fIDS
  • Mono32f
  • RGB32f

RAW:

Only the following formats are supported and must match the format used when saving:

  • Mono8
  • Mono10
  • Mono10p
  • Mono12
  • Mono12p
  • Mono16
  • BayerRG8
  • BayerRG10
  • BayerRG10p
  • BayerRG12
  • BayerRG12p
  • BayerGR8
  • BayerGR10
  • BayerGR10p
  • BayerGR12
  • BayerGR12p
  • BayerBG8
  • BayerBG10
  • BayerBG10p
  • BayerBG12
  • BayerBG12p
  • BayerGB8
  • BayerGB10
  • BayerGB10p
  • BayerGB12
  • BayerGB12p
  • Confidence8
  • Confidence16
  • Coord3D_C8
  • Coord3D_C16

HDR:

  • Mono32f
  • RGB32f

See the Pixel and Pixel Format Specifications for a detailed description of the pixel formats.

◆ Image() [4/7]

Image ( peak::common::PixelFormat pixelFormat,
uint8_t * buffer,
size_t bufferSize,
const peak::common::Size & imageSize )
inline

Constructs an Image from a buffer.

Parameters
pixelFormatThe pixel format of the image.
bufferThe buffer containing image data.
bufferSizeThe size of the buffer.
imageSizeThe size of the image in pixels.
Since
ids_peak_icv 1.0

◆ Image() [5/7]

Image ( peak::common::PixelFormat pixelFormat,
const peak::common::Size & imageSize )
inline

Constructs an Image with a given size and pixel format.

Parameters
pixelFormatThe pixel format of the image.
imageSizeThe size of the image in pixels.
Since
ids_peak_icv 1.0

◆ Image() [6/7]

Image ( const Image & other)
inline
Since
ids_peak_icv 1.0

◆ Image() [7/7]

Image ( Image && other)
inlinenoexcept
Since
ids_peak_icv 1.0

◆ ~Image()

~Image ( )
inlineoverride
Since
ids_peak_icv 1.0

Member Function Documentation

◆ At()

template<typename DataType >
DataType * At ( size_t x,
size_t y ) const
inline

Provides a pointer to the data at the specified coordinates.

Template Parameters
DataTypeThe type of the data to retrieve.
Parameters
xThe x-coordinate.
yThe y-coordinate.
Returns
A pointer to the data at the specified coordinates.
Since
ids_peak_icv 1.0

◆ ConvertPixelFormat() [1/2]

void ConvertPixelFormat ( Image & destinationImage) const
inline

Converts the image to the pixel format specified in the previously created destination image.

Use this function if you already have a previously created image and want to avoid unnecessary memory allocations or copies.

If the input image has the same pixel format as the target pixel format, the image will be copied.

Restrictions:

  • Conversion to Bayer formats is only supported from a bayer format with the same pattern, e.g. from BayerRG10p to BayerRG10 or BayerRG8.
  • Conversion to packed formats is not supported.
  • Conversions from RGB or BGR formats to RGBa or BGRa formats is not supported.
  • RGBa and BGRa formats support only conversions into different bit depths of the same channel layout or to Mono formats.
  • Confidence and Coord3D formats can only be converted to other bit depths of the same format type.
Note
For a full list of supported conversions see Supported Pixel Format Conversions.
Parameters
destinationImageThe size of the source image must match the size of the destination image.
Exceptions
MismatchExceptionThe source size does not match the destination image size.
NotSupportedExceptionThe conversion of the source pixel format into the destination pixel format is currently not supported.
Since
ids_peak_icv 1.4

◆ ConvertPixelFormat() [2/2]

Image ConvertPixelFormat ( peak::common::PixelFormat pixelFormat) const
inline

Converts the image to a different pixel format.

If the input image has the same pixel format as the specified pixel format parameter, the image will be copied.

Restrictions:

  • Conversion to Bayer formats is only supported from a bayer format with the same pattern, e.g. from BayerRG10p to BayerRG10 or BayerRG8.
  • Conversion to packed formats is not supported.
  • Conversions from RGB or BGR formats to RGBa or BGRa formats is not supported.
  • RGBa and BGRa formats support only conversions into different bit depths of the same channel layout or to Mono formats.
  • Confidence and Coord3D formats can only be converted to other bit depths of the same format type.
Note
For a full list of supported conversions see Supported Pixel Format Conversions.
Parameters
pixelFormatThe target pixel format.
Returns
A new Image with the target pixel format.
Since
ids_peak_icv 1.0

◆ ConvertPixelFormatWithFactor()

Image ConvertPixelFormatWithFactor ( peak::common::PixelFormat pixelFormat,
const double factor ) const
inline

Converts an image into another pixel format with a factor multiplied to every pixel.

If the input image has the same pixel format as the specified pixel format parameter, the image will be copied.

Supported conversions: From PixelFormat::Coord3D_C8 or PixelFormat::Coord3D_C16 to PixelFormat::Coord3D_C32f

Parameters
pixelFormatThe target pixel format.
factorThe multiplication factor
Returns
A new Image with the target pixel format.
Since
ids_peak_icv 1.1

◆ Copy()

Image Copy ( ) const
inline
Returns
A deep copy of the image, including its region and metadata.
Since
ids_peak_icv 1.0

◆ Crop()

Image Crop ( const peak::common::Rectangle & rect) const
inline

Crops the image to the given rectangle.

Returns
The cropped image.
Exceptions
OutOfRangeExceptionThe given rectangle is (partly) outside the image.
Since
ids_peak_icv 1.0

◆ Deinterleave()

std::vector< Image > Deinterleave ( ) const
inline

Splits an image with an interleaved pixel format into individual images.

The function separates e.g. multiple exposures embedded in the combined HDR raw image and provides them as independent images, each with the correctly associated exposure information.

Supported pixel formats
  • Mono10g40IDS_I_A_B
  • BayerRG10g40IDS_I_A_B
  • BayerBG10g40IDS_I_A_B
  • BayerGR10g40IDS_I_A_B
  • BayerGB10g40IDS_I_A_B
  • Mono12g24IDS_I_A_B
  • BayerRG12g24IDS_I_A_B
  • BayerBG12g24IDS_I_A_B
  • BayerGR12g24IDS_I_A_B
  • BayerGB12g24IDS_I_A_B
  • Mono8_I_A_B
  • BayerRG8_I_A_B
  • BayerBG8_I_A_B
  • BayerGR8_I_A_B
  • BayerGB8_I_A_B
  • Mono10_I_A_B
  • BayerRG10_I_A_B
  • BayerBG10_I_A_B
  • BayerGR10_I_A_B
  • BayerGB10_I_A_B
  • Mono12_I_A_B
  • BayerRG12_I_A_B
  • BayerBG12_I_A_B
  • BayerGR12_I_A_B
  • BayerGB12_I_A_B
  • Mono10p_I_A_B
  • BayerRG10p_I_A_B
  • BayerBG10p_I_A_B
  • BayerGR10p_I_A_B
  • BayerGB10p_I_A_B
  • Mono12p_I_A_B
  • BayerRG12p_I_A_B
  • BayerBG12p_I_A_B
  • BayerGR12p_I_A_B
  • BayerGB12p_I_A_B
  • Mono8_I_AB_CD
  • Mono10_I_AB_CD
  • Mono12_I_AB_CD
  • Mono10p_I_AB_CD
  • Mono12p_I_AB_CD
  • Mono10g40IDS_I_AB_CD
  • Mono12g24IDS_I_AB_CD

See the Pixel and Pixel Format Specifications for a detailed description of the pixel formats.

Returns
A vector where each element represents one of the interleaved images.
Since
ids_peak_icv 1.3

◆ GetBytesPerLine()

size_t GetBytesPerLine ( ) const
inline

Computes the number of bytes required to store one line of pixel data (no padding).

This returns the exact number of bytes used for one scanline of pixel data based on the image's width, number of channels, and bits per pixel.

Returns
Number of bytes per line of pixel data.
Since
ids_peak_icv 1.0

◆ GetData()

uint8_t * GetData ( ) const
inline

Provides a pointer to the image data buffer.

Returns
A pointer to the image data buffer.
Since
ids_peak_icv 1.0

◆ GetMetadata()

peak::common::Metadata GetMetadata ( ) const
inline

Returns the Metadata of an image which contains information about the image capture information.

Returns
The Metadata of the image
Since
ids_peak_icv 1.1

◆ GetPixelFormat()

peak::common::PixelFormat GetPixelFormat ( ) const
inline

Provides the pixel format of the image.

Returns
The pixel format of the image.
Since
ids_peak_icv 1.0

◆ GetRegion()

Region GetRegion ( ) const
inline

Provides the region of the image.

Returns
The region of the image.
Since
ids_peak_icv 1.1

◆ GetSize()

peak::common::Size GetSize ( ) const
inline

Provides the size of the image in pixels.

Returns
The size of the image in pixels.
Since
ids_peak_icv 1.0

◆ GetSizeInBytes()

size_t GetSizeInBytes ( ) const
inline

Provides the size of the image data in bytes.

Returns
The size of the image data in bytes.
Since
ids_peak_icv 1.0

◆ operator-()

Image operator- ( const Image & subtrahend) const
inline

Subtracts the specified subtrahend image pixelwise from the current image and returns the resulting image.

This function performs a pixelwise subtraction of the given subtrahend image from the current image. The resulting image is returned as a new Image object. The operation requires that both images have the same pixel format and dimensions.

Parameters
subtrahendThe image to subtract from the current image.
Supported pixel formats
  • BayerGR8
  • BayerGR10
  • BayerGR12
  • BayerRG8
  • BayerRG10
  • BayerRG12
  • BayerGB8
  • BayerGB10
  • BayerGB12
  • BayerBG8
  • BayerBG10
  • BayerBG12
  • Mono8
  • Mono10
  • Mono12
  • Mono16
  • Confidence8
  • Confidence16
  • Coord3D_C8
  • Coord3D_C16
  • Coord3D_C32f
  • Coord3D_ABC32f
  • RGB8
  • RGB10
  • RGB12
  • BGR8
  • BGR10
  • BGR12
  • Mono32fIDS
  • RGB32fIDS
  • Mono32f
  • RGB32f

See the Pixel and Pixel Format Specifications for a detailed description of the pixel formats.

Returns
The resulting image after pixelwise subtraction.
Since
ids_peak_icv 1.1

◆ operator=() [1/2]

Image & operator= ( const Image & other)
inline
Since
ids_peak_icv 1.0

◆ operator=() [2/2]

Image & operator= ( Image && other)
inlinenoexcept
Since
ids_peak_icv 1.0

◆ operator==()

bool operator== ( const Image & rhs) const
inline
Since
ids_peak_icv 1.0

◆ ResetRegion()

void ResetRegion ( ) const
inline

Resets the region on the image to the complete image.

Since
ids_peak_icv 1.1

◆ Scale()

Image Scale ( const peak::common::Size & targetImageSize,
const Interpolation & interpolation = Interpolation::NearestNeighbor ) const
inline

Returns an image scaled to the given image size.

Internally the scale factors are computed as follows:

  • Horizontal scale factor (X-axis) = Image width / Size width
  • Vertical scale factor (Y-axis) = Image height / Size height

These factors determine how the input image is resized to match the desired output dimensions.

Parameters
targetImageSizeThe image size to which the original image is scaled.
interpolationThe interpolation method used to scale the image.
Returns
The scaled image.
Exceptions
NotPossibleExceptionThe given targetImageSize is empty (i.e. width × height == 0).
NotSupportedExceptionThe interpolation method is not supported.
Since
ids_peak_icv 1.0

◆ SetMetadata()

void SetMetadata ( const peak::common::Metadata & metadata)
inline

Updates the Metadata of an image which is used to store and manage capture information.

Parameters
metadataMetadata to be updated
Since
ids_peak_icv 1.1

◆ SetRegion()

void SetRegion ( const Region & region) const
inline

Updates the region on the image.

Sets a region of interest (ROI) for the specified image handle, which defines a sub-area of the image where operations or analyses are focused. Any points in the region that fall outside the bounds of the image are automatically discarded (clipped).

Parameters
regionRegion to update
Since
ids_peak_icv 1.1

◆ Subtract()

Image Subtract ( const Image & subtrahend) const
inline

Subtracts the specified subtrahend image pixelwise from the current image and returns the resulting image.

This function performs a pixelwise subtraction of the given subtrahend image from the current image. The resulting image is returned as a new Image object. The operation requires that both images have the same pixel format and dimensions.

Parameters
subtrahendThe image to subtract from the current image.
Supported pixel formats
  • BayerGR8
  • BayerGR10
  • BayerGR12
  • BayerRG8
  • BayerRG10
  • BayerRG12
  • BayerGB8
  • BayerGB10
  • BayerGB12
  • BayerBG8
  • BayerBG10
  • BayerBG12
  • Mono8
  • Mono10
  • Mono12
  • Mono16
  • Confidence8
  • Confidence16
  • Coord3D_C8
  • Coord3D_C16
  • Coord3D_C32f
  • Coord3D_ABC32f
  • RGB8
  • RGB10
  • RGB12
  • BGR8
  • BGR10
  • BGR12
  • Mono32fIDS
  • RGB32fIDS
  • Mono32f
  • RGB32f

See the Pixel and Pixel Format Specifications for a detailed description of the pixel formats.

Returns
The resulting image after pixelwise subtraction.
Since
ids_peak_icv 1.1