IDS peak ICV v1.5.0
Loading...
Searching...
No Matches
DownsamplingModule Class Reference
Inheritance diagram for DownsamplingModule:

Public Member Functions

None __init__ (self, DownsamplingMode default_mode, str custom_type)
 Creates a DownsamplingModule with default values.
 
None __del__ (self)
 
str type (self)
 Returns the type of the pipeline for serialization purposes.
 
Image process (self, Image input_image)
 Applies the downsampling factors and mode to the input image and returns a downsampled copy based on current settings.
 
None reset_to_default (self)
 Resets all settings to their default values defined at initialization, i.e.
 
int x (self)
 Returns the current number of columns used for downsampling.
 
None x (self, int value)
 Sets the number of columns to downsample.
 
int y (self)
 Returns the current number of rows used for downsampling.
 
None y (self, int value)
 Sets the number of rows to downsample.
 
DownsamplingMode mode (self)
 Returns the current DownsamplingMode.
 
None mode (self, DownsamplingMode value)
 Sets the DownsamplingMode.
 
None serialize (self, IArchive archive)
 Serializes the object's internal state into the provided archive.
 
None deserialize (self, IArchive archive)
 Restores the object's state from the provided archive.
 
Interval range (self)
 Returns the valid range for downsampling factors x and y.
 

Data Fields

int x = 1):
 
int y = self.DEFAULT_Y
 
 mode = self._default_mode
 

Static Public Attributes

int DEFAULT_X = 1
 
int DEFAULT_Y = 1
 

Protected Attributes

int _x = self.DEFAULT_X
 
int _y = self.DEFAULT_Y
 
 _mode = default_mode
 
 _default_mode = default_mode
 
 _type = custom_type
 
 _handle = peak_icv_downsampling_handle(None)
 

Detailed Description

Downsampling is used to decrease the image size.

This module provides comprehensive functionality for image downsampling, which is the process of reducing image resolution and dimensions. It supports multiple algorithms optimized for various use cases.

There are two basic techniques for downsampling:

  • Binning This method reduces resolution by summarizing or averaging groups of pixels in the horizontal (x) and/or vertical (y) directions. It helps preserve image quality by minimizing aliasing artifacts.
  • Decimation This method reduces resolution by selecting (i.e., skipping) pixels at regular intervals along columns (x), rows (y) or both. It is computationally efficient but may introduce aliasing.

The reduction factors are specified separately for the x (columns) and y (rows) directions.

Since
ids_peak_icv 1.0

Constructor & Destructor Documentation

◆ __init__()

None __init__ ( self,
DownsamplingMode default_mode,
str custom_type )

Creates a DownsamplingModule with default values.

Parameters
default_modeOverride default mode, used when resetting the module to default
custom_typeOverride custom mode, used when serialized to disk
Since
ids_peak_icv 1.0

Reimplemented from ModuleBase.

◆ __del__()

None __del__ ( self)

Member Function Documentation

◆ deserialize()

None deserialize ( self,
IArchive archive )

Restores the object's state from the provided archive.

This function reads and applies all necessary parameters from the given archive to reconstruct the internal state of the object. It ensures that the object is restored to a valid and consistent state.

Parameters
archiveThe source archive containing the serialized parameters.
Exceptions
CorruptedExceptionIf the archive is malformed, misses keys or the values are invalid
NotSupportedExceptionIf the 'Version' entry indicates an unsupported version.
Note
This function requires that the archive contains all expected fields as produced by a corresponding serialize() call.
Since
ids_peak_icv 1.0

Reimplemented from ModuleBase.

◆ mode() [1/2]

DownsamplingMode mode ( self)

Returns the current DownsamplingMode.

Returns
The current DownsamplingMode.
Since
ids_peak_icv 1.0

◆ mode() [2/2]

None mode ( self,
DownsamplingMode value )

Sets the DownsamplingMode.

Parameters
valueThe DownsamplingMode to set.
Since
ids_peak_icv 1.0

◆ process()

Image process ( self,
Image input_image )

Applies the downsampling factors and mode to the input image and returns a downsampled copy based on current settings.

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
  • RGBa8
  • RGBa10
  • RGBa12
  • BGRa8
  • BGRa10
  • BGRa12
  • Mono32fIDS
  • RGB32fIDS
  • Mono32f
  • RGB32f

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

Note
Processes the entire image, ignoring any specified image region.
The alpha channel of the input image (if present) is also ignored. This is because the alpha channel can have different interpretations — such as transparency, segmentation labels, or masks — each of which would require different handling during binning. Consequently, the alpha channel of the output image is always set to the maximum possible pixel value.
Parameters
input_imageThe input image to be processed.
Returns
A new image object that is the transformed result of the input.
Exceptions
NotSupportedExceptionIf input has any other than the supported pixel formats.
Since
ids_peak_icv 1.0

◆ range()

Interval range ( self)

Returns the valid range for downsampling factors x and y.

Returns
The valid range.
Since
ids_peak_icv 1.0

◆ reset_to_default()

None reset_to_default ( self)

Resets all settings to their default values defined at initialization, i.e.

x = 1, y = 1, and the initial downsampling mode.

Note
The enabled state and custom_type do not change when calling this function.
Since
ids_peak_icv 1.0

◆ serialize()

None serialize ( self,
IArchive archive )

Serializes the object's internal state into the provided archive.

This function populates the object into an archive with all parameters required to fully represent the current state of the object. It ensures that the object can be reconstructed or transmitted accurately by saving all relevant data members in a consistent and structured format.

Parameters
archiveThe target archive that will store the serialized parameters.
Since
ids_peak_icv 1.0

Reimplemented from ModuleBase.

◆ type()

str type ( self)

Returns the type of the pipeline for serialization purposes.

Returns
Module type
Since
ids_peak_icv 1.0

◆ x() [1/2]

int x ( self)

Returns the current number of columns used for downsampling.

Returns
The current number of columns to downsample.
Since
ids_peak_icv 1.0

◆ x() [2/2]

None x ( self,
int value )

Sets the number of columns to downsample.

Parameters
valueThe number of columns to downsample.
Since
ids_peak_icv 1.0

◆ y() [1/2]

int y ( self)

Returns the current number of rows used for downsampling.

Returns
The current number of rows to downsample.
Since
ids_peak_icv 1.0

◆ y() [2/2]

None y ( self,
int value )

Sets the number of rows to downsample.

Parameters
valueThe number of rows to downsample.
Since
ids_peak_icv 1.0

Field Documentation

◆ _default_mode

_default_mode = default_mode
protected

◆ _handle

_handle = peak_icv_downsampling_handle(None)
protected

◆ _mode

_mode = default_mode
protected

◆ _type

_type = custom_type
protected

◆ _x

int _x = self.DEFAULT_X
protected

◆ _y

int _y = self.DEFAULT_Y
protected

◆ DEFAULT_X

int DEFAULT_X = 1
static

◆ DEFAULT_Y

int DEFAULT_Y = 1
static

◆ mode

mode = self._default_mode

◆ x

x = 1):

◆ y

y = self.DEFAULT_Y