UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
Vision Module

All vision-related classes and functions. More...

Concepts

concept  ufo::Color
 Identifies any UFO color instantiation (Gray, Lab, Lch, Lrgb, Rgb).
 
concept  ufo::FloatingPointColor
 Colors with a floating-point channel type.
 
concept  ufo::IntegralColor
 Colors with an integral channel type.
 
concept  ufo::ColorWithAlpha
 Colors that include an alpha channel.
 
concept  ufo::ColorWithWeight
 Colors that include a weight channel.
 
concept  ufo::ColorWithAlphaAndWeight
 Colors with both alpha and weight channels.
 
concept  ufo::BasicColor
 Colors without optional channels (no alpha, no weight).
 
concept  ufo::GrayColor
 Grayscale colors (Gray<T, Flags>).
 
concept  ufo::RgbColor
 Gamma-encoded sRgb colors (Rgb<T, Flags>).
 
concept  ufo::LinearRgbColor
 Linear-light Rgb colors (Lrgb<T, Flags>).
 
concept  ufo::LabColor
 Oklab perceptual colors (Lab<T, Flags>).
 
concept  ufo::LchColor
 OkLch cylindrical colors (Lch<T, Flags>).
 
concept  ufo::RgbFamilyColor
 Rgb-family colors (gamma-encoded or linear: Rgb or Lrgb).
 
concept  ufo::PerceptualColor
 Perceptual color models (Lab or Lch).
 
concept  ufo::DisplayColor
 Color models suitable for display (Rgb, Lrgb, or Gray).
 
concept  ufo::HueBasedColor
 Color models with a hue component (Lch).
 
concept  ufo::LightnessBasedColor
 Color models with a lightness component (Lab or Lch).
 
concept  ufo::AccumulableColor
 Colors that support weighted accumulation (floating-point with weight).
 
concept  ufo::ImageColor
 Colors suitable for image processing (integral, or floating-point display colors).
 
concept  ufo::HDRColor
 Colors suitable for high dynamic range operations (floating-point display colors).
 
concept  ufo::TransparentColor
 Colors with transparency support.
 
concept  ufo::CompactColor
 Colors optimized for compact storage (integral, at most 16 bits per channel).
 
concept  ufo::SameValueType
 Two colors with the same underlying channel type.
 
concept  ufo::SameColorModel
 Two colors with the same color model.
 
concept  ufo::SameColorFlags
 Two colors with the same flags.
 
concept  ufo::EquivalentColors
 Two colors that are equivalent (same model, channel type, and flags).
 
concept  ufo::ConvertibleColor
 Colors with compatible channel types for conversion.
 
concept  ufo::BlendableColors
 Colors that can be blended together (same model and mutually convertible types).
 
concept  ufo::ColorWithValueType
 Colors with a specific channel type.
 
concept  ufo::Color8Bit
 Colors with an 8-bit channel type.
 
concept  ufo::Color16Bit
 Colors with a 16-bit channel type.
 
concept  ufo::ColorFloat
 Colors with a 32-bit float channel type.
 
concept  ufo::ColorDouble
 Colors with a 64-bit double channel type.
 
concept  ufo::GammaCorrectable
 Colors that support gamma correction (Rgb family).
 
concept  ufo::ColorSpaceConvertible
 Colors that support color space conversion between display color models.
 
concept  ufo::PerceptuallyUniform
 Colors that operate in a perceptually uniform space.
 
concept  ufo::IsColor
 Convenience alias: any UFO color instantiation.
 

Classes

struct  ufo::Gray< T, Flags >
 Grayscale color. More...
 
class  ufo::Image< T >
 Image class for storing and manipulating 2D pixel data. More...
 
struct  ufo::Lab< T, Flags >
 Oklab perceptual color. More...
 
struct  ufo::Lch< T, Flags >
 OkLch color. More...
 
struct  ufo::Lrgb< T, Flags >
 Linear-light RGB color. More...
 
struct  ufo::OrthogonalCamera
 Orthogonal camera model for ray-generation and projection. More...
 
struct  ufo::OrthogonalIntrinsics
 Stores the intrinsic parameters of an orthogonal camera. More...
 
struct  ufo::PerspectiveCamera
 Perspective camera model for ray-generation and projection. More...
 
struct  ufo::PerspectiveIntrinsics
 Stores the intrinsic parameters of a perspective camera. More...
 
struct  ufo::Rgb< T, Flags >
 Gamma-encoded sRGB color. More...
 
enum class  ColorDeltaE { EUCLIDEAN , OK }
 
template<Color C>
constexpr float ufo::deltaEEuclideanSquared (C const &color, C const &sample)
 Computes the squared Euclidean distance between two colors.
 
