PICCANTE  0.4
The hottest HDR imaging library!
color_conv_rgb_to_srgb.hpp
Go to the documentation of this file.
1 /*
2 
3 PICCANTE
4 The hottest HDR imaging library!
5 http://vcg.isti.cnr.it/piccante
6 
7 Copyright (C) 2014
8 Visual Computing Laboratory - ISTI CNR
9 http://vcg.isti.cnr.it
10 First author: Francesco Banterle
11 
12 This Source Code Form is subject to the terms of the Mozilla Public
13 License, v. 2.0. If a copy of the MPL was not distributed with this
14 file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 
16 */
17 
18 #ifndef PIC_COLORS_COLOR_CONV_RGB_TO_SRGB_HPP
19 #define PIC_COLORS_COLOR_CONV_RGB_TO_SRGB_HPP
20 
21 #include "../colors/color_conv.hpp"
22 
23 namespace pic {
24 
29 {
30 protected:
31 
33 
34 public:
35 
40  {
41  linear = false;
42 
43  gamma = 2.4f;
44  gamma_inv = 1.0f / gamma;
45  a = 0.055f;
46  a_plus_1 = 1.0f + a;
47  }
48 
54  void direct(float *colIn, float *colOut)
55  {
56  for(int i = 0; i < 3; i++) {
57  if(colIn[i] > 0.0031308f) {
58  colOut[i] = a_plus_1 * powf(colIn[i], gamma_inv) - a;
59  } else {
60  colOut[i] = 12.92f * colIn[i];
61  }
62  }
63  }
64 
70  void inverse(float *colIn, float *colOut)
71  {
72  for(int i = 0; i < 3; i++) {
73  if(colIn[i] > 0.04045f) {
74  colOut[i] = powf((colIn[i] + a) / a_plus_1, gamma);
75  } else {
76  colOut[i] = colIn[i] / 12.92f;
77  }
78  }
79  }
80 };
81 
82 } // end namespace pic
83 
84 #endif /* PIC_COLORS_COLOR_SPACE_XYZ_HPP */
85 
float a_plus_1
Definition: color_conv_rgb_to_srgb.hpp:32
void inverse(float *colIn, float *colOut)
inverse
Definition: color_conv_rgb_to_srgb.hpp:70
float gamma
Definition: color_conv_rgb_to_srgb.hpp:32
bool linear
Definition: display.hpp:30
ColorConvRGBtosRGB()
ColorConvRGBtosRGB.
Definition: color_conv_rgb_to_srgb.hpp:39
float a
Definition: color_conv_rgb_to_srgb.hpp:32
void direct(float *colIn, float *colOut)
direct
Definition: color_conv_rgb_to_srgb.hpp:54
Definition: bilateral_separation.hpp:25
The ColorConv class.
Definition: color_conv.hpp:26
float gamma_inv
Definition: color_conv_rgb_to_srgb.hpp:32
The ColorConvRGBtosRGB class.
Definition: color_conv_rgb_to_srgb.hpp:28