MRPT  2.0.5
color_maps_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <gtest/gtest.h>
11 #include <mrpt/img/color_maps.h>
12 
13 TEST(color_maps, cmGRAYSCALE)
14 {
15  using namespace mrpt::img;
16 
17  {
18  float r, g, b;
19  colormap(cmGRAYSCALE, .0f, r, g, b);
20  EXPECT_NEAR(r, .0f, 1e-3f);
21  EXPECT_NEAR(g, .0f, 1e-3f);
22  EXPECT_NEAR(b, .0f, 1e-3f);
23  }
24  {
25  float r, g, b;
26  colormap(cmGRAYSCALE, 1.0f, r, g, b);
27  EXPECT_NEAR(r, 1.0f, 1e-3f);
28  EXPECT_NEAR(g, 1.0f, 1e-3f);
29  EXPECT_NEAR(b, 1.0f, 1e-3f);
30  }
31  {
32  float r, g, b;
33  colormap(cmGRAYSCALE, -0.1f, r, g, b);
34  EXPECT_NEAR(r, .0f, 1e-3f);
35  EXPECT_NEAR(g, .0f, 1e-3f);
36  EXPECT_NEAR(b, .0f, 1e-3f);
37  }
38  {
39  float r, g, b;
40  colormap(cmGRAYSCALE, 1.2f, r, g, b);
41  EXPECT_NEAR(r, 1.0f, 1e-3f);
42  EXPECT_NEAR(g, 1.0f, 1e-3f);
43  EXPECT_NEAR(b, 1.0f, 1e-3f);
44  }
45  {
46  float r, g, b;
47  colormap(cmGRAYSCALE, 0.8f, r, g, b);
48  EXPECT_NEAR(r, 0.8f, 1e-3f);
49  EXPECT_NEAR(g, 0.8f, 1e-3f);
50  EXPECT_NEAR(b, 0.8f, 1e-3f);
51  }
52 }
53 
54 TEST(color_maps, cmJET)
55 {
56  using namespace mrpt::img;
57 
58  {
59  float r, g, b;
60  colormap(cmJET, .0f, r, g, b);
61  EXPECT_NEAR(r, 0.0f, 1e-3f);
62  EXPECT_NEAR(g, 0.0f, 1e-3f);
63  EXPECT_NEAR(b, 0.5625f, 1e-3f);
64  }
65  {
66  float r, g, b;
67  colormap(cmJET, 1.0f, r, g, b);
68  EXPECT_NEAR(r, 0.5f, 1e-3f);
69  EXPECT_NEAR(g, 0.0f, 1e-3f);
70  EXPECT_NEAR(b, 0.0f, 1e-3f);
71  }
72  {
73  float r, g, b;
74  colormap(cmJET, 0.8f, r, g, b);
75  EXPECT_NEAR(r, 1.0f, 1e-3f);
76  EXPECT_NEAR(g, 0.2375f, 1e-3f);
77  EXPECT_NEAR(b, 0.0f, 1e-3f);
78  }
79 }
80 
81 TEST(color_maps, cmHOT)
82 {
83  using namespace mrpt::img;
84 
85  {
86  float r, g, b;
87  colormap(cmHOT, .0f, r, g, b);
88  EXPECT_NEAR(r, 0.04166f, 1e-3f);
89  EXPECT_NEAR(g, 0.0f, 1e-3f);
90  EXPECT_NEAR(b, 0.0f, 1e-3f);
91  }
92  {
93  float r, g, b;
94  colormap(cmHOT, 1.0f, r, g, b);
95  EXPECT_NEAR(r, 1.0f, 1e-3f);
96  EXPECT_NEAR(g, 1.0f, 1e-3f);
97  EXPECT_NEAR(b, 1.0f, 1e-3f);
98  }
99  {
100  float r, g, b;
101  colormap(cmHOT, 0.8f, r, g, b);
102  EXPECT_NEAR(r, 1.0f, 1e-3f);
103  EXPECT_NEAR(g, 1.0f, 1e-3f);
104  EXPECT_NEAR(b, 0.2625f, 1e-3f);
105  }
106 }
void colormap(const TColormap &color_map, const float color_index, float &r, float &g, float &b)
Transform a float number in the range [0,1] into RGB components.
Definition: color_maps.cpp:114
[New in MRPT 1.5.0]
Definition: color_maps.h:37
TEST(color_maps, cmGRAYSCALE)
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)



Page generated by Doxygen 1.8.14 for MRPT 2.0.5 Git: eb5aebda1 Sat Jul 18 23:34:37 2020 +0200 at sáb jul 18 23:45:10 CEST 2020