Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
121fa049
Commit
121fa049
authored
Aug 15, 2017
by
Rostislav Vasilikhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
srgb support added
parent
5ea1c722
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
test_color.cpp
modules/imgproc/test/test_color.cpp
+74
-0
No files found.
modules/imgproc/test/test_color.cpp
View file @
121fa049
...
...
@@ -87,6 +87,7 @@ protected:
int
fwd_code
,
inv_code
;
bool
test_cpp
;
int
hue_range
;
bool
srgb
;
};
...
...
@@ -108,6 +109,7 @@ CV_ColorCvtBaseTest::CV_ColorCvtBaseTest( bool _custom_inv_transform, bool _allo
test_cpp
=
false
;
hue_range
=
0
;
blue_idx
=
0
;
srgb
=
false
;
inplace
=
false
;
}
...
...
@@ -146,6 +148,7 @@ void CV_ColorCvtBaseTest::get_test_array_types_and_sizes( int test_case_idx,
cn
=
(
cvtest
::
randInt
(
rng
)
&
1
)
+
3
;
blue_idx
=
cvtest
::
randInt
(
rng
)
&
1
?
2
:
0
;
srgb
=
(
cvtest
::
randInt
(
rng
)
&
1
)
!=
0
;
types
[
INPUT
][
0
]
=
CV_MAKETYPE
(
depth
,
cn
);
types
[
OUTPUT
][
0
]
=
types
[
REF_OUTPUT
][
0
]
=
CV_MAKETYPE
(
depth
,
3
);
...
...
@@ -1004,6 +1007,16 @@ void CV_ColorXYZTest::convert_row_abc2bgr_32f_c3( const float* src_row, float* d
//// rgb <=> L*a*b*
static
inline
float
applyGamma
(
float
x
)
{
return
x
<=
0.04045
f
?
x
*
(
1.
f
/
12.92
f
)
:
(
float
)
std
::
pow
((
double
)(
x
+
0.055
)
*
(
1.
/
1.055
),
2.4
);
}
static
inline
float
applyInvGamma
(
float
x
)
{
return
x
<=
0.0031308
?
x
*
12.92
f
:
(
float
)(
1.055
*
std
::
pow
((
double
)
x
,
1.
/
2.4
)
-
0.055
);
}
class
CV_ColorLabTest
:
public
CV_ColorCvtBaseTest
{
public
:
...
...
@@ -1026,10 +1039,20 @@ void CV_ColorLabTest::get_test_array_types_and_sizes( int test_case_idx, vector<
{
CV_ColorCvtBaseTest
::
get_test_array_types_and_sizes
(
test_case_idx
,
sizes
,
types
);
if
(
srgb
)
{
if
(
blue_idx
==
0
)
fwd_code
=
CV_BGR2Lab
,
inv_code
=
CV_Lab2BGR
;
else
fwd_code
=
CV_RGB2Lab
,
inv_code
=
CV_Lab2RGB
;
}
else
{
if
(
blue_idx
==
0
)
fwd_code
=
CV_LBGR2Lab
,
inv_code
=
CV_Lab2LBGR
;
else
fwd_code
=
CV_LRGB2Lab
,
inv_code
=
CV_Lab2LRGB
;
}
}
...
...
@@ -1065,6 +1088,16 @@ void CV_ColorLabTest::convert_row_bgr2abc_32f_c3(const float* src_row, float* ds
float
G
=
src_row
[
x
+
1
];
float
B
=
src_row
[
x
];
R
=
std
::
min
(
std
::
max
(
R
,
0.
f
),
1.
f
);
G
=
std
::
min
(
std
::
max
(
G
,
0.
f
),
1.
f
);
B
=
std
::
min
(
std
::
max
(
B
,
0.
f
),
1.
f
);
if
(
srgb
)
{
R
=
applyGamma
(
R
);
G
=
applyGamma
(
G
);
B
=
applyGamma
(
B
);
}
float
X
=
(
R
*
M
[
0
]
+
G
*
M
[
1
]
+
B
*
M
[
2
])
/
Xn
;
float
Y
=
R
*
M
[
3
]
+
G
*
M
[
4
]
+
B
*
M
[
5
];
float
Z
=
(
R
*
M
[
6
]
+
G
*
M
[
7
]
+
B
*
M
[
8
])
/
Zn
;
...
...
@@ -1139,6 +1172,16 @@ void CV_ColorLabTest::convert_row_abc2bgr_32f_c3( const float* src_row, float* d
float
G
=
M
[
3
]
*
X
+
M
[
4
]
*
Y
+
M
[
5
]
*
Z
;
float
B
=
M
[
6
]
*
X
+
M
[
7
]
*
Y
+
M
[
8
]
*
Z
;
R
=
std
::
min
(
std
::
max
(
R
,
0.
f
),
1.
f
);
G
=
std
::
min
(
std
::
max
(
G
,
0.
f
),
1.
f
);
B
=
std
::
min
(
std
::
max
(
B
,
0.
f
),
1.
f
);
if
(
srgb
)
{
R
=
applyInvGamma
(
R
);
G
=
applyInvGamma
(
G
);
B
=
applyInvGamma
(
B
);
}
dst_row
[
x
]
=
B
;
dst_row
[
x
+
1
]
=
G
;
dst_row
[
x
+
2
]
=
R
;
...
...
@@ -1169,10 +1212,20 @@ void CV_ColorLuvTest::get_test_array_types_and_sizes( int test_case_idx, vector<
{
CV_ColorCvtBaseTest
::
get_test_array_types_and_sizes
(
test_case_idx
,
sizes
,
types
);
if
(
srgb
)
{
if
(
blue_idx
==
0
)
fwd_code
=
CV_BGR2Luv
,
inv_code
=
CV_Luv2BGR
;
else
fwd_code
=
CV_RGB2Luv
,
inv_code
=
CV_Luv2RGB
;
}
else
{
if
(
blue_idx
==
0
)
fwd_code
=
CV_LBGR2Luv
,
inv_code
=
CV_Luv2LBGR
;
else
fwd_code
=
CV_LRGB2Luv
,
inv_code
=
CV_Luv2LRGB
;
}
}
...
...
@@ -1224,6 +1277,16 @@ void CV_ColorLuvTest::convert_row_bgr2abc_32f_c3( const float* src_row, float* d
float
g
=
src_row
[
j
+
1
];
float
b
=
src_row
[
j
];
r
=
std
::
min
(
std
::
max
(
r
,
0.
f
),
1.
f
);
g
=
std
::
min
(
std
::
max
(
g
,
0.
f
),
1.
f
);
b
=
std
::
min
(
std
::
max
(
b
,
0.
f
),
1.
f
);
if
(
srgb
)
{
r
=
applyGamma
(
r
);
g
=
applyGamma
(
g
);
b
=
applyGamma
(
b
);
}
float
X
=
r
*
M
[
0
]
+
g
*
M
[
1
]
+
b
*
M
[
2
];
float
Y
=
r
*
M
[
3
]
+
g
*
M
[
4
]
+
b
*
M
[
5
];
float
Z
=
r
*
M
[
6
]
+
g
*
M
[
7
]
+
b
*
M
[
8
];
...
...
@@ -1309,6 +1372,17 @@ void CV_ColorLuvTest::convert_row_abc2bgr_32f_c3( const float* src_row, float* d
float
g
=
M
[
3
]
*
X
+
M
[
4
]
*
Y
+
M
[
5
]
*
Z
;
float
b
=
M
[
6
]
*
X
+
M
[
7
]
*
Y
+
M
[
8
]
*
Z
;
r
=
std
::
min
(
std
::
max
(
r
,
0.
f
),
1.
f
);
g
=
std
::
min
(
std
::
max
(
g
,
0.
f
),
1.
f
);
b
=
std
::
min
(
std
::
max
(
b
,
0.
f
),
1.
f
);
if
(
srgb
)
{
r
=
applyInvGamma
(
r
);
g
=
applyInvGamma
(
g
);
b
=
applyInvGamma
(
b
);
}
dst_row
[
j
]
=
b
;
dst_row
[
j
+
1
]
=
g
;
dst_row
[
j
+
2
]
=
r
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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