template<Color C>
constexpr float ufo::deltaEEuclidean (C const &color, C const &sample)
 Computes the Euclidean distance between two colors.
 
template<Color C>
constexpr float ufo::deltaEOkSquared (C const &color, C const &sample, float const ab_scale=2.0f)
 Computes the squared Ok delta E distance between two colors.
 
template<Color C>
constexpr float ufo::deltaEOk (C const &color, C const &sample, float const ab_scale=2.0f)
 Computes the Ok delta E distance between two colors.
 
template<Color C>
constexpr float ufo::deltaESquared (C const &color, C const &sample, ColorDeltaE method=ColorDeltaE::EUCLIDEAN, ColorSpace space=ColorSpace::NATIVE)
 Computes the squared distance between two colors using a specified method.
 
template<Color C>
constexpr float ufo::deltaE (C const &color, C const &sample, ColorDeltaE method=ColorDeltaE::EUCLIDEAN, ColorSpace space=ColorSpace::NATIVE)
 Computes the distance between two colors using a specified method.
 
enum class  ufo::ColorFlags : std::uint8_t { ufo::ColorFlags::None = 0 , ufo::ColorFlags::Alpha = 1 << 0 , ufo::ColorFlags::Weight = 1 << 1 , ufo::ColorFlags::All = Alpha | Weight }
 Bitmask controlling optional fields in a Color specialisation. More...
 
constexpr ColorFlags ufo::operator| (ColorFlags a, ColorFlags b) noexcept
 Bitwise OR for combining ColorFlags.
 
constexpr ColorFlags ufo::operator& (ColorFlags a, ColorFlags b) noexcept
 Bitwise AND for testing ColorFlags.
 
constexpr ColorFlags ufo::operator~ (ColorFlags a) noexcept
 Bitwise complement - inverts all valid ColorFlags bits.
 
consteval bool ufo::alphaset (ColorFlags flags) noexcept
 Returns true if the Alpha flag is set.
 
consteval bool ufo::weightset (ColorFlags flags) noexcept
 Returns true if the Weight flag is set.
 
constexpr std::string_view ufo::toString (ColorFlags flags) noexcept
 Returns a human-readable string for a ColorFlags value.
 
std::ostream & ufo::operator<< (std::ostream &os, ColorFlags flags)
 Stream-insertion operator for ColorFlags.
 
enum class  ufo::ColorSpace {
  NATIVE , Rgb , Oklab , Oklab2 ,
  Oklch
}
 Selects the working color space for color operations. More...
 
constexpr std::string_view ufo::toString (ColorSpace cs) noexcept
 Returns a human-readable name for cs.
 
std::ostream & ufo::operator<< (std::ostream &out, ColorSpace cs)
 Writes the color-space name to out.
 
enum class  ufo::ColorModel {
  Gray , Lab , Lch , Lrgb ,
  Rgb
}
 Tag identifying the color model of a color type. More...
 
template<class... Ts>
using ufo::first_color_t = typename first_color< Ts... >::type
 
template<class T >
using ufo::value_type_t = typename color_traits< T >::value_type
 Extracts the channel scalar type of a color.
 
template<class T >
using ufo::alpha_type_t = typename color_traits< T >::value_type
 Extracts the alpha scalar type of a color.
 
template<class T >
using ufo::add_alpha_t = typename color_traits< T >::template rebind_flags< color_traits< T >::flags|ColorFlags::Alpha >
 Adds ColorFlags::Alpha to a color type.
 
template<class T >
using ufo::remove_alpha_t = typename color_traits< T >::template rebind_flags< color_traits< T >::flags &~ColorFlags::Alpha >
 Removes ColorFlags::Alpha from a color type.
 
template<class T >
using ufo::weight_type_t = typename color_traits< T >::weight_type
 Extracts the weight scalar type of a color.
 
template<class T >
using ufo::add_weight_t = typename color_traits< T >::template rebind_flags< color_traits< T >::flags|ColorFlags::Weight >
 Adds ColorFlags::Weight to a color type.
 
template<class T >
using ufo::remove_weight_t = typename color_traits< T >::template rebind_flags< color_traits< T >::flags &~ColorFlags::Weight >
 Removes ColorFlags::Weight from a color type.
 
template<class T >
constexpr bool ufo::is_color_v = is_color<T>::value
 
template<class... Ts>
constexpr bool ufo::contains_color_v = contains_color<Ts...>::value
 
template<class T >
constexpr bool ufo::has_alpha_v = has_alpha<T>::value
 
template<class T >
constexpr auto ufo::init_alpha_v = init_alpha<T>::value
 
template<class T >
constexpr bool ufo::has_weight_v = has_weight<T>::value
 
