IDS peak ICV v1.1.0
Loading...
Searching...
No Matches
DownsamplingModule Class Reference

#include <peak_icv/pipeline/detail/peak_icv_downsampling_module.hpp>

Inheritance diagram for DownsamplingModule:

Public Member Functions

 DownsamplingModule ()
 Creates a DownsamplingModule with default values.
 
 DownsamplingModule (DownsamplingMode defaultMode, std::string customName)
 Creates a DownsamplingModule with factors x = 1, y = 1 and the given downsampling mode and name.
 
 ~DownsamplingModule () override
 
 DownsamplingModule (const DownsamplingModule &other)=delete
 Copy constructor for class DownsamplingModule is deleted.
 
 DownsamplingModule (DownsamplingModule &&other) noexcept
 
DownsamplingModule & operator= (const DownsamplingModule &other)=delete
 Copy assignment for class DownsamplingModule is deleted.
 
DownsamplingModule & operator= (DownsamplingModule &&other) noexcept
 
void SetEnabled (bool enabled) override
 Sets the enabled state of this module.
 
bool IsEnabled () const override
 Checks if the module is currently enabled.
 
void Serialize (peak::common::serialization::IArchive &archive) const override
 Serializes the object's internal state into the provided archive.
 
void Deserialize (const peak::common::serialization::IArchive &archive) override
 Restores the object's state from the provided archive.
 
peak::icv::Image Process (const peak::icv::Image &input) const
 Applies the downsampling factors and mode to the input image and returns a downsampled copy based on current settings.
 
peak::common::Any Process (const peak::common::Any &input) const override
 Applies the downsampling factors and mode to the input image and returns a downsampled copy based on current settings.
 
const char * GetType () const override
 Returns the type of the module for serialization purposes or the custom type, if defined.
 
void SetCustomType (const std::string &type)
 Sets the custom type of the module for serialization purposes.
 
void ResetToDefault () override
 Resets all settings to default values, except the CustomType.
 
void SetX (uint32_t x)
 Sets the number of columns to downsample.
 
void SetY (uint32_t y)
 Sets the number of rows to downsample.
 
uint32_t GetX () const
 Returns the current number of columns used for downsampling.
 
uint32_t GetY () const
 Returns the current number of rows used for downsampling.
 
peak::common::IntervalU GetRange () const
 Returns the valid range for downsampling factors x and y.
 
void SetMode (const DownsamplingMode &mode)
 Sets the DownsamplingMode.
 
DownsamplingMode GetMode () const
 Returns the current DownsamplingMode.
 

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

Definition at line 110 of file peak_icv_downsampling_module.hpp.

Constructor & Destructor Documentation

◆ DownsamplingModule() [1/4]

DownsamplingModule ( )
inlineexplicit

Creates a DownsamplingModule with default values.

Since
ids_peak_icv 1.0

Definition at line 476 of file peak_icv_downsampling_module.hpp.

◆ DownsamplingModule() [2/4]

DownsamplingModule ( DownsamplingMode defaultMode,
std::string customName )
inlineexplicit

Creates a DownsamplingModule with factors x = 1, y = 1 and the given downsampling mode and name.

Since
ids_peak_icv 1.0

Definition at line 480 of file peak_icv_downsampling_module.hpp.

◆ ~DownsamplingModule()

~DownsamplingModule ( )
inlineoverride
Since
ids_peak_icv 1.0

Definition at line 490 of file peak_icv_downsampling_module.hpp.

◆ DownsamplingModule() [3/4]

DownsamplingModule ( const DownsamplingModule & other)
delete

Copy constructor for class DownsamplingModule is deleted.

Note
If you need to copy a module, you can create a new one and copy the parameters via Serialize() and Deserialize().
Since
ids_peak_icv 1.0

◆ DownsamplingModule() [4/4]

DownsamplingModule ( DownsamplingModule && other)
inlinenoexcept
Since
ids_peak_icv 1.0

Definition at line 498 of file peak_icv_downsampling_module.hpp.

Member Function Documentation

◆ Deserialize()

void Deserialize ( const peak::common::serialization::IArchive & archive)
inlineoverridevirtual

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

Implements ISerializable.

Definition at line 547 of file peak_icv_downsampling_module.hpp.

◆ GetMode()

DownsamplingMode GetMode ( ) const
inline

Returns the current DownsamplingMode.

Returns
The current DownsamplingMode.
Since
ids_peak_icv 1.0

