16#include <peak_icv_c/algorithms/preprocessing/peak_icv_image_converter.h>
203 constexpr static int moduleVersion{ 1 };
205 bool m_enabled{
true };
206 peak_icv_image_converter_handle m_handle{};
212 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ImageConverter_Create(&m_handle);
218 if (m_handle !=
nullptr)
220 std::ignore = PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ImageConverter_Destroy(m_handle);
226 m_enabled = other.m_enabled;
227 std::swap(m_handle, other.m_handle);
234 m_enabled = other.m_enabled;
235 std::swap(m_handle, other.m_handle);
244 archive.
SetInt(
"Version", moduleVersion);
249 const auto version = archive.
GetInt(
"Version");
267 return "MonoConversion";
274 if (info.IsSingleChannel() && info.HasIntensityChannel())
279 const auto bitDepth = info.GetStorageBitsPerChannel();
311 const auto outputFormat = GetOutputFormat(inputFormat);
313 if (inputFormat == outputFormat)
318 auto*
const inputImageHandle = peak::common::detail::BackendAccessor<peak::icv::Image>::BackendHandle(inputImage);
322 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ImageConverter_Convert(
323 m_handle, inputImageHandle,
static_cast<peak_common_pixel_format
>(outputFormat), &outputHandle);
326 return peak::common::Any(peak::common::detail::BackendAccessor<peak::icv::Image>::CreateInstance(outputHandle));
332 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.
#define PEAK_COMMON_NO_DISCARD
Compatability macro for the nodiscard attribute.
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