template<Color C>
constexpr C & ufo::operator+= (C &lhs, C const &rhs)
 Adds two colors component-wise.
 
template<Color C>
constexpr C ufo::operator+ (C lhs, C const &rhs)
 Adds two colors component-wise.
 
template<Color C>
constexpr C & ufo::operator-= (C &lhs, C const &rhs)
 Subtracts two colors component-wise.
 
template<Color C>
constexpr C ufo::operator- (C lhs, C const &rhs)
 Subtracts two colors component-wise.
 
template<Color C>
constexpr C & ufo::operator*= (C &lhs, float rhs)
 Multiplies a color by a scalar.
 
template<Color C>
constexpr C & ufo::operator*= (C &lhs, C const &rhs)
 Multiplies two colors component-wise.
 
template<Color C>
constexpr C ufo::operator* (C lhs, C const &rhs)
 Multiplies two colors component-wise.
 
template<Color C>
constexpr C ufo::operator* (C lhs, float rhs)
 Multiplies a color by a scalar.
 
template<Color C>
constexpr C ufo::operator* (float lhs, C rhs)
 Multiplies a scalar by a color.
 
template<Color C>
constexpr C & ufo::operator/= (C &lhs, C const &rhs)
 Divides a color by another color component-wise.
 
template<Color C>
constexpr C & ufo::operator/= (C &lhs, float rhs)
 Divides a color by a scalar.
 
template<Color C>
constexpr C ufo::operator/ (C lhs, C const &rhs)
 Divides two colors component-wise.
 
template<Color C>
constexpr C ufo::operator/ (C lhs, float rhs)
 Divides a color by a scalar.
 
template<Color C>
constexpr C ufo::operator/ (float lhs, C rhs)
 Divides a scalar by a color.
 
template<Color C>
constexpr C ufo::average (C a, C const &b)
 Computes the average of two colors.
 
template<std::ranges::input_range R>
requires Color<std::ranges::range_value_t<R>>
constexpr std::ranges::range_value_t< R > ufo::average (R &&r)
 Computes the average of a range of colors.
 
template<std::input_iterator InputIt, std::sentinel_for< InputIt > Sentinel>
requires Color<std::iter_value_t<InputIt>>
constexpr std::iter_value_t< InputIt > ufo::average (InputIt first, Sentinel last)
 Computes the average of a range of colors.
 
template<Color C>
constexpr C ufo::average (std::initializer_list< C > il)
 Computes the average of an initializer list of colors.
 
template<Color C>
constexpr C ufo::blend (C a, C const &b, float t)
 Blends two colors using a factor t.
 
template<std::ranges::input_range R, std::ranges::input_range W>
requires Color<std::ranges::range_value_t<R>> && std::floating_point<std::ranges::range_value_t<W>>
constexpr std::ranges::range_value_t< R > ufo::blend (R &&r, W &&w)
 Blends multiple colors using a range of weights.
 
template<std::input_iterator InputIt1, std::sentinel_for< InputIt1 > Sentinel, std::input_iterator InputIt2>
requires Color<std::iter_value_t<InputIt1>> && std::floating_point<std::iter_value_t<InputIt2>>
constexpr std::iter_value_t< InputIt1 > ufo::blend (InputIt1 first, Sentinel last, InputIt2 first_weight)
 Blends multiple colors using a range of weights.
 
template<std::ranges::input_range R, std::floating_point T>
requires Color<std::ranges::range_value_t<R>>
constexpr std::ranges::range_value_t< R > ufo::blend (R &&r, std::initializer_list< T > w)
 Blends multiple colors using an initializer list of weights.
 
template<Color C, std::floating_point T>
constexpr C ufo::blend (std::initializer_list< C > r, std::initializer_list< T > w)
 Blends multiple colors using an initializer list of colors and weights.
 
template<Color To, Color From>
constexpr To ufo::convert (From const &color)
 Convert a color from one type to another.
 
template<typename T , ColorFlags F, Color From>
requires (std::floating_point<T> || std::integral<T>)
constexpr auto ufo::convert (From const &color)
 Convert a color from one type to another.
 
template<Color From, Color To>
constexpr void ufo::convert (From const &in, To &out)
 Convert a color from one type to another and assign to an output variable.
 
template<Color C, std::size_t N>
constexpr C ufo::colorMap (std::array< C, N > const &map, float value, float min_value, float max_value)
 Maps a value to a color using a color map.
 
template<Color C>
constexpr weight_type_t< C > ufo::weight (C color) noexcept
 Returns the weight of color, or 1 if color has no weight field.
 
template<Color C>
constexpr add_weight_t< C > ufo::addWeight (C color, float w=1.0f) noexcept
 Returns a copy of color with a weight field set to w.
 
