4from ids_peak_icv
import lib_loader
14 Mono conversion is an image pipeline module that converts images to a monochrome format.
15 The mono conversion module performs a mono (grayscale) conversion on input images.
16 When enabled, it converts the input image to a mono format while preserving the input bit depth.
17 If disabled, the input image is passed through unchanged.
19 @since ids_peak_icv 1.0
25 Initializes a MonoConversionModule with default settings.
27 @since ids_peak_icv 1.0
32 execute_and_map_return_codes(lib_loader.dll().peak_icv_Preprocessing_ImageConverter_Create,
33 ctypes.pointer(image_converter_handle))
38 if hasattr(self,
'_handle'):
39 lib_loader.dll().peak_icv_Preprocessing_ImageConverter_Destroy(self.
_handle)
45 Returns the type of the module (used for serialization or UI).
49 @since ids_peak_icv 1.0
51 return "MonoConversion"
58 @since ids_peak_icv 1.0
62 def process(self, input_image: Image) -> Image:
65 Converts the input image to the configured output pixel format.
67 This operation disregards any specified image regions and processes the full image.
69 @param input_image: The input image to convert.
70 @return Converted image in the configured pixel format.
72 @since ids_peak_icv 1.0
79 if input_image.pixel_format == output_pixel_format:
83 execute_and_map_return_codes(
84 lib_loader.dll().peak_icv_Preprocessing_ImageConverter_Convert, self.
_handle, input_image._handle,
86 output_pixel_format.value),
87 ctypes.pointer(output_image_handle))
89 return Image(_handle=output_image_handle)
94 Frees unused internal buffers.
96 This module uses pre-allocated internal buffers to accelerate conversions.
97 When the image size or pixel format changes, new buffers are allocated, which may cause
98 the internal buffer pool to grow over time. This function can be used to release
99 unused buffers and reduce memory usage.
101 Avoid calling this function too frequently (e.g., after every resize or format change),
102 as it introduces some overhead.
104 @since ids_peak_icv 1.0
107 execute_and_map_return_codes(
108 lib_loader.dll().peak_icv_Preprocessing_ImageConverter_ReleaseBuffers, self.
_handle)
115 if (input_pixel_format.is_single_channel
and input_pixel_format.has_intensity_channel):
116 return input_pixel_format
118 bit_depth = input_pixel_format.storage_bits_per_channel
121 return PixelFormat.MONO_8
123 return PixelFormat.MONO_10
125 return PixelFormat.MONO_12
126 return PixelFormat.MONO_16
None enabled(self, bool value)
Sets the enabled state of the module.
bool enabled(self)
Gets whether the module is currently enabled.
Image Class for working with algorithms.
Base class for all pipeline modules.
None enabled(self, bool value)
Enable or disable the module.
bool enabled(self)
Get whether this module is enabled.
Mono conversion is an image pipeline module that converts images to a monochrome format.
None reset_to_default(self)
Does nothing.
None release_buffers(self)
Frees unused internal buffers.
str type(self)
Returns the type of the module (used for serialization or UI).
PixelFormat _get_output_format(PixelFormat input_pixel_format)
Image process(self, Image input_image)
Converts the input image to the configured output pixel format.
None __init__(self)
Initializes a MonoConversionModule with default settings.