boost::gil::kth_semantic_element_type

Specifies the type of the K‐th semantic element of a color base

Synopsis

template<
    typename ColorBase,
    int K>
struct kth_semantic_element_type;

Description

The semantic index of an element is the index of its color in the color space. Semantic indexing allows for proper pairing of elements of color basesindependent on their layout. For example, red is the first semantic element of a color base regardless of whether it has an RGB layout or a BGR layout.All GIL color base algorithms taking multiple color bases use semantic indexing to access their elements.

Example:

// 16-bit BGR pixel, 4 bits for the blue, 3 bits for the green, 2 bits for the red channel and 7 unused bits
using bgr432_pixel_t = packed_pixel_type<uint16_t, mp11::mp_list_c<unsigned,4,3,2>, bgr_layout_t>::type;

// A reference to its red channel. Although the red channel is the third, its semantic index is 0 in the RGB color space
using red_channel_reference_t = kth_semantic_element_reference_type<bgr432_pixel_t, 0>::type;

// Initialize the pixel to black
bgr432_pixel_t red_pixel(0,0,0);

// Set the red channel to 100%
red_channel_reference_t red_channel = semantic_at_c<0>(red_pixel);
red_channel = channel_traits<red_channel_reference_t>::max_value();

Type Aliases

Static Data Members

Derived Classes

Name

Description

color_element_type

Specifies the type of the element associated with a given color tag

Created with MrDocs