IDS peak AFL v2.0.2
Loading...
Searching...
No Matches
peak_common_channel.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
15#include <ostream>
16#include <string>
17
18namespace peak
19{
20namespace common
21{
22
46
51PEAK_COMMON_NO_DISCARD inline std::string ToString(Channel channel)
52{
53 switch (channel)
54 {
56 return "Intensity";
57 case Channel::Red:
58 return "Red";
59 case Channel::Green:
60 return "Green";
61 case Channel::Blue:
62 return "Blue";
63 case Channel::Alpha:
64 return "Alpha";
65 case Channel::X:
66 return "X";
67 case Channel::Y:
68 return "Y";
69 case Channel::Z:
70 return "Z";
71 case Channel::Bayer:
72 return "Bayer";
74 return "ChromaU";
76 return "ChromaV";
77 }
78
79 throw InvalidParameterException("The specified channel " + std::to_string(static_cast<int>(channel)) + " is unknown.");
80}
81
85inline std::ostream& operator<<(std::ostream& os, const Channel channel)
86{
87 return os << ToString(channel);
88}
89
90namespace detail
91{
92
96PEAK_COMMON_NO_DISCARD inline Channel ToChannel(const std::string& channel)
97{
98 if (channel == "Intensity")
99 {
100 return Channel::Intensity;
101 }
102 if (channel == "Red")
103 {
104 return Channel::Red;
105 }
106 if (channel == "Green")
107 {
108 return Channel::Green;
109 }
110 if (channel == "Blue")
111 {
112 return Channel::Blue;
113 }
114 if (channel == "Alpha")
115 {
116 return Channel::Alpha;
117 }
118 if (channel == "X")
119 {
120 return Channel::X;
121 }
122 if (channel == "Y")
123 {
124 return Channel::Y;
125 }
126 if (channel == "Z")
127 {
128 return Channel::Z;
129 }
130 if (channel == "Bayer")
131 {
132 return Channel::Bayer;
133 }
134 if (channel == "ChromaU")
135 {
136 return Channel::ChromaU;
137 }
138 if (channel == "ChromaV")
139 {
140 return Channel::ChromaV;
141 }
142
143 throw InvalidParameterException("The specified channel '" + channel + "' is unknown.");
144}
145} // namespace detail
146
147} // namespace common
148} // namespace peak
Thrown when a function receives an invalid parameter.
Definition peak_common_exceptions.hpp:58
Channel
Represents the various data channels in image or spatial data formats.
Definition peak_common_channel.hpp:33
@ X
Definition peak_common_channel.hpp:39
@ Z
Definition peak_common_channel.hpp:41
@ ChromaV
Definition peak_common_channel.hpp:44
@ Y
Definition peak_common_channel.hpp:40
@ Alpha
Definition peak_common_channel.hpp:38
@ Intensity
Definition peak_common_channel.hpp:34
@ Blue
Definition peak_common_channel.hpp:37
@ ChromaU
Definition peak_common_channel.hpp:43
@ Green
Definition peak_common_channel.hpp:36
@ Bayer
Definition peak_common_channel.hpp:42
@ Red
Definition peak_common_channel.hpp:35
Channel ToChannel(const std::string &channel)
Definition peak_common_channel.hpp:96
Root namespace for common types and interfaces shared across multiple libraries.
Definition peak_common_math.hpp:22
std::string ToString(Channel channel)
Converts a Channel enum value to its string representation.
Definition peak_common_channel.hpp:51