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