PICCANTE  0.4
The hottest HDR imaging library!
color_conv_xyz_to_logluv.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_XYZ_TO_LOGLUV_HPP
19 #define PIC_COLORS_COLOR_CONV_XYZ_TO_LOGLUV_HPP
20 
21 #include "../colors/color_conv.hpp"
22 
23 namespace pic {
24 
29 {
30 protected:
31  float epsilon;
32 
33 public:
34 
39  {
40  linear = false;
41  epsilon = 1.0f;
42  }
43 
49  void direct(float *colIn, float *colOut)
50  {
51 
52  colOut[0] = logf(colIn[1] + epsilon);
53 
54  float norm = colIn[0] + colIn[1] + colIn[2];
55  float x = colIn[0] / norm;
56  float y = colIn[1] / norm;
57 
58  float norm_uv = -2.0f * x + 12.0f * y + 3.0f;
59  float u_prime = 4.0f * x / norm_uv;
60  float v_prime = 9.0f * y / norm_uv;
61 
62  colOut[1] = u_prime;
63  colOut[2] = v_prime;
64  }
65 
71  void inverse(float *colIn, float *colOut)
72  {
73  float norm = 6.0f * colIn[1] - 16.0f * colIn[2] + 12.0f;
74 
75  float x = 9.0f * colIn[1] / norm;
76  float y = 4.0f * colIn[2] / norm;
77  float z = 1.0f - x - y;
78 
79  float Y = MAX(expf(colIn[0]) - epsilon, 0.0f);
80  norm = Y / y;
81 
82  colOut[0] = x * norm;
83  colOut[1] = Y;
84  colOut[2] = z * norm;
85  }
86 };
87 
88 } // end namespace pic
89 
90 #endif /* PIC_COLORS_COLOR_SPACE_LOGLUV_HPP */
91 
void inverse(float *colIn, float *colOut)
inverse from CIE LUV to XYZ
Definition: color_conv_xyz_to_logluv.hpp:71
float epsilon
Definition: color_conv_xyz_to_logluv.hpp:31
bool linear
Definition: display.hpp:30
ColorConvXYZtoLogLuv()
ColorConvXYZtoLogLuv.
Definition: color_conv_xyz_to_logluv.hpp:38
The ColorConvXYZtoLogLuv class.
Definition: color_conv_xyz_to_logluv.hpp:28
void direct(float *colIn, float *colOut)
direct from XYZ to CIE LUV
Definition: color_conv_xyz_to_logluv.hpp:49
Definition: bilateral_separation.hpp:25
#define MAX(a, b)
Definition: math.hpp:73
The ColorConv class.
Definition: color_conv.hpp:26