template<Color C>
constexpr remove_weight_t< C > ufo::removeWeight (C color) noexcept
 Returns a copy of color with the weight field removed.
 

Detailed Description

All vision-related classes and functions.

Author
Daniel Duberg (danie.nosp@m.ldub.nosp@m.erg@g.nosp@m.mail.nosp@m..com)
See also
https://github.com/UnknownFreeOccupied/ufo
Version
1.0
Date
2026-02-22

Copyright (c) 2020-2026, Daniel Duberg All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Typedef Documentation

◆ add_alpha_t

template<class T >
using ufo::add_alpha_t = typedef typename color_traits<T>::template rebind_flags<color_traits<T>::flags | ColorFlags::Alpha>

Adds ColorFlags::Alpha to a color type.

Definition at line 308 of file type_traits.hpp.

◆ add_weight_t

template<class T >
using ufo::add_weight_t = typedef typename color_traits<T>::template rebind_flags<color_traits<T>::flags | ColorFlags::Weight>

Adds ColorFlags::Weight to a color type.

Definition at line 346 of file type_traits.hpp.

◆ alpha_type_t

template<class T >
using ufo::alpha_type_t = typedef typename color_traits<T>::value_type

Extracts the alpha scalar type of a color.

Definition at line 275 of file type_traits.hpp.

◆ first_color_t

template<class... Ts>
using ufo::first_color_t = typedef typename first_color<Ts...>::type

Definition at line 251 of file type_traits.hpp.

◆ remove_alpha_t

template<class T >
using ufo::remove_alpha_t = typedef typename color_traits<T>::template rebind_flags<color_traits<T>::flags & ~ColorFlags::Alpha>

Removes ColorFlags::Alpha from a color type.

Definition at line 316 of file type_traits.hpp.

◆ remove_weight_t

template<class T >
using ufo::remove_weight_t = typedef typename color_traits<T>::template rebind_flags<color_traits<T>::flags & ~ColorFlags::Weight>

Removes ColorFlags::Weight from a color type.

Definition at line 354 of file type_traits.hpp.

◆ value_type_t

template<class T >
using ufo::value_type_t = typedef typename color_traits<T>::value_type

Extracts the channel scalar type of a color.

Definition at line 263 of file type_traits.hpp.

◆ weight_type_t

template<class T >
using ufo::weight_type_t = typedef typename color_traits<T>::weight_type

Extracts the weight scalar type of a color.

Definition at line 340 of file type_traits.hpp.

Enumeration Type Documentation

◆ ColorDeltaE

enum class ufo::ColorDeltaE
strong

Definition at line 66 of file delta_e.hpp.

◆ ColorFlags

enum class ufo::ColorFlags : std::uint8_t
strong

Bitmask controlling optional fields in a Color specialisation.

Flags may be combined with operator|:

Identifies any UFO color instantiation (Gray, Lab, Lch, Lrgb, Rgb).
Definition concepts.hpp:73
Enumerator
None 

No optional fields.

Alpha 

Include an alpha channel.

Weight 

Include an accumulation weight.

All 

All optional fields.

Definition at line 70 of file flags.hpp.

◆ ColorModel

enum class ufo::ColorModel
strong

Tag identifying the color model of a color type.

Definition at line 76 of file type_traits.hpp.

◆ ColorSpace

enum class ufo::ColorSpace
strong

Selects the working color space for color operations.

Each enumerator names a distinct color space:

  • NATIVE - keep the data in whatever space it already occupies
  • Rgb - gamma-encoded sRgb
  • Oklab - Oklab perceptual color space (Björn Ottosson, 2020)
  • Oklab2 - improved Oklab variant with adjusted blue-yellow axis
  • Oklch - cylindrical form of Oklab (lightness, chroma, hue)

Definition at line 71 of file space.hpp.

Function Documentation

◆ addWeight()

template<Color C>
constexpr add_weight_t< C > ufo::addWeight ( color,
float  w = 1.0f 
)
constexprnoexcept

Returns a copy of color with a weight field set to w.

Parameters
[in]colorThe color to add a weight to.
[in]wThe weight to add to color.
Returns
A copy of color with a weight field set to w.

If color already carries a weight field it is returned unchanged and w is ignored. For floating-point channel types the stored channels are pre-multiplied by w.

Definition at line 87 of file weight.hpp.

◆ alphaset()

consteval bool ufo::alphaset ( ColorFlags  flags)
noexcept

Returns true if the Alpha flag is set.

Definition at line 114 of file flags.hpp.

◆ average() [1/4]

template<Color C>
constexpr C ufo::average ( a,
C const &  b 
)
constexpr

