45#ifndef UFO_VISION_COLOR_GRAY_HPP
46#define UFO_VISION_COLOR_GRAY_HPP
49#include <ufo/vision/color/flags.hpp>
73template <
class T =
float, ColorFlags Flags = ColorFlags::None>
74 requires(std::integral<T> || std::floating_point<T>)
85 requires(std::integral<T> || std::floating_point<T>)
103 Gray const&
b)
noexcept =
default;
114 requires(std::integral<T> || std::floating_point<T>)
140 Gray const&
b)
noexcept =
default;
151 requires(std::integral<T> || std::floating_point<T>)
174 Gray const&
b)
noexcept =
default;
185 requires(std::integral<T> || std::floating_point<T>)
216 Gray const&
b)
noexcept =
default;
225template <
class T, ColorFlags Flags>
228 if constexpr (
weightset(Flags) && std::floating_point<T>) {
229 return color.gray /
static_cast<T
>(color.weight);
281template <
class T, ColorFlags Flags>
284 out <<
"Gray: " << +c.gray;
286 out <<
" Alpha: " << +c.alpha;
289 out <<
" Weight: " << c.weight;
302template <
class T, ufo::ColorFlags Flags>
303struct std::formatter<
ufo::Gray<T, Flags>> {
304 constexpr auto parse(std::format_parse_context& ctx) {
return ctx.begin(); }
308 auto out = std::format_to(ctx.out(),
"Gray: {}", +c.gray);
310 out = std::format_to(out,
" Alpha: {}", +c.alpha);
313 out = std::format_to(out,
" Weight: {}", c.weight);
consteval bool alphaset(ColorFlags flags) noexcept
Returns true if the Alpha flag is set.
consteval bool weightset(ColorFlags flags) noexcept
Returns true if the Weight flag is set.
All vision-related classes and functions.
constexpr T b(Lab< T, Flags > color) noexcept
Returns the un-weighted blue–yellow axis value.
constexpr T gray(Gray< T, Flags > color) noexcept
Returns the un-weighted gray channel value.
constexpr T a(Lab< T, Flags > color) noexcept
Returns the un-weighted green–red axis value.
friend constexpr bool operator==(Gray const &a, Gray const &b) noexcept=default
Returns true if a and b are equal.
T alpha
Alpha channel (possibly pre-multiplied by weight).
float weight
Accumulation weight (positive).
friend constexpr bool operator==(Gray const &a, Gray const &b) noexcept=default
Returns true if a and b are equal.
T gray
Gray channel (possibly pre-multiplied by weight).
friend constexpr bool operator==(Gray const &a, Gray const &b) noexcept=default
Returns true if a and b are equal.
friend constexpr bool operator==(Gray const &a, Gray const &b) noexcept=default
Returns true if a and b are equal.
T gray
Gray channel (possibly pre-multiplied by weight).
float weight
Accumulation weight (positive).