Definition at line 670 of file peak_icv_downsampling_module.hpp.

◆ GetRange()

peak::common::IntervalU GetRange ( ) const
inline

Returns the valid range for downsampling factors x and y.

Returns
The valid range.
Since
ids_peak_icv 1.0

Definition at line 651 of file peak_icv_downsampling_module.hpp.

◆ GetType()

const char * GetType ( ) const
inlineoverridevirtual

Returns the type of the module for serialization purposes or the custom type, if defined.

Returns
A string representing the module's type.
Since
ids_peak_icv 1.0

Implements IModule.

Definition at line 599 of file peak_icv_downsampling_module.hpp.

◆ GetX()

uint32_t GetX ( ) const
inline

Returns the current number of columns used for downsampling.

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

Definition at line 629 of file peak_icv_downsampling_module.hpp.

◆ GetY()

uint32_t GetY ( ) const
inline

Returns the current number of rows used for downsampling.

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

Definition at line 640 of file peak_icv_downsampling_module.hpp.

◆ IsEnabled()

bool IsEnabled ( ) const
inlineoverridevirtual

Checks if the module is currently enabled.

Returns
True if the module is enabled, false otherwise.
Since
ids_peak_icv 1.0

Implements IModule.

Definition at line 528 of file peak_icv_downsampling_module.hpp.

◆ operator=() [1/2]

DownsamplingModule & operator= ( const DownsamplingModule & other)
delete

Copy assignment for class DownsamplingModule is deleted.

Note
If you need to copy a module, you can create a new one and copy the parameters via Serialize() and Deserialize().
Since
ids_peak_icv 1.0

◆ operator=() [2/2]

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

Definition at line 504 of file peak_icv_downsampling_module.hpp.

◆ Process() [1/2]

peak::common::Any Process ( const peak::common::Any & input) const
inlineoverridevirtual

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

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
inputThe input image to be processed.
Returns
A new image object that is the transformed result of the input.
Exceptions
peak::common::InvalidCastExceptionIf the input cast to peak::icv::Image failed.
NotSupportedExceptionIf image has any other than the supported pixel formats.
Since
ids_peak_icv 1.0

Implements IModule.

Definition at line 566 of file peak_icv_downsampling_module.hpp.

◆ Process() [2/2]

peak::icv::Image Process ( const peak::icv::Image & input) const
inline

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

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
inputThe input image to be processed.
Returns
A new image object that is the transformed result of the input.
Exceptions
NotSupportedExceptionIf image has any other than the supported pixel formats.
Since
ids_peak_icv 1.0

Definition at line 561 of file peak_icv_downsampling_module.hpp.

◆ ResetToDefault()

void ResetToDefault ( )
inlineoverridevirtual

Resets all settings to default values, except the CustomType.

Since
ids_peak_icv 1.0

Implements IModule.

Definition at line 608 of file peak_icv_downsampling_module.hpp.

◆ Serialize()

void Serialize ( peak::common::serialization::IArchive & archive) const
inlineoverridevirtual

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

This function populates the given 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

Implements ISerializable.

Definition at line 533 of file peak_icv_downsampling_module.hpp.

◆ SetCustomType()

void SetCustomType ( const std::string & type)

Sets the custom type of the module for serialization purposes.

Parameters
typeA string representing the module's type.
Since
ids_peak_icv 1.0

◆ SetEnabled()

void SetEnabled ( bool enabled)
inlineoverridevirtual

Sets the enabled state of this module.

Parameters
enabledIf true, the module is enabled; otherwise, it is disabled.
Since
ids_peak_icv 1.0

Implements IModule.

Definition at line 523 of file peak_icv_downsampling_module.hpp.

◆ SetMode()

void SetMode ( const DownsamplingMode & mode)
inline

Sets the DownsamplingMode.

Parameters
modeThe DownsamplingMode to set.
Since
ids_peak_icv 1.0

Definition at line 662 of file peak_icv_downsampling_module.hpp.

◆ SetX()

void SetX ( uint32_t x)
inline

Sets the number of columns to downsample.

Parameters
xThe number of columns to downsample.
Since
ids_peak_icv 1.0

Definition at line 615 of file peak_icv_downsampling_module.hpp.

◆ SetY()

void SetY ( uint32_t y)
inline

Sets the number of rows to downsample.

Parameters
yThe number of rows to downsample.
Since
ids_peak_icv 1.0

Definition at line 622 of file peak_icv_downsampling_module.hpp.