IDS peak ICV v1.1.0
Loading...
Searching...
No Matches
color_correction_feature.py
Go to the documentation of this file.
1from __future__ import annotations
2
3import numpy
4
5from ids_peak_icv.pipeline._internal.color_matrix_transformation_module import ColorMatrixTransformationModule
7
8
10 """!
11 @brief
12 Color correction applies a 3x3 color correction matrix to the image.
13
14 @supportedPixelformats{ColorMatrixTransformation}
15
16 Color correction is typically used to convert colors from a camera sensor’s native RGB space to a standard color space,
17 or to perform color balancing and correction.
18
19 When performing color correction, a 3x3 color correction matrix is applied to the color values of the image.
20
21 The color correction matrix is represented as a 3×3 float array::
22
23 +--------+--------+--------+
24 | m_00 | m_01 | m_02 |
25 +--------+--------+--------+
26 | m_10 | m_11 | m_12 |
27 +--------+--------+--------+
28 | m_20 | m_21 | m_22 |
29 +--------+--------+--------+
30
31 Each element `m_ij` defines how much of the input channel `j` contributes to the output channel `i`.
32 For example, `m_01` is the contribution of the green input to the red output.
33
34 The matrix is applied as follows:
35 ```python
36 red_value_out = m_00 * red_value_in + m_01 * green_value_in + m_02 * blue_value_in;
37 green_value_out = m_10 * red_value_in + m_11 * green_value_in + m_12 * blue_value_in;
38 blue_value_out = m_20 * red_value_in + m_21 * green_value_in + m_22 * blue_value_in;
39 ```
40
41 where red_value_in, green_value_in, and blue_value_in are the input red, green, and blue channel values, respectively,
42 and red_value_out, green_value_out, and blue_value_out are the corresponding corrected output values.
43 All RGB values are normalized to the range [0.0, 1.0].
44
45 @warning Improper color correction matrices may result in color shifts, clipping, or unnatural colors.
46
47 The default value for the color correction matrix is the identity matrix.
48
49 @since ids_peak_icv 1.0
50 @ingroup ids_peak_icv_python_pipeline_features
51 """
52
53 def __init__(self, module: ColorMatrixTransformationModule) -> None:
54 """!
55 @brief
56 Creates a ColorCorrectionFeature for an existing color matrix transformation module.
57 @param module: Reference to the underlying module
58
59 @since ids_peak_icv 1.0
60 """
61 self._module = module
62
63 @property
64 def enabled(self) -> bool:
65 """!
66 @brief
67 Indicates whether the feature is currently enabled.
68 @return True if enabled; otherwise, False.
69
70 @since ids_peak_icv 1.0
71 """
72 return self._module.color_correction_enabled
73
74 @enabled.setter
75 def enabled(self, value: bool) -> None:
76 """!
77 @brief
78 Enables or disables the feature.
79 @param value: Set to True to enable the feature, or False to disable it.
80
81 @since ids_peak_icv 1.0
82 """
83 self._module.color_correction_enabled = value
84
85 def reset_to_default(self) -> None:
86 """!
87 @brief
88 Resets the color correction matrix to identity matrix.
89 @note The enabled state does not change when calling this function.
90
91 @since ids_peak_icv 1.0
92 """
94
95 @property
96 def matrix(self) -> numpy.ndarray:
97 """!
98 @brief
99 Gets the current color correction matrix.
100 @return The color correction matrix currently set.
101
102 @since ids_peak_icv 1.0
103 """
104 return self._module.matrix
105
106 @matrix.setter
107 def matrix(self, matrix: numpy.ndarray) -> None:
108 """!
109 @brief
110 Sets the color correction matrix.
111 @param matrix: A floating-point matrix representing the color correction matrix.
112
113 @since ids_peak_icv 1.0
114 """
115 self._module.matrix = matrix
Color correction applies a 3x3 color correction matrix to the image.
None reset_to_default(self)
Resets the color correction matrix to identity matrix.
None __init__(self, ColorMatrixTransformationModule module)
Creates a ColorCorrectionFeature for an existing color matrix transformation module.
bool enabled(self)
Indicates whether the feature is currently enabled.
numpy.ndarray matrix(self)
Gets the current color correction matrix.
Abstract base class for all image processing pipeline features.
Definition ifeature.py:6