148 PEAK_COMMON_NO_DISCARD
bool IsEnabled()
const override;
157 PEAK_COMMON_NO_DISCARD
const char*
GetType()
const override;
413 void UpdateMatrixInAutoFeatureModule()
const;
415 static constexpr auto saturationKey =
"Saturation";
416 static constexpr auto matrixKey =
"ColorCorrection";
417 static constexpr auto chromaticAdaptionKey =
"ChromaticAdaption";
419 peak_icv_color_matrix_transformation_handle m_handle{};
421 std::shared_ptr<modules::IAutoFeature> m_autoFeatureModule;
427 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_Create(&m_handle);
433 if (m_handle !=
nullptr)
435 std::ignore = PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_Destroy(m_handle);
441 m_handle = std::exchange(other.m_handle,
nullptr);
448 if (m_handle !=
nullptr)
451 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_Destroy(m_handle);
455 m_handle = std::exchange(other.m_handle,
nullptr);
463 archive.
SetInt(
"Version", 2);
468 archive.
SetArchive(saturationKey, saturationArchive);
473 const auto colorCorrectionMatrix =
GetMatrix();
474 colorCorrectionMatrix.Serialize(*matrixArchive);
485 archive.
SetArchive(chromaticAdaptionKey, chromaticAdaption);
490 const auto version = archive.
GetInt(
"Version");
494 const auto saturationArchive = archive.
GetArchive(saturationKey);
495 const auto matrixArchive = archive.
GetArchive(matrixKey);
504 SetSaturation(
static_cast<float>(saturationArchive->GetDouble(
"Value")));
508 const auto chromaticAdaptionArchive = archive.
GetArchive(chromaticAdaptionKey);
509 if (chromaticAdaptionArchive->HasKey(
"ColorTemperature"))
511 SetColorTemperature(
static_cast<uint32_t
>(chromaticAdaptionArchive->GetInt(
"ColorTemperature")));
533 UpdateMatrixInAutoFeatureModule();
543 return "ColorMatrixTransformation";
553 UpdateMatrixInAutoFeatureModule();
560 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_GetColorCorrectionMatrix(
561 m_handle,
reinterpret_cast<peak_icv_color_correction_matrix*
>(&colorCorrectionMatrix.At(0, 0)));
564 return colorCorrectionMatrix;
570 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_SetColorCorrectionMatrix(
571 m_handle, *
reinterpret_cast<const peak_icv_color_correction_matrix*
>(&matrix.
At(0, 0)));
576 UpdateMatrixInAutoFeatureModule();
583 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_SetSaturation(m_handle, saturation);
587 UpdateMatrixInAutoFeatureModule();
595 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_GetSaturation(m_handle, &saturation);
602 peak_common_interval_f intervalF;
604 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_GetSaturationRange(m_handle, &intervalF);
607 return { intervalF.minimum, intervalF.maximum };
617 auto needsProcessing = [&] {
620 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_NeedsProcessing(m_handle, &value);
636 if (!isColorImage || info.
IsPacked())
641 auto*
const inputImageHandle = peak::common::detail::BackendAccessor<peak::icv::Image>::BackendHandle(inputImage);
644 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_ProcessInplace(m_handle, inputImageHandle);
650inline void ColorMatrixTransformationModule::UpdateMatrixInAutoFeatureModule()
const
652 if (m_autoFeatureModule !=
nullptr)
654 std::array<float, 9> data{};
657 std::copy(matrix.cbegin(), matrix.cend(), data.begin());
659 m_autoFeatureModule->SetColorCorrectionMatrix(data);
665 m_autoFeatureModule =
module;
666 UpdateMatrixInAutoFeatureModule();
673 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_GetEffectiveMatrix(
674 m_handle,
reinterpret_cast<peak_icv_color_correction_matrix*
>(&matrix.At(0, 0)));
682 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_Saturation_SetEnabled(m_handle, enabled);
684 UpdateMatrixInAutoFeatureModule();
690 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_ColorCorrection_SetEnabled(m_handle, enabled);
692 UpdateMatrixInAutoFeatureModule();
699 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_Saturation_IsEnabled(m_handle, &enabled);
708 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_ColorCorrection_IsEnabled(m_handle, &enabled);
715 peak_icv_chromatic_adaption_algorithm algorithm;
717 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_ChromaticAdaption_GetAlgorithm(m_handle, &algorithm);
724 peak_icv_color_space colorSpace;
726 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_ChromaticAdaption_GetTargetColorSpace(
727 m_handle, &colorSpace);
734 const auto cAlgorithm =
static_cast<peak_icv_chromatic_adaption_algorithm
>(algorithm);
736 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_ChromaticAdaption_SetAlgorithm(m_handle, cAlgorithm);
738 UpdateMatrixInAutoFeatureModule();
743 const auto cColorSpace =
static_cast<peak_icv_color_space
>(colorSpace);
745 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_ChromaticAdaption_SetTargetColorSpace(
746 m_handle, cColorSpace);
748 UpdateMatrixInAutoFeatureModule();
753 peak_common_range_u cRange{};
755 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_ChromaticAdaption_GetColorTemperatureRange(
759 return peak::common::detail::BackendAccessor<peak::common::RangeU>::CreateInstance({ cRange });
765 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_ChromaticAdaption_SetColorTemperature(
766 m_handle, temperature);
768 UpdateMatrixInAutoFeatureModule();
775 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_ChromaticAdaption_HasColorTemperature(
783 uint32_t temperature{};
785 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_ChromaticAdaption_GetColorTemperature(
786 m_handle, &temperature);
794 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_ChromaticAdaption_ResetColorTemperature(m_handle);
796 UpdateMatrixInAutoFeatureModule();
802 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_ChromaticAdaption_SetEnabled(m_handle, enabled);
804 UpdateMatrixInAutoFeatureModule();
811 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_ColorMatrixTransformation_ChromaticAdaption_IsEnabled(m_handle, &enabled);
A type-erased container for any copyable value.
T & AnyCast()
Casts the stored value to the specified type.
Represents a continuous numeric interval with inclusive lower and upper bounds.
Represents a numeric range with defined boundaries and a fixed increment.
Interface for a hierarchical key-value archive system.
virtual std::shared_ptr< IArchive > GetArchive(const std::string &key) const =0
Retrieves a nested archive by key.
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 std::shared_ptr< IArchive > CreateArchive() const =0
Creates a new, empty archive instance.
virtual void SetArchive(const std::string &key, const std::shared_ptr< IArchive > &value)=0
Stores a nested archive object.
constexpr Type & At(std::size_t row, std::size_t col)
Accesses the element at the specified row and column.
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.
void Deserialize(const peak::common::serialization::IArchive &archive) override
Restores the object's state from the provided archive.
Adjusts to changes in lighting conditions to maintain consistent color perception despite variations ...
Color correction applies a 3x3 ColorCorrectionMatrix to the image.
Adjusts the saturation of an image by modifying a 3x3 ColorCorrectionMatrix.
Interface for a module used within a pipeline.
ColorSpace
Color spaces supported by the chromatic adaptation feature.
ChromaticAdaptionAlgorithm
Algorithm used for chromatic adaption.
@ Bradford
Bradford adaption algorithm (Default).
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
ColorSpace ToColorSpace(const std::string &colorSpace)
std::string ToString(const DebayerConversionPolicy &policy)
void ValidateVersion(int64_t version, const std::string &moduleName)
ChromaticAdaptionAlgorithm ToChromaticAdaptionAlgorithm(const std::string &algorithm)