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 @return The serialized module's internal state.
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.
89 @since ids_peak_icv 1.0
91 return self.__class__.__name__.replace(
"Module",
"")
96 Resets the sharpness level to default (0).
98 @since ids_peak_icv 1.0
106 Gets the current sharpness level.
108 @return Integer level.
110 @since ids_peak_icv 1.0
115 def level(self, level: int) ->
None:
118 Sets the sharpness level.
120 @param level: An integer specifying the sharpening strength.
121 @exception OutOfRangeException: The specified level is outside the valid range.
123 @since ids_peak_icv 1.0
126 if level < range_.minimum
or level > range_.maximum:
134 Gets the valid range of sharpening level values.
136 @return IntervalU with min and max values.
138 @since ids_peak_icv 1.0
143 execute_and_map_return_codes(
144 lib_loader.dll().peak_icv_ImageFilter_Sharpening_GetRange,
145 ctypes.pointer(c_interval)
147 return Interval(c_interval.minimum, c_interval.maximum)
149 def process(self, input_image: Image) -> Image:
152 Apply sharpening to the specified image.
154 @supportedPixelformats{Sharpening}
156 If sharpening is disabled or the sharpening level is set to 0, the input
157 image is returned unchanged. Otherwise, this method applies an in-place
158 sharpening operation using the configured level.
160 @param input_image: Input image to be processed.
161 @return Processed output image.
163 @since ids_peak_icv 1.0
171 input_handle = input_image._handle
172 execute_and_map_return_codes(
173 lib_loader.dll().peak_icv_ImageFilter_Sharpening_ProcessInPlace,
Represents an interval with lower and upper boundaries.
Thrown when a value is outside the allowed 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 default (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.