CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
image
ColorConverter.h
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#pragma once
8
9
#include "
carla/image/BoostGil.h
"
10
#include "
carla/image/CityScapesPalette.h
"
11
12
namespace
carla
{
13
namespace
image
{
14
15
class
ColorConverter
{
16
public
:
17
18
struct
LogarithmicLinear
{
19
template
<
typename
DstPixelT>
20
void
operator()
(
const
boost::gil::gray32fc_pixel_t &src, DstPixelT &dst)
const
{
21
using namespace
boost::gil;
22
const
float
value = 1.0f + std::log(src[0u]) / 5.70378f;
23
const
float
clamped = std::max(std::min(value, 1.0f), 0.005f);
24
color_convert(gray32fc_pixel_t{clamped}, dst);
25
}
26
};
27
28
struct
Depth
{
29
template
<
typename
SrcPixelT,
typename
DstPixelT>
30
void
operator()
(
const
SrcPixelT &src, DstPixelT &dst)
const
{
31
using namespace
boost::gil;
32
static_assert
(
33
sizeof
(
typename
color_space_type<SrcPixelT>::type) ==
sizeof
(uint8_t),
34
"Invalid pixel type."
);
35
const
float
depth =
36
get_color(src, red_t()) +
37
(get_color(src, green_t()) * 256) +
38
(get_color(src, blue_t()) * 256 * 256);
39
const
float
normalized = depth /
static_cast<
float
>
(256 * 256 * 256 - 1);
40
color_convert(gray32fc_pixel_t{normalized}, dst);
41
}
42
};
43
44
struct
LogarithmicDepth
{};
45
46
struct
CityScapesPalette
{
47
template
<
typename
SrcPixelT,
typename
DstPixelT>
48
void
operator()
(
const
SrcPixelT &src, DstPixelT &dst)
const
{
49
using namespace
boost::gil;
50
static_assert
(
51
sizeof
(
typename
color_space_type<SrcPixelT>::type) ==
sizeof
(uint8_t),
52
"Invalid pixel type."
);
53
const
auto
color =
image::CityScapesPalette::GetColor
(get_color(src, red_t()));
54
color_convert(rgb8c_pixel_t{color[0u], color[1u], color[2u]}, dst);
55
}
56
};
57
};
58
59
}
// namespace image
60
}
// namespace carla
BoostGil.h
CityScapesPalette.h
carla::image::CityScapesPalette::GetColor
static constexpr auto GetColor(uint8_t tag)
Return an RGB uint8_t array.
Definition
CityScapesPalette.h:68
carla::image::ColorConverter
Definition
ColorConverter.h:15
carla::image
Definition
CityScapesPalette.h:12
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
carla::image::ColorConverter::CityScapesPalette
Definition
ColorConverter.h:46
carla::image::ColorConverter::CityScapesPalette::operator()
void operator()(const SrcPixelT &src, DstPixelT &dst) const
Definition
ColorConverter.h:48
carla::image::ColorConverter::Depth
Definition
ColorConverter.h:28
carla::image::ColorConverter::Depth::operator()
void operator()(const SrcPixelT &src, DstPixelT &dst) const
Definition
ColorConverter.h:30
carla::image::ColorConverter::LogarithmicDepth
Definition
ColorConverter.h:44
carla::image::ColorConverter::LogarithmicLinear
Definition
ColorConverter.h:18
carla::image::ColorConverter::LogarithmicLinear::operator()
void operator()(const boost::gil::gray32fc_pixel_t &src, DstPixelT &dst) const
Definition
ColorConverter.h:20
Generated by
1.18.0