IDS peak ICV v1.3.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 Gets whether this feature is currently enabled.
68
69 @return True if enabled; otherwise False.
70
71 @since ids_peak_icv 1.0
72 """
73 return self._module.color_correction_enabled
74
75 @enabled.setter
76 def enabled(self, enabled: bool) -> None:
77 """!
78 @brief
79 Enables or disables the feature.
80
81 @param enabled: True to enable, False to disable.
82
83 @since ids_peak_icv 1.0
84 """
85 self._module.color_correction_enabled = enabled
86
87 def reset_to_default(self) -> None:
88 """!
89 @brief
90 Resets the color correction matrix to its default value (identity matrix).
91
92 @note The enabled state does not change when calling this function.
93
94 @since ids_peak_icv 1.0
95 """
97
98 @property
99 def matrix(self) -> numpy.ndarray:
100 """!
101 @brief
102 Gets the current color correction matrix.
103
104 @return The current color correction matrix.
105
106 @since ids_peak_icv 1.0
107 """
108 return self._module.matrix
109
110 @matrix.setter
111 def matrix(self, matrix: numpy.ndarray) -> None:
112 """!
113 @brief
114 Sets the color correction matrix.
115
116 @param matrix: A floating-point 3x3 color correction matrix.
117
118 @since ids_peak_icv 1.0
119 """
120 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 its default value (identity matrix).
None __init__(self, ColorMatrixTransformationModule module)
Creates a ColorCorrectionFeature for an existing color matrix transformation module.
numpy.ndarray matrix(self)
Gets the current color correction matrix.
Abstract base class for all image processing pipeline features.
Definition ifeature.py:6