Computes the average of two colors.

Template Parameters
CThe color type.
Parameters
[in]aThe first color.
[in]bThe second color.
Returns
The average of the two colors.

Definition at line 77 of file average.hpp.

◆ average() [2/4]

template<std::input_iterator InputIt, std::sentinel_for< InputIt > Sentinel>
requires Color<std::iter_value_t<InputIt>>
constexpr std::iter_value_t< InputIt > ufo::average ( InputIt  first,
Sentinel  last 
)
constexpr

Computes the average of a range of colors.

Template Parameters
InputItThe input iterator type.
SentinelThe sentinel type.
Parameters
[in]firstThe beginning of the range.
[in]lastThe end of the range.
Returns
The average of the range of colors.

Definition at line 124 of file average.hpp.

◆ average() [3/4]

template<std::ranges::input_range R>
requires Color<std::ranges::range_value_t<R>>
constexpr std::ranges::range_value_t< R > ufo::average ( R &&  r)
constexpr

Computes the average of a range of colors.

Template Parameters
RThe range type.
Parameters
[in]rThe range of colors.
Returns
The average of the range of colors.

Definition at line 94 of file average.hpp.

◆ average() [4/4]

template<Color C>
constexpr C ufo::average ( std::initializer_list< C >  il)
constexpr

Computes the average of an initializer list of colors.

Template Parameters
CThe color type.
Parameters
[in]ilThe initializer list of colors.
Returns
The average of the initializer list of colors.

Definition at line 136 of file average.hpp.

◆ blend() [1/5]

template<Color C>
constexpr C ufo::blend ( a,
C const &  b,
float  t 
)
constexpr

Blends two colors using a factor t.

Template Parameters
CThe color type.
Parameters
[in]aThe first color.
[in]bThe second color.
[in]tThe blending factor in [0, 1].
Returns
The blended color.

Performs linear interpolation: a + t * (b - a).

Definition at line 78 of file blend.hpp.

◆ blend() [2/5]

template<std::input_iterator InputIt1, std::sentinel_for< InputIt1 > Sentinel, std::input_iterator InputIt2>
requires Color<std::iter_value_t<InputIt1>> && std::floating_point<std::iter_value_t<InputIt2>>
constexpr std::iter_value_t< InputIt1 > ufo::blend ( InputIt1  first,
Sentinel  last,
InputIt2  first_weight 
)
constexpr

Blends multiple colors using a range of weights.

Template Parameters
InputIt1The color iterator type.
SentinelThe color sentinel type.
InputIt2The weight iterator type.
Parameters
[in]firstThe beginning of the color range.
[in]lastThe end of the color range.
[in]first_weightThe beginning of the weight range.
Returns
The resulting blended color.

Definition at line 138 of file blend.hpp.

◆ blend() [3/5]

template<std::ranges::input_range R, std::floating_point T>
requires Color<std::ranges::range_value_t<R>>
constexpr std::ranges::range_value_t< R > ufo::blend ( R &&  r,
std::initializer_list< T >  w 
)
constexpr

Blends multiple colors using an initializer list of weights.

Template Parameters
RThe color range type.
TThe weight type.
Parameters
[in]rThe range of colors.
[in]wThe initializer list of weights.
Returns
The resulting blended color.

Definition at line 159 of file blend.hpp.

◆ blend() [4/5]

template<std::ranges::input_range R, std::ranges::input_range W>
requires Color<std::ranges::range_value_t<R>> && std::floating_point<std::ranges::range_value_t<W>>
constexpr std::ranges::range_value_t< R > ufo::blend ( R &&  r,
W &&  w 
)
constexpr

Blends multiple colors using a range of weights.

Template Parameters
RThe color range type.
WThe weight range type.
Parameters
[in]rThe range of colors.
[in]wThe range of weights.
Returns
The resulting blended color.

Computes the weighted sum of the colors in r using weights in w.

Definition at line 102 of file blend.hpp.

◆ blend() [5/5]

template<Color C, std::floating_point T>
constexpr C ufo::blend ( std::initializer_list< C >  r,
std::initializer_list< T >  w 
)
constexpr

Blends multiple colors using an initializer list of colors and weights.

Template Parameters
CThe color type.
TThe weight type.
Parameters
[in]rThe initializer list of colors.
[in]wThe initializer list of weights.
Returns
The resulting blended color.

Definition at line 174 of file blend.hpp.

◆ colorMap()

template<Color C, std::size_t N>
constexpr C ufo::colorMap ( std::array< C, N > const &  map,
float  value,
float  min_value,
float  max_value 
)
constexpr

Maps a value to a color using a color map.

