27 #ifndef MLN_VALUE_GRAYLEVEL_F_HH
28 # define MLN_VALUE_GRAYLEVEL_F_HH
36 # include <mln/value/ops.hh>
38 # include <mln/core/contract.hh>
39 # include <mln/metal/math/pow.hh>
40 # include <mln/metal/bexpr.hh>
41 # include <mln/literal/ops.hh>
43 # include <mln/value/float01_f.hh>
44 # include <mln/trait/value_.hh>
61 namespace internal {
struct gray_f; }
63 template <
unsigned n>
struct graylevel;
76 typedef mln::value::internal::gray_f ret;
82 typedef mln::value::internal::gray_f ret;
87 typedef mln::value::internal::gray_f ret;
93 typedef mln::value::internal::gray_f ret;
99 typedef mln::value::internal::gray_f ret;
105 typedef mln::value::internal::gray_f ret;
108 template <
typename I >
109 struct set_binary_< op::
times,
113 typedef mln::value::internal::gray_f ret;
116 template <
typename I >
117 struct set_binary_< op::
times,
121 typedef mln::value::internal::gray_f ret;
125 template <
typename F >
126 struct set_binary_< op::
times,
128 mln::value::Floating, F >
130 typedef mln::value::internal::gray_f ret;
133 template <
typename F >
134 struct set_binary_< op::
times,
135 mln::value::Floating, F,
138 typedef mln::value::internal::gray_f ret;
142 template <
typename S >
145 typedef mln::value::internal::gray_f ret;
148 template <
typename S >
151 typedef mln::value::internal::gray_f ret;
156 template <
typename T>
struct value_;
160 struct value_<mln::value::graylevel_f>
170 nbits = mln_nbits(equiv_),
174 typedef trait::value::nature::floating nature;
175 typedef trait::value::kind::gray kind;
176 typedef mln_trait_value_quant_(equiv_) quant;
178 static const equiv_ min() {
return 0; }
179 static const equiv_
max() {
return 1; }
180 static const equiv_ epsilon() {
return mln_epsilon(equiv_); }
196 public Floating< graylevel_f >,
198 public internal::value_like_< float01_f,
217 template <
unsigned n>
220 template <
unsigned n>
233 graylevel_f&
operator=(
const mln::literal::medium_gray_t&);
238 template <
unsigned n>
249 std::ostream& operator<<(std::ostream& ostr,
const graylevel_f& g);
257 template <
unsigned n>
259 operator+(const graylevel_f& lhs, const
graylevel<n>& rhs);
261 template <
unsigned n>
262 mln_trait_op_plus(graylevel_f,
graylevel<n>)
263 operator+(const
graylevel<n>& lhs, const graylevel_f& rhs);
266 mln_trait_op_minus_(graylevel_f, graylevel_f)
267 operator-(const graylevel_f& lhs, const graylevel_f& rhs);
270 mln_trait_op_times_(graylevel_f, graylevel_f)
271 operator*(const graylevel_f& lhs, const graylevel_f& rhs);
277 template <
unsigned n, typename T>
278 mln_trait_op_times(graylevel_f, T)
279 operator*(const graylevel_f& lhs, const T& rhs);
282 template <
unsigned n, typename T>
283 mln_trait_op_times(graylevel_f, T)
284 operator*(const T& lhs, const graylevel_f& rhs);
287 template <
unsigned n, typename T>
289 operator/(const graylevel_f& lhs, const T& rhs);
294 template <typename I>
295 mln_trait_op_times(graylevel_f, I)
296 operator*(const graylevel_f& lhs, const
Integer<I>& rhs);
299 template <typename I>
300 mln_trait_op_times(I, graylevel_f)
301 operator*(const
Integer<I>& lhs, const graylevel_f& rhs);
304 template <typename I>
305 mln_trait_op_div(graylevel_f, I)
306 operator/(const graylevel_f& lhs, const
Integer<I>& rhs);
309 template <typename I>
310 mln_trait_op_div(I, graylevel_f)
311 operator/(const
Integer<I>& lhs, const graylevel_f& rhs);
316 template <typename F>
317 mln_trait_op_times(graylevel_f, F)
318 operator*(const graylevel_f& lhs, const Floating<F>& rhs);
321 template <typename F>
322 mln_trait_op_times(F, graylevel_f)
323 operator*(const Floating<F>& lhs, const graylevel_f& rhs);
327 template <typename F>
328 mln_trait_op_div(graylevel_f, F)
329 operator/(const graylevel_f& lhs, const Floating<F>& rhs);
332 template <typename F>
333 mln_trait_op_div(F, graylevel_f)
334 operator/(const Floating<F>& lhs, const graylevel_f& rhs);
337 # ifndef MLN_INCLUDE_ONLY
350 mln_precondition(val >= 0);
351 mln_precondition(val <= 1);
359 mln_precondition(val >= 0);
360 mln_precondition(val <= 1);
365 template <
unsigned n>
368 mln_precondition(rhs.
to_float() >= 0);
369 mln_precondition(rhs.
to_float() <= 1);
373 template <
unsigned n>
377 mln_precondition(rhs.
to_float() >= 0);
378 mln_precondition(rhs.
to_float() <= 1);
385 : Floating<graylevel_f>()
394 mln_precondition(rhs.v_ >= 0);
395 mln_precondition(rhs.v_ <= 1);
442 template <
unsigned n>
459 std::ostream& operator<<(std::ostream& ostr,
const graylevel_f& g)
461 return ostr << g.
value() <<
"/gl_f";
464 # endif // ! MLN_INCLUDE_ONLY
474 #endif // ! MLN_VALUE_GRAYLEVEL_F_HH