supereight
colour_utils.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2019-2021 Smart Robotics Lab, Imperial College London, Technical University of Munich
3  * SPDX-FileCopyrightText: 2019-2021 Nils Funk
4  * SPDX-FileCopyrightText: 2019-2021 Sotiris Papatheodorou
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef SE_COLOUR_UTILS_HPP
9 #define SE_COLOUR_UTILS_HPP
10 
11 #include <Eigen/Dense>
12 #include <cstdint>
13 #include <vector>
14 
15 
16 
17 namespace se {
18 namespace colours {
22 static const std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f>> scale = {
23  {102, 194, 165},
24  {252, 141, 98},
25  {141, 160, 203},
26  {231, 138, 195},
27  {166, 216, 84},
28  {255, 217, 47},
29  {229, 196, 148},
30  {179, 179, 179}};
31 } // namespace colours
32 
49 static inline uint32_t
50 pack_rgba(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a);
51 
52 
53 
63 static inline uint32_t pack_rgba(const Eigen::Vector4f& color);
64 
65 
66 
76 static inline uint32_t pack_rgba(const Eigen::Vector3f& color);
77 
78 
79 
89 static inline uint32_t pack_rgba(const Eigen::Vector4i& color);
90 
91 
92 
103 static inline uint32_t pack_rgba(const Eigen::Vector3i& color);
104 
105 
106 
113 static inline uint8_t r_from_rgba(const uint32_t rgba);
114 
115 
116 
123 static inline uint8_t g_from_rgba(const uint32_t rgba);
124 
125 
126 
133 static inline uint8_t b_from_rgba(const uint32_t rgba);
134 
135 
136 
143 static inline uint8_t a_from_rgba(const uint32_t rgba);
144 
145 
146 
162 static inline uint32_t blend(const uint32_t rgba_1, const uint32_t rgba_2, const float alpha);
163 
164 
165 
166 static inline void rgb_to_rgba(const uint8_t* rgb, uint32_t* rgba, size_t num_pixels);
167 
168 
169 
170 static inline void rgba_to_rgb(const uint32_t* rgba, uint8_t* rgb, size_t num_pixels);
171 
172 
173 
186 void depth_to_rgba(uint32_t* depth_RGBA_image_data,
187  const float* depth_image_data,
188  const Eigen::Vector2i& depth_image_res,
189  const float min_depth,
190  const float max_depth);
191 } // namespace se
192 
193 #include "impl/colour_utils_impl.hpp"
194 
195 #endif // SE_COLOUR_UTILS_HPP
static void rgba_to_rgb(const uint32_t *rgba, uint8_t *rgb, size_t num_pixels)
static uint32_t pack_rgba(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a)
Pack the individual RGBA channels into a single 32-bit unsigned integer.
static uint8_t r_from_rgba(const uint32_t rgba)
Get the value of the red channel from a 32-bit packed RGBA value.
static void rgb_to_rgba(const uint8_t *rgb, uint32_t *rgba, size_t num_pixels)
static uint32_t blend(const uint32_t rgba_1, const uint32_t rgba_2, const float alpha)
Blend two RGBA colors based on the value of the blending parameter alpha.
void depth_to_rgba(uint32_t *depth_RGBA_image_data, const float *depth_image_data, const Eigen::Vector2i &depth_image_res, const float min_depth, const float max_depth)
Convert a depth image to an RGBA image to allow visualizing it.
static uint8_t a_from_rgba(const uint32_t rgba)
Get the value of the alpha channel from a 32-bit packed RGBA value.
static uint8_t b_from_rgba(const uint32_t rgba)
Get the value of the blue channel from a 32-bit packed RGBA value.
Helper wrapper to allocate and de-allocate octants in the octree.
Definition: colour_utils.hpp:17
static const std::vector< Eigen::Vector3f, Eigen::aligned_allocator< Eigen::Vector3f > > scale
The colours used for the various integration scales.
Definition: colour_utils.hpp:22
static uint8_t g_from_rgba(const uint32_t rgba)
Get the value of the green channel from a 32-bit packed RGBA value.