Template Parameters
CThe color type.
NThe size of the color map.
Parameters
[in]mapThe color map.
[in]valueThe value to map.
[in]min_valueThe minimum value of the range.
[in]max_valueThe maximum value of the range.
Returns
The mapped color.

Definition at line 74 of file map.hpp.

◆ convert() [1/3]

template<Color To, Color From>
constexpr To ufo::convert ( From const &  color)
constexpr

Convert a color from one type to another.

Template Parameters
ToThe destination color type (must satisfy the Color concept).
FromThe source color type (must satisfy the Color concept).
Parameters
[in]colorThe color to convert.
Returns
The converted color of type To.

Performs a full color model and channel type conversion, including handling of alpha and weight fields.

Definition at line 73 of file convert.hpp.

◆ convert() [2/3]

template<typename T , ColorFlags F, Color From>
requires (std::floating_point<T> || std::integral<T>)
constexpr auto ufo::convert ( From const &  color)
constexpr

Convert a color from one type to another.

Template Parameters
TThe destination value type (must satisfy the floating_point or integral concept).
FThe destination color flags (must satisfy the ColorFlags concept).
FromThe source color type (must satisfy the Color concept).
Parameters
[in]colorThe color to convert.
Returns
The converted color of type To.

Converts the value type and alpha/weight flags, keeping the same color model.

Definition at line 124 of file convert.hpp.

◆ convert() [3/3]

template<Color From, Color To>
constexpr void ufo::convert ( From const &  in,
To &  out 
)
constexpr

Convert a color from one type to another and assign to an output variable.

Template Parameters
FromThe source color type (must satisfy the Color concept).
ToThe destination color type (must satisfy the Color concept).
Parameters
[in]inThe color to convert.
[out]outThe output variable to store the converted color.

This is a convenience overload that assigns the result of the conversion to the output parameter.

Definition at line 140 of file convert.hpp.

◆ deltaE()

template<Color C>
constexpr float ufo::deltaE ( C const &  color,
C const &  sample,
ColorDeltaE  method = ColorDeltaE::EUCLIDEAN,
ColorSpace  space = ColorSpace::NATIVE 
)
constexpr

Computes the distance between two colors using a specified method.

Template Parameters
CThe color type.
Parameters
[in]colorThe first color.
[in]sampleThe second color.
[in]methodThe delta E method to use (default: EUCLIDEAN).
[in]spaceThe color space to perform the calculation in (default: NATIVE).
Returns
The distance.

Definition at line 208 of file delta_e.hpp.

◆ deltaEEuclidean()

template<Color C>
constexpr float ufo::deltaEEuclidean ( C const &  color,
C const &  sample 
)
constexpr

Computes the Euclidean distance between two colors.

Template Parameters
CThe color type.
Parameters
[in]colorThe first color.
[in]sampleThe second color.
Returns
The Euclidean distance.

Definition at line 124 of file delta_e.hpp.

◆ deltaEEuclideanSquared()

template<Color C>
constexpr float ufo::deltaEEuclideanSquared ( C const &  color,
C const &  sample 
)
constexpr

Computes the squared Euclidean distance between two colors.

Template Parameters
CThe color type.
Parameters
[in]colorThe first color.
[in]sampleThe second color.
Returns
The squared Euclidean distance.

The distance is computed in the color space of C using floating-point precision.

Definition at line 86 of file delta_e.hpp.

◆ deltaEOk()

template<Color C>
constexpr float ufo::deltaEOk ( C const &  color,
C const &  sample,
float const  ab_scale = 2.0f 
)
constexpr

Computes the Ok delta E distance between two colors.

Template Parameters
CThe color type.
Parameters
[in]colorThe first color.
[in]sampleThe second color.
[in]ab_scaleThe scale factor for the chromaticity channels (default: 2.0).
Returns
The Ok delta E distance.

Definition at line 159 of file delta_e.hpp.

◆ deltaEOkSquared()

template<Color C>
constexpr float ufo::deltaEOkSquared ( C const &  color,
C const &  sample,
float const  ab_scale = 2.0f 
)
constexpr

Computes the squared Ok delta E distance between two colors.

Template Parameters
CThe color type.
Parameters
[in]colorThe first color.
[in]sampleThe second color.
[in]ab_scaleThe scale factor for the chromaticity channels (default: 2.0).
Returns
The squared Ok delta E distance.

Definition at line 138 of file delta_e.hpp.

◆ deltaESquared()

template<Color C>
constexpr float ufo::deltaESquared ( C const &  color,
C const &  sample,
ColorDeltaE  method = ColorDeltaE::EUCLIDEAN,
ColorSpace  space = ColorSpace::NATIVE 
)
constexpr

Computes the squared distance between two colors using a specified method.

