IDS peak ICV v1.2.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 an instance to a file on disk.
 
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.
 
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_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

Definition at line 40 of file image.py.

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.

Definition at line 235 of file image.py.

◆ __del__()

None __del__ ( self)

Destructor for Image class.

Definition at line 283 of file image.py.

Member Function Documentation

◆ __eq__()

bool __eq__ ( self,
object other )

Definition at line 575 of file image.py.

◆ __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

Definition at line 559 of file image.py.

◆ _create_from_np_array()

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

Definition at line 131 of file image.py.

◆ 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

Definition at line 393 of file image.py.

◆ 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

Definition at line 432 of file image.py.

◆ 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)

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

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

Definition at line 161 of file image.py.

◆ 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

Definition at line 75 of file image.py.

◆ 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

Definition at line 219 of file image.py.

◆ 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

Definition at line 107 of file image.py.

◆ 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

Definition at line 52 of file image.py.

◆ height()

int height ( self)

Provides the height of the image.

Returns
Image height in pixels
Since
ids_peak_icv 1.0

Definition at line 362 of file image.py.

◆ metadata() [1/2]

Metadata metadata ( self)

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

Returns
The metadata of the image.
Since
ids_peak_icv 1.0

Definition at line 502 of file image.py.

◆ 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

Definition at line 524 of file image.py.

◆ pixel_format()

PixelFormat pixel_format ( self)

Definition at line 594 of file image.py.

◆ 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

Definition at line 460 of file image.py.

◆ 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

Definition at line 476 of file image.py.

◆ reset_region()

None reset_region ( self)

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

Since
ids_peak_icv 1.0

Definition at line 492 of file image.py.

◆ save()

None save ( self,
str output_file_path )

Saves an instance to a file on disk.

The type is specified by the given file ending in file name.

The following image formats are supported:

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

The compression settings for PNG and JPEG images are as follows: For JPEG, the image quality is set to 75%, and for PNG, the image quality is set to 100%.

Note
The file extension for the given file name must match the specified image format when an image is saved. Otherwise, an error will occur when saving an image. The file extensions are:
  • PNG: .png
  • BMP: .bmp
  • JPEG: .jpeg
  • TIFF: .tiff
  • RAW: .raw

Supported image and pixel formats

BMP:

  • Mono8
  • Mono10
  • Mono12
  • Mono16
  • RGB8
  • RGBa8
  • RGB10p32
  • BGR8
  • BGRa8
  • BGR10p32
  • 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

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

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
output_file_pathThe path of the file to store the image to disk.
Since
ids_peak_icv 1.0

Definition at line 291 of file image.py.

◆ size()

Size size ( self)

Provides the size.Size of the image.

Returns
Image size in pixels
Since
ids_peak_icv 1.0

Definition at line 338 of file image.py.

◆ 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

Definition at line 540 of file image.py.

◆ 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

Definition at line 373 of file image.py.

◆ width()

int width ( self)

Provides the width of the image.

Returns
Image width in pixels
Since
ids_peak_icv 1.0

Definition at line 350 of file image.py.

Field Documentation

◆ _data

np _data .ndarray
staticprotected

Definition at line 49 of file image.py.

◆ _handle [1/2]

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

Definition at line 242 of file image.py.

◆ _handle [2/2]

Size _handle = other.size:

Definition at line 578 of file image.py.

◆ _ids_peak_ipl_image

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

Definition at line 262 of file image.py.

◆ _metadata

Metadata | None _metadata = None
protected

Definition at line 252 of file image.py.

◆ _pixel_format

_pixel_format = PixelFormat(image_info.pixel_format)
protected

Definition at line 254 of file image.py.

◆ _raw_data

_raw_data = None
protected

Definition at line 266 of file image.py.

◆ _size

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

Definition at line 255 of file image.py.