Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
dd9804dc
"examples/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "993fd3f94baff137216d2b16dade638f3b6c99c3"
Commit
dd9804dc
authored
Apr 06, 2013
by
Davis King
Browse files
Added some unit tests for the new floating point DNG formats
parent
b4f74bd9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
dlib/test/image.cpp
dlib/test/image.cpp
+70
-0
No files found.
dlib/test/image.cpp
View file @
dd9804dc
...
@@ -1332,6 +1332,69 @@ namespace
...
@@ -1332,6 +1332,69 @@ namespace
}
}
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
void
test_dng_floats
(
double
scale
)
{
dlog
<<
LINFO
<<
"in test_dng_floats"
;
print_spinner
();
array2d
<
T
>
img
(
100
,
101
);
dlib
::
rand
rnd
;
for
(
long
r
=
0
;
r
<
img
.
nr
();
++
r
)
{
for
(
long
c
=
0
;
c
<
img
.
nc
();
++
c
)
{
T
val
=
rnd
.
get_random_double
()
*
scale
;
img
[
r
][
c
]
=
val
;
// Lets the float_details object while we are here doing this stuff.
float_details
temp
=
val
;
T
val2
=
temp
;
// for the same type we should exactly reproduce the value.
DLIB_TEST
(
val2
==
val
);
float
valf
=
temp
;
double
vald
=
temp
;
long
double
vall
=
temp
;
DLIB_TEST
(
std
::
abs
(
valf
-
val
)
<
scale
*
std
::
numeric_limits
<
float
>::
epsilon
());
DLIB_TEST
(
std
::
abs
(
vald
-
val
)
<
scale
*
std
::
numeric_limits
<
double
>::
epsilon
());
DLIB_TEST
(
std
::
abs
(
vall
-
val
)
<
scale
*
std
::
numeric_limits
<
long
double
>::
epsilon
());
}
}
ostringstream
sout
;
save_dng
(
img
,
sout
);
istringstream
sin
;
array2d
<
float
>
img1
;
array2d
<
double
>
img2
;
array2d
<
long
double
>
img3
;
sin
.
clear
();
sin
.
str
(
sout
.
str
());
load_dng
(
img1
,
sin
);
sin
.
clear
();
sin
.
str
(
sout
.
str
());
load_dng
(
img2
,
sin
);
sin
.
clear
();
sin
.
str
(
sout
.
str
());
load_dng
(
img3
,
sin
);
DLIB_TEST
(
img
.
nr
()
==
img1
.
nr
());
DLIB_TEST
(
img
.
nr
()
==
img2
.
nr
());
DLIB_TEST
(
img
.
nr
()
==
img3
.
nr
());
DLIB_TEST
(
img
.
nc
()
==
img1
.
nc
());
DLIB_TEST
(
img
.
nc
()
==
img2
.
nc
());
DLIB_TEST
(
img
.
nc
()
==
img3
.
nc
());
DLIB_TEST
(
max
(
abs
(
mat
(
img
)
-
matrix_cast
<
T
>
(
mat
(
img1
))))
<
scale
*
std
::
numeric_limits
<
float
>::
epsilon
());
DLIB_TEST
(
max
(
abs
(
mat
(
img
)
-
matrix_cast
<
T
>
(
mat
(
img2
))))
<
scale
*
std
::
numeric_limits
<
double
>::
epsilon
());
DLIB_TEST
(
max
(
abs
(
mat
(
img
)
-
matrix_cast
<
T
>
(
mat
(
img3
))))
<
scale
*
std
::
numeric_limits
<
long
double
>::
epsilon
());
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
class
image_tester
:
public
tester
class
image_tester
:
public
tester
...
@@ -1373,6 +1436,13 @@ namespace
...
@@ -1373,6 +1436,13 @@ namespace
test_segment_image
<
int
>
();
test_segment_image
<
int
>
();
test_segment_image
<
rgb_pixel
>
();
test_segment_image
<
rgb_pixel
>
();
test_segment_image
<
rgb_alpha_pixel
>
();
test_segment_image
<
rgb_alpha_pixel
>
();
test_dng_floats
<
float
>
(
1
);
test_dng_floats
<
double
>
(
1
);
test_dng_floats
<
long
double
>
(
1
);
test_dng_floats
<
float
>
(
1e30
);
test_dng_floats
<
double
>
(
1e30
);
test_dng_floats
<
long
double
>
(
1e30
);
}
}
}
a
;
}
a
;
...
...
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