IDS peak ICV v1.4.0
Loading...
Searching...
No Matches
Image Class Reference
Inheritance diagram for Image:

Public Member Functions

Image create_from_pixel_format_and_size (cls, PixelFormat pixel_format, Size size)
 Creates an instance of Image using a size.Size and a pixel format.
 
Image create_from_ids_peak_ipl_image (cls, ids_peak_ipl.Image ids_peak_ipl_image)
 Creates an instance of Image using a ids_peak_ipl image.
 
Image create_from_np_array (cls, PixelFormat pixel_format, Size size, np.ndarray data)
 Creates an instance of Image using a PixelFormat, size.Size and numpy image buffer.
 
Image create_from_file (cls, str image_path, PixelFormat|None forced_pixel_format=None)
 Creates an Image from a file path.
 
Image create_from_image_view (cls, IImageView image_view)
 Creates an instance of Image using an IImageView interface.
 
None __init__ (self, *Any args, **Any kwargs)
 In order to create an Image, please refer to the classmethods.
 
None __del__ (self)
 Destructor for Image class.
 
None save (self, str output_file_path)
 Saves the image to a file.
 
Size size (self)
 Provides the size.Size of the image.
 
int width (self)
 Provides the width of the image.
 
int height (self)
 Provides the height of the image.
 
np.ndarray to_numpy_array (self, bool copy=True)
 Provides a numpy representation of the image.
 
Image convert_pixel_format (self, PixelFormat pixel_format)
 Converts the image to a different pixel format.
 
Image convert_pixel_format_with_factor (self, PixelFormat pixel_format, float factor)
 Converts an image into another pixel format with a factor multiplied to every pixel.
 
Region region (self)
 Retrieves the region.Region associated with the specified image_handle.
 
None region (self, Region region)
 Updates the region.Region on the image.
 
None reset_region (self)
 Resets the region.Region on the image to the complete image.
 
Metadata metadata (self)
 Retrieves the metadata.Metadata of an image which contains information about the image capture settings.
 
None metadata (self, Metadata metadata)
 Updates the metadata.Metadata of an image which is used to store and manage capture settings.
 
Image subtract (self, Image subtrahend)
 Subtracts the specified subtrahend image pixelwise from the current image and returns the resulting image.
 
List[Image] deinterleave (self)
 Splits an image with an interleaved pixel format into individual images.
 
Image copy (self)
 
Image __sub__ (self, Image subtrahend)
 Subtracts the specified subtrahend image pixelwise from the current image and returns the resulting image.
 
bool __eq__ (self, object other)
 
PixelFormat pixel_format (self)
 

Data Fields

Size _handle = other.size:
 

Protected Member Functions

Image _create_from_pixel_format_size_and_zero_init (cls, PixelFormat pixel_format, Size size, bool zero_init)
 
Image _create_from_np_array (cls, PixelFormat pixel_format, Size size, np.ndarray data)
 

Protected Attributes

 _handle
 
Metadata|None _metadata = None
 
 _pixel_format = PixelFormat(image_info.pixel_format)
 
 _size = Size(image_info.size.width, image_info.size.height)
 
str _ids_peak_ipl_image = kwargs["_ids_peak_ipl_image"] if "_ids_peak_ipl_image" in kwargs else None
 
 _raw_data = None
 

Static Protected Attributes

np _data .ndarray
 

Detailed Description

Image Class for working with algorithms.

Since
ids_peak_icv 1.0

Constructor & Destructor Documentation

◆ __init__()

None __init__ ( self,
*Any args,
**Any kwargs )

In order to create an Image, please refer to the classmethods.

Since
ids_peak_icv 1.0

Reimplemented in UndistortedImage, and XYZImage.

◆ __del__()

None __del__ ( self)

Destructor for Image class.

Member Function Documentation

◆ __eq__()

bool __eq__ ( self,
object other )

◆ __sub__()

Image __sub__ ( self,
Image subtrahend )

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.
Returns
The resulting image after pixelwise subtraction.
Since
ids_peak_icv 1.0

◆ _create_from_np_array()

Image _create_from_np_array ( cls,
PixelFormat pixel_format,
Size size,
np.ndarray data )
protected

◆ _create_from_pixel_format_size_and_zero_init()

Image _create_from_pixel_format_size_and_zero_init ( cls,
PixelFormat pixel_format,
Size size,
bool zero_init )
protected

◆ convert_pixel_format()

Image convert_pixel_format ( self,
PixelFormat pixel_format )

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
pixel_formatThe target pixel format.
Returns
A new Image with the target pixel format.
Since
ids_peak_icv 1.0

◆ convert_pixel_format_with_factor()

Image convert_pixel_format_with_factor ( self,
PixelFormat pixel_format,
float factor )

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

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

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

◆ copy()

Image copy ( self)
Returns
A deep copy of the image, including its region and metadata.
Since
ids_peak_icv 1.4

◆ create_from_file()

Image create_from_file ( cls,
str image_path,
PixelFormat | None forced_pixel_format = None )

Creates an Image from a file path.

This method loads an image from the given file path.

If a PixelFormat is provided via forced_pixel_format, the method attempts to interpret the file using that format. If interpretation fails, an exception is raised. 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) (Only if forced_pixel_format is specified)
  • Raw Binary Format (RAW)
  • High Dynamic Range (HDR) (Only if forced_pixel_format is specified)

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:

If forced_pixel_format is None any raw image can be loaded.

If forced_pixel_format is specified, 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.

Parameters
image_pathFile path on disk, pointing to an image.
forced_pixel_formatPixel format the loaded image is forced to use.
Returns
The loaded Image as a new instance
Since
ids_peak_icv 1.0

◆ create_from_ids_peak_ipl_image()

Image create_from_ids_peak_ipl_image ( cls,
ids_peak_ipl.Image ids_peak_ipl_image )

Creates an instance of Image using a ids_peak_ipl image.

Parameters
ids_peak_ipl_imageids_peak_ipl image
Returns
Created an image instance.
Since
ids_peak_icv 1.0

◆ create_from_image_view()

Image create_from_image_view ( cls,
IImageView image_view )

Creates an instance of Image using an IImageView interface.

Parameters
image_viewAn object implementing the IImageView interface, which can be constructed from a buffer provided by a camera.
Returns
A new Image instance created from the given image view.
Since
ids_peak_icv 1.0

◆ create_from_np_array()

Image create_from_np_array ( cls,
PixelFormat pixel_format,
Size size,
np.ndarray data )

Creates an instance of Image using a PixelFormat, size.Size and numpy image buffer.

Parameters
pixel_formatPixel format of the image
sizeImage size in pixels
dataNumpy array holding the buffer data
Returns
Created an image instance.
Exceptions
OutOfRangeExceptionIf the input array is 2D and the expected number of channels is not 1, or if it is 3D and the channel count does not match, or if it has a number of dimensions other than 2 or 3.
Since
ids_peak_icv 1.0

◆ create_from_pixel_format_and_size()

Image create_from_pixel_format_and_size ( cls,
PixelFormat pixel_format,
Size size )

Creates an instance of Image using a size.Size and a pixel format.

Parameters
sizeImage size in pixels
pixel_formatPixel format of the image
Returns
Returns an image instance.
Since
ids_peak_icv 1.0

◆ deinterleave()

List[Image] deinterleave ( self)

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

The function separates e.g. multiple exposures or gains 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 list of images, where each element represents one of the deinterleaved images.
Since
ids_peak_icv 1.3

◆ height()

int height ( self)

Provides the height of the image.

Returns
Image height in pixels
Since
ids_peak_icv 1.0

◆ metadata() [1/2]

Metadata metadata ( self)

Retrieves the metadata.Metadata of an image which contains information about the image capture settings.

The retrieved metadata object is a reference to the image metadata, meaning that changes within the metadata object will result in changes within the metadata of the image.

Returns
The metadata of the image.
Since
ids_peak_icv 1.0

◆ metadata() [2/2]

None metadata ( self,
Metadata metadata )

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

Parameters
metadataThe metadata to be updated.
Since
ids_peak_icv 1.0

◆ pixel_format()

PixelFormat pixel_format ( self)

◆ region() [1/2]

Region region ( self)

Retrieves the region.Region associated with the specified image_handle.

Returns
The image region.
Since
ids_peak_icv 1.0

◆ region() [2/2]

None region ( self,
Region region )

Updates the region.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
regionThe region to be set.
Since
ids_peak_icv 1.0

◆ reset_region()

None reset_region ( self)

