Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CGoGN
CGoGN
Commits
23091b60
Commit
23091b60
authored
Mar 16, 2011
by
Kenneth Vanhoey
Browse files
correction conversions Luv
parent
599d6307
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/Utils/colourConverter.h
View file @
23091b60
...
...
@@ -117,7 +117,6 @@ private: // private constants
static
const
REAL
un
=
0.197832
;
static
const
REAL
vn
=
0.468340
;
}
;
}
// namespace Utils
...
...
include/Utils/colourConverter.hpp
View file @
23091b60
...
...
@@ -36,18 +36,30 @@ ColourConverter<REAL>::ColourConverter(VEC3 col, enum ColourEncoding enc) :
switch
(
originalEnc
)
{
case
(
C_RGB
):
assert
(
-
0.001
<
col
[
0
]
&&
col
[
0
]
<
1.001
)
;
assert
(
-
0.001
<
col
[
1
]
&&
col
[
1
]
<
1.001
)
;
assert
(
-
0.001
<
col
[
2
]
&&
col
[
2
]
<
1.001
)
;
RGB
=
new
VEC3
(
col
)
;
break
;
case
(
C_Luv
)
:
assert
(
-
0.001
<
col
[
0
]
&&
col
[
0
]
<
100.001
)
;
assert
(
-
83.001
<
col
[
1
]
&&
col
[
1
]
<
175.001
)
;
assert
(
-
134.001
<
col
[
2
]
&&
col
[
2
]
<
108.001
)
;
Luv
=
new
VEC3
(
col
)
;
break
;
case
(
C_XYZ
)
:
assert
(
-
0.001
<
col
[
0
]
&&
col
[
0
]
<
1.001
)
;
assert
(
-
0.001
<
col
[
1
]
&&
col
[
1
]
<
1.001
)
;
assert
(
-
0.001
<
col
[
2
]
&&
col
[
2
]
<
1.001
)
;
XYZ
=
new
VEC3
(
col
)
;
break
;
case
(
C_Lab
)
:
assert
(
-
0.001
<
col
[
0
]
&&
col
[
0
]
<
100.001
)
;
assert
(
-
86.001
<
col
[
1
]
&&
col
[
1
]
<
98.001
)
;
assert
(
-
108.001
<
col
[
2
]
&&
col
[
2
]
<
95.001
)
;
Lab
=
new
VEC3
(
col
)
;
break
;
}
...
...
@@ -71,10 +83,10 @@ Geom::Vector<3,REAL> ColourConverter<REAL>::getLuv() {
template
<
typename
REAL
>
Geom
::
Vector
<
3
,
REAL
>
ColourConverter
<
REAL
>::
getLab
()
{
if
(
L
uv
==
NULL
)
if
(
L
ab
==
NULL
)
convert
(
originalEnc
,
C_Lab
)
;
return
*
L
uv
;
return
*
L
ab
;
}
template
<
typename
REAL
>
...
...
@@ -136,16 +148,17 @@ void ColourConverter<REAL>::convertXYZtoLuv() {
REAL
&
Y
=
(
*
XYZ
)[
1
]
;
REAL
&
Z
=
(
*
XYZ
)[
2
]
;
if
(
Y
>
0.008856
)
L
=
116.0
f
*
pow
(
Y
,
1.0
f
/
3.0
)
-
16
;
REAL
Ydiv
=
Y
/
Yn
;
if
(
Ydiv
>
0.008856
)
L
=
116.0
*
pow
(
Ydiv
,
1.0
f
/
3.0
)
-
16.0
;
else
// near black
L
=
903.3
*
Y
;
L
=
903.3
*
Y
div
;
REAL
den
=
X
+
15.0
*
Y
+
3
*
Z
;
REAL
u1
=
(
4.0
*
X
)
/
den
;
REAL
v1
=
(
9.0
*
X
)
/
den
;
u
=
13
*
L
*
(
u1
-
0.197832
)
;
v
=
13
*
L
*
(
v1
-
0.468340
)
;
REAL
v1
=
(
9.0
*
Y
)
/
den
;
u
=
13
*
L
*
(
u1
-
un
)
;
v
=
13
*
L
*
(
v1
-
vn
)
;
Luv
=
new
VEC3
(
L
,
u
,
v
)
;
}
...
...
@@ -161,27 +174,18 @@ void ColourConverter<REAL>::convertLuvToXYZ() {
if
(
L
>
8.0
)
Y
=
pow
(((
L
+
16.0
)
/
116.0
),
3
)
;
else
// near black
Y
=
L
/
903.3
;
Y
=
Yn
*
L
/
903.3
;
REAL
den
=
13.0
*
L
;
REAL
u1
=
u
/
den
+
0.197832
;
REAL
v1
=
v
/
den
+
0.468340
;
REAL
u1
=
u
/
den
+
un
;
REAL
v1
=
v
/
den
+
vn
;
den
=
4.0
*
v1
;
X
=
Y
*
9.0
*
u1
/
den
;
Z
=
Y
*
(
12
-
3
*
u1
-
20
*
v1
)
/
den
;
X
=
Y
*
9.0
*
u1
/
den
;
Z
=
Y
*
(
12
-
3
*
u1
-
20
*
v1
)
/
den
;
XYZ
=
new
VEC3
(
X
,
Y
,
Z
)
;
}
/*
template<typename REAL>
REAL f(REAL x) {
if (x > 0.008856)
return pow(x,1.0/3.0) ;
else
return 7.787 * x + 16.0/116.0 ;
}*/
template
<
typename
REAL
>
void
ColourConverter
<
REAL
>::
convertXYZtoLab
()
{
REAL
L
,
a
,
b
;
...
...
@@ -214,9 +218,9 @@ template<typename REAL>
void
ColourConverter
<
REAL
>::
convertLabToXYZ
()
{
REAL
X
,
Y
,
Z
;
REAL
&
L
=
(
*
L
uv
)[
0
]
;
REAL
&
a
=
(
*
L
uv
)[
1
]
;
REAL
&
b
=
(
*
L
uv
)[
2
]
;
REAL
&
L
=
(
*
L
ab
)[
0
]
;
REAL
&
a
=
(
*
L
ab
)[
1
]
;
REAL
&
b
=
(
*
L
ab
)[
2
]
;
struct
Local
{
static
REAL
f
(
REAL
x
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment