IDS peak ICV v1.1.0
Loading...
Searching...
No Matches
peak_icv_binning_mode.hpp
Go to the documentation of this file.
1
11#pragma once
12
13#include <peak_common_c/detail/peak_common_defines.h>
15
16#include <string>
17
18namespace peak
19{
20namespace pipeline
21{
30enum class BinningMode
31{
33 Average = 0,
34
36 Sum = 1
37};
38
47PEAK_COMMON_NO_DISCARD inline std::string ToString(BinningMode mode)
48{
49 if (mode == BinningMode::Average)
50 {
51 return "Average";
52 }
53 if (mode == BinningMode::Sum)
54 {
55 return "Sum";
56 }
57 const auto modeStr = std::to_string(static_cast<int>(mode));
58 throw peak::icv::NotSupportedException("The given binning mode " + modeStr + " is unknown!");
59}
60
69inline std::ostream& operator<<(std::ostream& os, BinningMode mode)
70{
71 return os << ToString(mode);
72}
73
74namespace detail
75{
84PEAK_COMMON_NO_DISCARD inline BinningMode ToBinningMode(const std::string& mode)
85{
86 if (mode == "Average")
87 {
89 }
90 if (mode == "Sum")
91 {
92 return BinningMode::Sum;
93 }
94 throw peak::icv::NotSupportedException("The given binning mode " + mode + " is unknown! ");
95}
96} // namespace detail
97
98} // namespace pipeline
99} // namespace peak
Thrown when a requested operation is not implemented or supported.
BinningMode
Mode parameter for the binning algorithm.
@ Sum
The pixel values of neighboring rows and/or columns are summed during binning.
@ Average
The averaged pixel values of neighboring rows and/or columns are computed during binning.
BinningMode ToBinningMode(const std::string &mode)
Converts a string representation to a BinningMode enum value.
std::string ToString(BinningMode mode)
Converts a BinningMode enum value to its string representation.
std::ostream & operator<<(std::ostream &os, BinningMode mode)
Stream output operator for BinningMode enum.