Resets the region.Region on the image to the complete image.

Since
ids_peak_icv 1.0

◆ save()

None save ( self,
str output_file_path )

Saves the image to a file.

The file format is determined by the specified file extension of the file name.

Supported image formats (with required file extensions):

  • PNG (.png) – Portable Network Graphics
  • BMP (.bmp) – Bitmap
  • JPEG (.jpeg) – Joint Photographic Experts Group
  • TIFF (.tiff) – Tag Image File Format
  • RAW (.raw) – Raw Binary Format
  • HDR (.hdr) – High Dynamic Range Format

Compression settings:

  • JPEG: 75% quality
  • PNG: 100% quality

Supported image and pixel formats

BMP:

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

JPEG:

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

PNG:

  • Mono8
  • Mono10
  • Mono12
  • Mono16
  • RGB8
  • RGB10
  • RGB12
  • RGBa8
  • RGBa10
  • RGBa12
  • BGR8
  • BGR10
  • BGRa8
  • BGR12
  • BGRa10
  • BGRa12
  • BayerRG8
  • BayerRG10
  • BayerRG12
  • BayerGR8
  • BayerGR10
  • BayerGR12
  • BayerBG8
  • BayerBG10
  • BayerBG12
  • BayerGB8
  • BayerGB10
  • BayerGB12
  • Confidence8
  • Confidence16
  • Coord3D_C8
  • Coord3D_C16
Note
When saving BGR formats to PNG, they are written as RGB.

TIFF:

  • 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
  • Mono32fIDS
  • RGB32fIDS
  • Mono32f
  • RGB32f
Note
When saving floating‑point images to TIFF: Not all image viewers support displaying TIFF files that store floating‑point pixel data. The saved TIFF file is intended primarily as a data container that allows this library to reliably write and later re‑read the data.

RAW:

  • BayerGR8
  • BayerGR10
  • BayerGR12
  • BayerRG8
  • BayerRG10
  • BayerRG12
  • BayerGB8
  • BayerGB10
  • BayerGB12
  • BayerBG8
  • BayerBG10
  • BayerBG12
  • Mono8
  • Mono10
  • Mono12
  • Mono16
  • Confidence8
  • Confidence16
  • Coord3D_C8
  • Coord3D_C16
  • RGB8
  • RGB10
  • RGB12
  • BGR8
  • BGR10
  • BGR12
  • RGBa8
  • RGBa10
  • RGBa12
  • BGRa8
  • BGRa10
  • BGRa12

HDR:

  • Mono32f
  • RGB32f

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

Parameters
output_file_pathThe path of the file to store the image to disk.
Since
ids_peak_icv 1.0

◆ size()

Size size ( self)

Provides the size.Size of the image.

Returns
Image size in pixels
Since
ids_peak_icv 1.0

◆ subtract()

Image subtract ( self,
Image subtrahend )

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.
Returns
The resulting image after pixelwise subtraction.
Since
ids_peak_icv 1.0

◆ to_numpy_array()

np.ndarray to_numpy_array ( self,
bool copy = True )

Provides a numpy representation of the image.

Note that the image is copied by default and the caller must not take care of the original Instance being still available.

Parameters
copyTrue: The image is copied, False: The image only references the internal memory.
Returns
Image data as a numpy array. Shape is [height, width] for single channel images. Shape is [height, width, number of channels] for multichannel images.
Since
ids_peak_icv 1.0

◆ width()

int width ( self)

Provides the width of the image.

Returns
Image width in pixels
Since
ids_peak_icv 1.0

Field Documentation

◆ _data

np _data .ndarray
staticprotected

◆ _handle [1/2]

_handle
protected
Initial value:
= check_init_for_classes_with_classmethods_only(self.__class__.__name__,
peak_icv_image_handle, *args, **kwargs)

◆ _handle [2/2]

Size _handle = other.size:

◆ _ids_peak_ipl_image

str _ids_peak_ipl_image = kwargs["_ids_peak_ipl_image"] if "_ids_peak_ipl_image" in kwargs else None
protected

◆ _metadata

Metadata | None _metadata = None
protected

◆ _pixel_format

_pixel_format = PixelFormat(image_info.pixel_format)
protected

◆ _raw_data

_raw_data = None
protected

◆ _size

_size = Size(image_info.size.width, image_info.size.height)
protected