16#include <peak_icv_c/algorithms/preprocessing/peak_icv_image_converter.h>
132 PEAK_COMMON_NO_DISCARD
bool IsEnabled()
const override;
141 PEAK_COMMON_NO_DISCARD
const char*
GetType()
const override;
204 constexpr static int moduleVersion{ 1 };
206 bool m_enabled{
true };
207 peak_icv_image_converter_handle m_handle{};
213 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ImageConverter_Create(&m_handle);
219 if (m_handle !=
nullptr)
221 std::ignore = PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ImageConverter_Destroy(m_handle);
227 m_enabled = other.m_enabled;
228 std::swap(m_handle, other.m_handle);
235 m_enabled = other.m_enabled;
236 std::swap(m_handle, other.m_handle);
245 archive.
SetInt(
"Version", moduleVersion);
250 const auto version = archive.
GetInt(
"Version");
268 return "MonoConversion";
275 if (info.IsSingleChannel() && info.HasIntensityChannel())
280 const auto bitDepth = info.GetStorageBitsPerChannel();
312 const auto outputFormat = GetOutputFormat(inputFormat);
314 if (inputFormat == outputFormat)
319 auto*
const inputImageHandle = peak::common::detail::BackendAccessor<peak::icv::Image>::BackendHandle(inputImage);
323 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ImageConverter_Convert(
324 m_handle, inputImageHandle,
static_cast<peak_common_pixel_format
>(outputFormat), &outputHandle);
327 return peak::common::Any(peak::common::detail::BackendAccessor<peak::icv::Image>::CreateInstance(outputHandle));
333 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ImageConverter_ReleaseBuffers(m_handle);
A type-erased container for any copyable value.
T & AnyCast()
Casts the stored value to the specified type.
Interface for a hierarchical key-value archive system.
virtual void SetBool(const std::string &key, bool value)=0
Stores a boolean value.
virtual void SetInt(const std::string &key, int64_t value)=0
Stores a 64-bit signed integer.
virtual int64_t GetInt(const std::string &key) const =0
Retrieves a 64-bit signed integer by key.
virtual bool GetBool(const std::string &key) const =0
Retrieves a boolean value by key.
For detailed information about the use of ids_peak_icv Image refer to the Image Guide.
peak::common::PixelFormat GetPixelFormat() const
Provides the pixel format of the image.
Mono conversion is an image pipeline module that converts images to a monochrome format.
MonoConversionModule()
Creates an instance of class MonoConversion.
const char * GetType() const override
Returns the type of the module for serialization purposes.
MonoConversionModule(const MonoConversionModule &other)=delete
Copy constructor for class MonoConversionModule is deleted.
~MonoConversionModule() override
void ReleaseBuffers() const
Frees unused internal buffers.
void Serialize(peak::common::serialization::IArchive &archive) const override
Serializes the object's internal state into the provided archive.
peak::icv::Image Process(const peak::icv::Image &input) const
Processes the input image, performing mono conversion if enabled.
void SetEnabled(bool enabled) override
Sets the enabled state of this module.
MonoConversionModule & operator=(const MonoConversionModule &other)=delete
Copy assignment for class MonoConversionModule is deleted.
void Deserialize(const peak::common::serialization::IArchive &archive) override
Restores the object's state from the provided archive.
void ResetToDefault() override
Does nothing for the mono conversion module.
bool IsEnabled() const override
Checks if the module is currently enabled.
Interface for a module used within a pipeline.
PixelFormat
Enum listing all supported pixel formats and their internal IDs.
@ Mono12
Mono 12-Bit pixel format.
@ Mono16
Mono 16-Bit pixel format.
@ Mono10
Mono 10-Bit pixel format.
@ Mono8
Mono 8-Bit pixel format.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
void ValidateVersion(int64_t version, const std::string &moduleName)
peak_icv_image * peak_icv_image_handle