9 #ifndef BOOST_GIL_CHANNEL_NUMERIC_OPERATIONS_HPP
10 #define BOOST_GIL_CHANNEL_NUMERIC_OPERATIONS_HPP
12 #include <boost/gil/channel.hpp>
14 namespace boost {
namespace gil {
34 template <
typename Channel1,
typename Channel2,
typename ChannelResult>
37 using ChannelRef1 =
typename channel_traits<Channel1>::const_reference;
38 using ChannelRef2 =
typename channel_traits<Channel2>::const_reference;
39 static_assert(std::is_convertible<ChannelRef1, ChannelResult>::value,
40 "ChannelRef1 not convertible to ChannelResult");
41 static_assert(std::is_convertible<ChannelRef2, ChannelResult>::value,
42 "ChannelRef2 not convertible to ChannelResult");
46 auto operator()(ChannelRef1 ch1, ChannelRef2 ch2)
const -> ChannelResult
48 return ChannelResult(ch1) + ChannelResult(ch2);
55 template <
typename Channel1,
typename Channel2,
typename ChannelResult>
58 using ChannelRef1 =
typename channel_traits<Channel1>::const_reference;
59 using ChannelRef2 =
typename channel_traits<Channel2>::const_reference;
60 static_assert(std::is_convertible<ChannelRef1, ChannelResult>::value,
61 "ChannelRef1 not convertible to ChannelResult");
62 static_assert(std::is_convertible<ChannelRef2, ChannelResult>::value,
63 "ChannelRef2 not convertible to ChannelResult");
67 auto operator()(ChannelRef1 ch1, ChannelRef2 ch2)
const -> ChannelResult
69 return ChannelResult(ch1) - ChannelResult(ch2);
76 template <
typename Channel1,
typename Channel2,
typename ChannelResult>
79 using ChannelRef1 =
typename channel_traits<Channel1>::const_reference;
80 using ChannelRef2 =
typename channel_traits<Channel2>::const_reference;
81 static_assert(std::is_convertible<ChannelRef1, ChannelResult>::value,
82 "ChannelRef1 not convertible to ChannelResult");
83 static_assert(std::is_convertible<ChannelRef2, ChannelResult>::value,
84 "ChannelRef2 not convertible to ChannelResult");
88 auto operator()(ChannelRef1 ch1, ChannelRef2 ch2)
const -> ChannelResult
90 return ChannelResult(ch1) * ChannelResult(ch2);
97 template <
typename Channel1,
typename Channel2,
typename ChannelResult>
100 using ChannelRef1 =
typename channel_traits<Channel1>::const_reference;
101 using ChannelRef2 =
typename channel_traits<Channel2>::const_reference;
102 static_assert(std::is_convertible<ChannelRef1, ChannelResult>::value,
103 "ChannelRef1 not convertible to ChannelResult");
104 static_assert(std::is_convertible<ChannelRef2, ChannelResult>::value,
105 "ChannelRef2 not convertible to ChannelResult");
109 auto operator()(ChannelRef1 ch1, ChannelRef2 ch2)
const -> ChannelResult
111 return ChannelResult(ch1) / ChannelResult(ch2);
118 template <
typename Channel,
typename Scalar,
typename ChannelResult>
121 using ChannelRef =
typename channel_traits<Channel>::const_reference;
122 static_assert(std::is_convertible<ChannelRef, ChannelResult>::value,
123 "ChannelRef not convertible to ChannelResult");
124 static_assert(std::is_scalar<Scalar>::value,
"Scalar not a scalar");
125 static_assert(std::is_convertible<Scalar, ChannelResult>::value,
126 "Scalar not convertible to ChannelResult");
128 auto operator()(ChannelRef channel, Scalar
const& scalar)
const -> ChannelResult
130 return ChannelResult(channel) + ChannelResult(scalar);
137 template <
typename Channel,
typename Scalar,
typename ChannelResult>
140 using ChannelRef =
typename channel_traits<Channel>::const_reference;
141 static_assert(std::is_convertible<ChannelRef, ChannelResult>::value,
142 "ChannelRef not convertible to ChannelResult");
143 static_assert(std::is_scalar<Scalar>::value,
"Scalar not a scalar");
144 static_assert(std::is_convertible<Scalar, ChannelResult>::value,
145 "Scalar not convertible to ChannelResult");
149 auto operator()(ChannelRef channel, Scalar
const& scalar)
const -> ChannelResult
152 return ChannelResult(channel - scalar);
159 template <
typename Channel,
typename Scalar,
typename ChannelResult>
162 using ChannelRef =
typename channel_traits<Channel>::const_reference;
163 static_assert(std::is_convertible<ChannelRef, ChannelResult>::value,
164 "ChannelRef not convertible to ChannelResult");
165 static_assert(std::is_scalar<Scalar>::value,
"Scalar not a scalar");
166 static_assert(std::is_convertible<Scalar, ChannelResult>::value,
167 "Scalar not convertible to ChannelResult");
171 auto operator()(ChannelRef channel, Scalar
const& scalar)
const -> ChannelResult
173 return ChannelResult(channel) * ChannelResult(scalar);
180 template <
typename Channel,
typename Scalar,
typename ChannelResult>
183 using ChannelRef =
typename channel_traits<Channel>::const_reference;
184 static_assert(std::is_convertible<ChannelRef, ChannelResult>::value,
185 "ChannelRef not convertible to ChannelResult");
186 static_assert(std::is_scalar<Scalar>::value,
"Scalar not a scalar");
187 static_assert(std::is_convertible<Scalar, ChannelResult>::value,
188 "Scalar not convertible to ChannelResult");
192 auto operator()(ChannelRef channel, Scalar
const& scalar)
const -> ChannelResult
194 return ChannelResult(channel) / ChannelResult(scalar);
201 template <
typename Channel>
204 using ChannelRef =
typename channel_traits<Channel>::reference;
206 auto operator()(ChannelRef channel)
const -> ChannelRef
219 template <
typename Channel>
222 using ChannelRef =
typename channel_traits<Channel>::reference;
224 auto operator()(ChannelRef channel)
const -> ChannelRef
226 channel = Channel(0);
234 template <
typename Channel1,
typename Channel2>
237 using ChannelRef1 =
typename channel_traits<Channel1>::const_reference;
238 using ChannelRef2 =
typename channel_traits<Channel2>::reference;
239 static_assert(std::is_convertible<ChannelRef1, Channel2>::value,
240 "ChannelRef1 not convertible to Channel2");
244 auto operator()(ChannelRef1 ch1, ChannelRef2 ch2)
const -> ChannelRef2
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36
Definition: channel_numeric_operations.hpp:236
auto operator()(ChannelRef1 ch1, ChannelRef2 ch2) const -> ChannelRef2
Definition: channel_numeric_operations.hpp:244
Arithmetic operation of dividing channel value by scalar.
Definition: channel_numeric_operations.hpp:182
auto operator()(ChannelRef channel, Scalar const &scalar) const -> ChannelResult
Definition: channel_numeric_operations.hpp:192
Arithmetic operation of division of two channel values.
Definition: channel_numeric_operations.hpp:99
auto operator()(ChannelRef1 ch1, ChannelRef2 ch2) const -> ChannelResult
Definition: channel_numeric_operations.hpp:109
Arithmetic operation of dividing channel value by 2.
Definition: channel_numeric_operations.hpp:203
Arithmetic operation of subtracting scalar from channel value.
Definition: channel_numeric_operations.hpp:139
auto operator()(ChannelRef channel, Scalar const &scalar) const -> ChannelResult
Definition: channel_numeric_operations.hpp:149
Arithmetic operation of subtraction of two channel values.
Definition: channel_numeric_operations.hpp:57
auto operator()(ChannelRef1 ch1, ChannelRef2 ch2) const -> ChannelResult
Definition: channel_numeric_operations.hpp:67
Arithmetic operation of channel value by a scalar.
Definition: channel_numeric_operations.hpp:161
auto operator()(ChannelRef channel, Scalar const &scalar) const -> ChannelResult
Definition: channel_numeric_operations.hpp:171
Arithmetic operation of multiplication of two channel values.
Definition: channel_numeric_operations.hpp:78
auto operator()(ChannelRef1 ch1, ChannelRef2 ch2) const -> ChannelResult
Definition: channel_numeric_operations.hpp:88
Arithmetic operation of adding scalar to channel value.
Definition: channel_numeric_operations.hpp:120
Arithmetic operation of addition of two channel values.
Definition: channel_numeric_operations.hpp:36
auto operator()(ChannelRef1 ch1, ChannelRef2 ch2) const -> ChannelResult
Definition: channel_numeric_operations.hpp:46
Operation of setting channel value to zero.
Definition: channel_numeric_operations.hpp:221