Template Parameters
CThe color type.
Parameters
[in]colorThe first color.
[in]sampleThe second color.
[in]methodThe delta E method to use (default: EUCLIDEAN).
[in]spaceThe color space to perform the calculation in (default: NATIVE).
Returns
The squared distance.

Definition at line 175 of file delta_e.hpp.

◆ operator&()

constexpr ColorFlags ufo::operator& ( ColorFlags  a,
ColorFlags  b 
)
constexprnoexcept

Bitwise AND for testing ColorFlags.

Parameters
[in]aThe first ColorFlags value.
[in]bThe second ColorFlags value.
Returns
The result of the bitwise AND operation.

Definition at line 94 of file flags.hpp.

◆ operator*() [1/3]

template<Color C>
constexpr C ufo::operator* ( lhs,
C const &  rhs 
)
constexpr

Multiplies two colors component-wise.

Parameters
[in]lhsThe left-hand side color.
[in]rhsThe right-hand side color.
Returns
The resulting color.

Definition at line 165 of file arithmetic.hpp.

◆ operator*() [2/3]

template<Color C>
constexpr C ufo::operator* ( lhs,
float  rhs 
)
constexpr

Multiplies a color by a scalar.

Parameters
[in]lhsThe left-hand side color.
[in]rhsThe right-hand side scalar.
Returns
The resulting color.

Definition at line 178 of file arithmetic.hpp.

◆ operator*() [3/3]

template<Color C>
constexpr C ufo::operator* ( float  lhs,
rhs 
)
constexpr

Multiplies a scalar by a color.

Parameters
[in]lhsThe left-hand side scalar.
[in]rhsThe right-hand side color.
Returns
The resulting color.

Definition at line 191 of file arithmetic.hpp.

◆ operator*=() [1/2]

template<Color C>
constexpr C & ufo::operator*= ( C &  lhs,
C const &  rhs 
)
constexpr

Multiplies two colors component-wise.

Parameters
[in,out]lhsThe left-hand side color.
[in]rhsThe right-hand side color.
Returns
The resulting color.

Definition at line 152 of file arithmetic.hpp.

◆ operator*=() [2/2]

template<Color C>
constexpr C & ufo::operator*= ( C &  lhs,
float  rhs 
)
constexpr

Multiplies a color by a scalar.

Parameters
[in,out]lhsThe left-hand side color.
[in]rhsThe right-hand side scalar.
Returns
The resulting color.

Definition at line 139 of file arithmetic.hpp.

◆ operator+()

template<Color C>
constexpr C ufo::operator+ ( lhs,
C const &  rhs 
)
constexpr

Adds two colors component-wise.

Parameters
[in]lhsThe left-hand side color.
[in]rhsThe right-hand side color.
Returns
The resulting color.

Definition at line 88 of file arithmetic.hpp.

◆ operator+=()

template<Color C>
constexpr C & ufo::operator+= ( C &  lhs,
C const &  rhs 
)
constexpr

Adds two colors component-wise.

Parameters
[in,out]lhsThe left-hand side color.
[in]rhsThe right-hand side color.
Returns
The resulting color.

Definition at line 75 of file arithmetic.hpp.

◆ operator-()

template<Color C>
constexpr C ufo::operator- ( lhs,
C const &  rhs 
)
constexpr

Subtracts two colors component-wise.

Parameters
[in]lhsThe left-hand side color.
[in]rhsThe right-hand side color.
Returns
The resulting color.

Definition at line 120 of file arithmetic.hpp.

◆ operator-=()

template<Color C>
constexpr C & ufo::operator-= ( C &  lhs,
C const &  rhs 
)
constexpr

Subtracts two colors component-wise.

Parameters
[in,out]lhsThe left-hand side color.
[in]rhsThe right-hand side color.
Returns
The resulting color.

Definition at line 107 of file arithmetic.hpp.

◆ operator/() [1/3]

template<Color C>
constexpr C ufo::operator/ ( lhs,
C const &  rhs 
)
constexpr

Divides two colors component-wise.

Parameters
[in]lhsThe left-hand side color.
[in]rhsThe right-hand side color.
Returns
The resulting color.

Definition at line 235 of file arithmetic.hpp.

◆ operator/() [2/3]

template<Color C>
constexpr C ufo::operator/ ( lhs,
float  rhs 
)
constexpr

Divides a color by a scalar.

Parameters
[in]lhsThe left-hand side color.
[in]rhsThe right-hand side scalar.
Returns
The resulting color.

Definition at line 248 of file arithmetic.hpp.

◆ operator/() [3/3]

template<Color C>
constexpr C ufo::operator/ ( float  lhs,
rhs 
)
constexpr

