Generic Image Library: kth_semantic_element_type, kth_semantic_element_reference_type, kth_semantic_element_const_reference_type, semantic_at_c

###  | #  |

Classes | Functions
kth_semantic_element_type, kth_semantic_element_reference_type, kth_semantic_element_const_reference_type, semantic_at_c
ColorBase » Algorithms and Utility Functions

semantic_at_c: Semantic channel accessors More...

## Classes
struct | kth_semantic_element_type< ColorBase, K >
| Specifies the type of the K-th semantic element of a color base. More...
struct | kth_semantic_element_reference_type< ColorBase, K >
| Specifies the return type of the mutable semantic_at_c<K>(color_base);. More...
struct | kth_semantic_element_const_reference_type< ColorBase, K >
| Specifies the return type of the constant semantic_at_c<K>(color_base);. More...

## Functions
template<int K, typename ColorBase >
auto | semantic_at_c (ColorBase &p) -> typename std::enable_if< !std::is_const< ColorBase >::value, typename kth_semantic_element_reference_type< ColorBase, K >::type >::type
| A mutable accessor to the K-th semantic element of a color base.
template<int K, typename ColorBase >
auto | semantic_at_c (ColorBase const &p) -> typename kth_semantic_element_const_reference_type< ColorBase, K >::type
| A constant accessor to the K-th semantic element of a color base.

## Detailed Description

semantic_at_c: Semantic channel accessors

Support for accessing the elements of a color base by semantic index

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 bases independent 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();