PICCANTE  0.4
The hottest HDR imaging library!
color_conv_xyz_xyY.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_xyY_HPP
19 #define PIC_COLORS_COLOR_CONV_XYZ_TO_xyY_HPP
20 
21 #include "../colors/color_conv.hpp"
22 
23 namespace pic {
24 
29 {
30 public:
31 
33  {
34  linear = false;
35  }
36 
42  void direct(float *colIn, float *colOut)
43  {
44  float XYZ = colIn[0] + colIn[1] + colIn[2];
45 
46  if(XYZ > 0.0f) {
47  colOut[0] = colIn[0] / XYZ;
48  colOut[1] = colIn[1] / XYZ;
49  colOut[2] = colIn[2];
50  } else {
51  colOut[0] = -1.0f;
52  colOut[1] = -1.0f;
53  colOut[2] = -1.0f;
54  }
55  }
56 
62  void inverse(float *colIn, float *colOut)
63  {
64  if(colIn[0] != 0.0f) {
65  float ratio = colIn[2] / colIn[1];
66  float z = CLAMPi(1.0f - colIn[0] - colIn[1], 0.0f, 1.0f);
67 
68  colOut[0] = colIn[0] * ratio;
69  colOut[1] = colIn[2];
70  colOut[2] = z * ratio;
71  } else {
72  colOut[0] = -1.0f;
73  colOut[1] = -1.0f;
74  colOut[2] = -1.0f;
75  }
76  }
77 };
78 
79 } // end namespace pic
80 
81 #endif /* PIC_COLORS_COLOR_SPACE_CIELAB_HPP */
82 
ColorConvXYZtoxyY()
Definition: color_conv_xyz_xyY.hpp:32
bool linear
Definition: display.hpp:30
The ColorConvXYZtoxyY class.
Definition: color_conv_xyz_xyY.hpp:28
void direct(float *colIn, float *colOut)
direct
Definition: color_conv_xyz_xyY.hpp:42
void inverse(float *colIn, float *colOut)
inverse
Definition: color_conv_xyz_xyY.hpp:62
#define CLAMPi(x, a, b)
Definition: math.hpp:81
Definition: bilateral_separation.hpp:25
The ColorConv class.
Definition: color_conv.hpp:26