Divides a scalar by a color.

Parameters
[in]lhsThe left-hand side scalar.
[in]rhsThe right-hand side color.
Returns
The resulting color.

Definition at line 261 of file arithmetic.hpp.

◆ operator/=() [1/2]

template<Color C>
constexpr C & ufo::operator/= ( C &  lhs,
C const &  rhs 
)
constexpr

Divides a color by another color component-wise.

Parameters
[in,out]lhsThe left-hand side color.
[in]rhsThe right-hand side color.
Returns
The resulting color.

Definition at line 209 of file arithmetic.hpp.

◆ operator/=() [2/2]

template<Color C>
constexpr C & ufo::operator/= ( C &  lhs,
float  rhs 
)
constexpr

Divides a color by a scalar.

Parameters
[in,out]lhsThe left-hand side color.
[in]rhsThe right-hand side scalar.
Returns
The resulting color.

Definition at line 222 of file arithmetic.hpp.

◆ operator<<() [1/2]

std::ostream & ufo::operator<< ( std::ostream &  os,
ColorFlags  flags 
)
inline

Stream-insertion operator for ColorFlags.

Definition at line 147 of file flags.hpp.

◆ operator<<() [2/2]

std::ostream & ufo::operator<< ( std::ostream &  out,
ColorSpace  cs 
)
inline

Writes the color-space name to out.

Definition at line 94 of file space.hpp.

◆ operator|()

constexpr ColorFlags ufo::operator| ( ColorFlags  a,
ColorFlags  b 
)
constexprnoexcept

Bitwise OR for combining ColorFlags.

Parameters
[in]aThe first ColorFlags value.
[in]bThe second ColorFlags value.
Returns
The result of the bitwise OR operation.

Definition at line 83 of file flags.hpp.

◆ operator~()

constexpr ColorFlags ufo::operator~ ( ColorFlags  a)
constexprnoexcept

Bitwise complement - inverts all valid ColorFlags bits.

Parameters
[in]aThe ColorFlags value to invert.
Returns
The result of the bitwise complement operation.

Definition at line 104 of file flags.hpp.

◆ removeWeight()

template<Color C>
constexpr remove_weight_t< C > ufo::removeWeight ( color)
constexprnoexcept

Returns a copy of color with the weight field removed.

Parameters
[in]colorThe color to remove the weight from.
Returns
A copy of color with the weight field removed.

If color has no weight field it is returned unchanged. For floating-point channel types the stored channels are divided by the weight, yielding un-premultiplied values; a zero weight returns a default-initialised color.

Definition at line 137 of file weight.hpp.

◆ toString() [1/2]

constexpr std::string_view ufo::toString ( ColorFlags  flags)
constexprnoexcept

Returns a human-readable string for a ColorFlags value.

Parameters
[in]flagsA valid combination of ColorFlags enumerators.
Returns
A null-terminated std::string_view with a stable lifetime.

Definition at line 132 of file flags.hpp.

◆ toString() [2/2]

constexpr std::string_view ufo::toString ( ColorSpace  cs)
constexprnoexcept

Returns a human-readable name for cs.

Parameters
csA valid ColorSpace enumerator.
Returns
A null-terminated string_view with static storage duration.

Definition at line 78 of file space.hpp.

◆ weight()

template<Color C>
constexpr weight_type_t< C > ufo::weight ( color)
constexprnoexcept

Returns the weight of color, or 1 if color has no weight field.

Parameters
[in]colorThe color to get the weight of.
Returns
The weight of color, or 1 if color has no weight field.

Definition at line 67 of file weight.hpp.

◆ weightset()

consteval bool ufo::weightset ( ColorFlags  flags)
noexcept

Returns true if the Weight flag is set.

Definition at line 122 of file flags.hpp.

Variable Documentation

◆ contains_color_v

template<class... Ts>
constexpr bool ufo::contains_color_v = contains_color<Ts...>::value
inlineconstexpr

Definition at line 229 of file type_traits.hpp.

◆ has_alpha_v

template<class T >
constexpr bool ufo::has_alpha_v = has_alpha<T>::value
inlineconstexpr

Definition at line 285 of file type_traits.hpp.

◆ has_weight_v

template<class T >
constexpr bool ufo::has_weight_v = has_weight<T>::value
inlineconstexpr

Definition at line 334 of file type_traits.hpp.

◆ init_alpha_v

template<class T >
constexpr auto ufo::init_alpha_v = init_alpha<T>::value
inlineconstexpr

Definition at line 302 of file type_traits.hpp.

◆ is_color_v

template<class T >
constexpr bool ufo::is_color_v = is_color<T>::value
inlineconstexpr

Definition at line 213 of file type_traits.hpp.