Open3D (C++ API)  0.12.0
ColorGrading.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2020 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <Eigen/Core>
30 #include <cstdint>
31 
32 namespace open3d {
33 namespace visualization {
34 namespace rendering {
35 
38 public:
40  enum class Quality : std::uint8_t { kLow, kMedium, kHigh, kUltra };
41 
42  enum class ToneMapping : std::uint8_t {
43  kLinear = 0,
44  kAcesLegacy = 1,
45  kAces = 2,
46  kFilmic = 3,
47  kUchimura = 4,
48  kReinhard = 5,
49  kDisplayRange = 6,
50  };
51 
53 
54  void SetQuality(Quality q);
55  Quality GetQuality() const { return quality_; }
56 
57  void SetToneMapping(ToneMapping algorithm);
58  ToneMapping GetToneMapping() const { return tonemapping_; }
59 
60  void SetTemperature(float temperature);
61  float GetTemperature() const { return temperature_; }
62 
63  void SetTint(float tint);
64  float GetTint() const { return tint_; }
65 
66  void SetContrast(float contrast);
67  float GetContrast() const { return contrast_; }
68 
69  void SetVibrance(float vibrance);
70  float GetVibrance() const { return vibrance_; }
71 
72  void SetSaturation(float saturation);
73  float GetSaturation() const { return saturation_; }
74 
75  void SetChannelMixer(const Eigen::Vector3f& red,
76  const Eigen::Vector3f& green,
77  const Eigen::Vector3f& blue);
78  Eigen::Vector3f GetMixerRed() const { return mixer_red_; }
79  Eigen::Vector3f GetMixerGreen() const { return mixer_green_; }
80  Eigen::Vector3f GetMixerBlue() const { return mixer_blue_; }
81 
82  void SetShadowMidtoneHighlights(const Eigen::Vector4f& shadows,
83  const Eigen::Vector4f& midtones,
84  const Eigen::Vector4f& highlights,
85  const Eigen::Vector4f& ranges);
86  Eigen::Vector4f GetShadows() const { return shadows_; }
87  Eigen::Vector4f GetMidtones() const { return midtones_; }
88  Eigen::Vector4f GetHighlights() const { return highlights_; }
89  Eigen::Vector4f GetRanges() const { return ranges_; }
90 
91  void SetSlopeOffsetPower(const Eigen::Vector3f& slope,
92  const Eigen::Vector3f& offset,
93  const Eigen::Vector3f& power);
94  Eigen::Vector3f GetSlope() const { return slope_; }
95  Eigen::Vector3f GetOffset() const { return offset_; }
96  Eigen::Vector3f GetPower() const { return power_; }
97 
98  void SetCurves(const Eigen::Vector3f& shadow_gamma,
99  const Eigen::Vector3f& midpoint,
100  const Eigen::Vector3f& highlight_scale);
101  Eigen::Vector3f GetShadowGamma() const { return shadow_gamma_; }
102  Eigen::Vector3f GetMidpoint() const { return midpoint_; }
103  Eigen::Vector3f GetHighlightScale() const { return highlight_scale_; }
104 
105 private:
106  Quality quality_;
107  ToneMapping tonemapping_;
108 
109  float temperature_ = 0.f;
110  float tint_ = 0.f;
111  float contrast_ = 1.f;
112  float vibrance_ = 1.f;
113  float saturation_ = 1.f;
114 
115  Eigen::Vector3f mixer_red_ = {1.f, 0.f, 0.f};
116  Eigen::Vector3f mixer_green_ = {0.f, 1.f, 0.f};
117  Eigen::Vector3f mixer_blue_ = {0.f, 0.f, 1.f};
118 
119  Eigen::Vector4f shadows_ = {1.f, 1.f, 1.f, 0.f};
120  Eigen::Vector4f midtones_ = {1.f, 1.f, 1.f, 0.f};
121  Eigen::Vector4f highlights_ = {1.f, 1.f, 1.f, 0.f};
122  Eigen::Vector4f ranges_ = {0.f, 0.333f, 0.55f, 1.f};
123 
124  Eigen::Vector3f slope_ = {1.f, 1.f, 1.f};
125  Eigen::Vector3f offset_ = {0.f, 0.f, 0.f};
126  Eigen::Vector3f power_ = {1.f, 1.f, 1.f};
127 
128  Eigen::Vector3f shadow_gamma_ = {1.f, 1.f, 1.f};
129  Eigen::Vector3f midpoint_ = {1.f, 1.f, 1.f};
130  Eigen::Vector3f highlight_scale_ = {1.f, 1.f, 1.f};
131 };
132 
133 } // namespace rendering
134 } // namespace visualization
135 } // namespace open3d
ToneMapping GetToneMapping() const
Definition: ColorGrading.h:58
Eigen::Vector3f GetOffset() const
Definition: ColorGrading.h:95
Eigen::Vector4f GetShadows() const
Definition: ColorGrading.h:86
void SetQuality(Quality q)
Definition: ColorGrading.cpp:38
float GetSaturation() const
Definition: ColorGrading.h:73
Quality GetQuality() const
Definition: ColorGrading.h:55
Eigen::Vector3f GetSlope() const
Definition: ColorGrading.h:94
int offset
Definition: FilePCD.cpp:64
void SetCurves(const Eigen::Vector3f &shadow_gamma, const Eigen::Vector3f &midpoint, const Eigen::Vector3f &highlight_scale)
Definition: ColorGrading.cpp:85
void SetShadowMidtoneHighlights(const Eigen::Vector4f &shadows, const Eigen::Vector4f &midtones, const Eigen::Vector4f &highlights, const Eigen::Vector4f &ranges)
Definition: ColorGrading.cpp:66
Eigen::Vector3f GetPower() const
Definition: ColorGrading.h:96
Quality
Quality level of color grading operations.
Definition: ColorGrading.h:40
float GetTemperature() const
Definition: ColorGrading.h:61
float GetTint() const
Definition: ColorGrading.h:64
void SetTint(float tint)
Definition: ColorGrading.cpp:48
void SetContrast(float contrast)
Definition: ColorGrading.cpp:50
Eigen::Vector4f GetRanges() const
Definition: ColorGrading.h:89
float GetVibrance() const
Definition: ColorGrading.h:70
Eigen::Vector3f GetMixerRed() const
Definition: ColorGrading.h:78
void SetVibrance(float vibrance)
Definition: ColorGrading.cpp:52
Eigen::Vector3f GetHighlightScale() const
Definition: ColorGrading.h:103
void SetSaturation(float saturation)
Definition: ColorGrading.cpp:54
Eigen::Vector3f GetMixerBlue() const
Definition: ColorGrading.h:80
Eigen::Vector3f GetMidpoint() const
Definition: ColorGrading.h:102
Definition: PinholeCameraIntrinsic.cpp:35
Eigen::Vector4f GetHighlights() const
Definition: ColorGrading.h:88
Manages.
Definition: ColorGrading.h:37
Eigen::Vector3f GetMixerGreen() const
Definition: ColorGrading.h:79
ColorGradingParams(Quality q, ToneMapping algorithm)
Definition: ColorGrading.cpp:35
float GetContrast() const
Definition: ColorGrading.h:67
Eigen::Vector3f GetShadowGamma() const
Definition: ColorGrading.h:101
void SetTemperature(float temperature)
Definition: ColorGrading.cpp:44
void SetChannelMixer(const Eigen::Vector3f &red, const Eigen::Vector3f &green, const Eigen::Vector3f &blue)
Definition: ColorGrading.cpp:58
void SetSlopeOffsetPower(const Eigen::Vector3f &slope, const Eigen::Vector3f &offset, const Eigen::Vector3f &power)
Definition: ColorGrading.cpp:77
void SetToneMapping(ToneMapping algorithm)
Definition: ColorGrading.cpp:40
Eigen::Vector4f GetMidtones() const
Definition: ColorGrading.h:87