3from ids_peak_common.serialization
import IArchive
4from ids_peak_common.datatypes
import Interval, PixelFormat
5from ids_peak_icv
import lib_loader, Image
15 Sharpening is an image pipeline module that applies a sharpening filter to enhance image detail.
17 @since ids_peak_common 1.1
18 @ingroup ids_peak_icv_python_pipeline_modules
21 SUPPORTED_PIXEL_FORMATS = [PixelFormat.MONO_8, PixelFormat.MONO_10, PixelFormat.MONO_12,
22 PixelFormat.RGB_8, PixelFormat.RGB_10, PixelFormat.RGB_12,
23 PixelFormat.RGBA_8, PixelFormat.RGBA_10, PixelFormat.RGBA_12,
24 PixelFormat.BGR_8, PixelFormat.BGR_10, PixelFormat.BGR_12,
25 PixelFormat.BGRA_8, PixelFormat.BGRA_10, PixelFormat.BGRA_12]
27 DEFAULT_LEVEL: int = 0
34 Creates an instance of the sharpening module.
36 @since ids_peak_icv 1.0
48 Serializes the object's internal state into the provided archive.
50 This function populates the given archive with all parameters required to fully represent the current state of the object.
51 It ensures that the object can be reconstructed or transmitted accurately by saving all relevant data members
52 in a consistent and structured format.
54 @param archive: The target archive that will store the serialized parameters.
56 @since ids_peak_icv 1.0
64 Restores the object's state from the provided archive.
66 This function reads and applies all necessary parameters from the given archive to reconstruct the internal state of the object.
67 It ensures that the object is restored to a valid and consistent state.
69 @param archive: The source archive containing the serialized parameters.
71 @exception CorruptedException: If Archive is malformed, misses keys or the values are invalid
72 @exception NotSupportedException: If the 'Version' entry indicates an unsupported version.
74 @note This function requires that the archive contains all expected fields as produced by a corresponding serialize() call.
76 @since ids_peak_icv 1.0
86 Returns the type of the module for serialization purposes.
90 @since ids_peak_icv 1.0
92 return self.__class__.__name__.replace(
"Module",
"")
97 Resets the sharpness level to its default value (0).
99 @note The enabled state does not change when calling this function.
101 @since ids_peak_icv 1.0
109 Gets the current sharpness level.
111 @return Integer level.
113 @since ids_peak_icv 1.0
118 def level(self, level: int) ->
None:
121 Sets the sharpness level.
123 @param level: An integer specifying the sharpening strength.
124 @exception OutOfRangeException: The specified level is outside the valid range.
126 @since ids_peak_icv 1.0
129 if level < range_.minimum
or level > range_.maximum:
137 Gets the valid range of sharpening level values.
139 @return IntervalU with min and max values.
141 @since ids_peak_icv 1.0
146 execute_and_map_return_codes(
147 lib_loader.dll().peak_icv_ImageFilter_Sharpening_GetRange,
148 ctypes.pointer(c_interval)
150 return Interval(c_interval.minimum, c_interval.maximum)
152 def process(self, input_image: Image) -> Image:
155 Apply sharpening to the specified image.
157 @supportedPixelformats{Sharpening}
159 If sharpening is disabled or the sharpening level is set to 0, the input
160 image is returned unchanged. Otherwise, this method applies an in-place
161 sharpening operation using the configured level.
163 @param input_image: Input image to be processed.
164 @return Processed output image.
166 @since ids_peak_icv 1.0
174 input_handle = input_image._handle
175 execute_and_map_return_codes(
176 lib_loader.dll().peak_icv_ImageFilter_Sharpening_ProcessInPlace,
Occurs when a provided value falls outside the allowed valid range.
Base class for all pipeline modules.
Sharpening is an image pipeline module that applies a sharpening filter to enhance image detail.
None reset_to_default(self)
Resets the sharpness level to its default value (0).
None deserialize(self, IArchive archive)
Restores the object's state from the provided archive.
list SUPPORTED_PIXEL_FORMATS
str type(self)
Returns the type of the module for serialization purposes.
None level(self, int level)
Sets the sharpness level.
Image process(self, Image input_image)
Apply sharpening to the specified image.
None __init__(self)
Creates an instance of the sharpening module.
int level(self)
Gets the current sharpness level.
None serialize(self, IArchive archive)
Serializes the object's internal state into the provided archive.
Interval level_range(self)
Gets the valid range of sharpening level values.