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
3f163bd4
Commit
3f163bd4
authored
Nov 08, 2020
by
Davis King
Browse files
Fix pixels being rounded to int values in some cases (#2228)
parent
83921b39
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
4 deletions
+23
-4
dlib/matrix/matrix_utilities.h
dlib/matrix/matrix_utilities.h
+1
-1
dlib/test/image.cpp
dlib/test/image.cpp
+17
-0
dlib/test/pixel.cpp
dlib/test/pixel.cpp
+5
-3
No files found.
dlib/matrix/matrix_utilities.h
View file @
3f163bd4
...
...
@@ -3049,7 +3049,7 @@ namespace dlib
const
M
&
m
)
{
pixel
=
static_cast
<
unsigned
char
>
(
m
(
0
));
pixel
=
static_cast
<
P
>
(
m
(
0
));
}
};
...
...
dlib/test/image.cpp
View file @
3f163bd4
...
...
@@ -1754,6 +1754,23 @@ namespace
<<
" error: "
<<
max
(
abs
(
chip
-
255
))
);
}
// So the same as above, but for an image with float values that are all the same to make
// sure noting funny happens for float images.
{
print_spinner
();
const
long
nr
=
53
;
const
long
nc
=
67
;
const
long
size
=
8
*
9
;
const
double
angle
=
30
*
pi
/
180
;
matrix
<
float
>
img
(
501
,
501
),
chip
;
img
=
1234.5
;
chip_details
details
(
centered_rect
(
center
(
get_rect
(
img
)),
nr
,
nc
),
size
,
angle
);
extract_image_chip
(
img
,
details
,
chip
);
DLIB_TEST_MSG
(
max
(
abs
(
chip
-
1234.5
))
==
0
,
"nr: "
<<
nr
<<
" nc: "
<<
nc
<<
" size: "
<<
size
<<
" angle: "
<<
angle
<<
" error: "
<<
max
(
abs
(
chip
-
255
))
);
}
{
// Make sure that the interpolation in extract_image_chip() keeps stuff in the
...
...
dlib/test/pixel.cpp
View file @
3f163bd4
...
...
@@ -449,7 +449,7 @@ namespace
p_gray
=
8
;
p_schar
=
8
;
p_int
=
8
;
p_float
=
8
;
p_float
=
8
.5
;
p_hsi
.
h
=
9
;
p_hsi
.
s
=
10
;
...
...
@@ -501,7 +501,7 @@ namespace
DLIB_TEST
(
p_gray
==
8
);
DLIB_TEST
(
p_schar
==
8
);
DLIB_TEST
(
p_int
==
8
);
DLIB_TEST
(
p_float
==
8
);
DLIB_TEST
(
p_float
==
8
.5
);
DLIB_TEST
(
p_hsi
.
h
==
9
);
DLIB_TEST
(
p_hsi
.
s
==
10
);
...
...
@@ -550,7 +550,7 @@ namespace
DLIB_TEST
(
p_gray
==
8
);
DLIB_TEST
(
p_int
==
8
);
DLIB_TEST
(
p_float
==
8
);
DLIB_TEST
(
p_float
==
8
.5
);
DLIB_TEST
(
p_schar
==
8
);
DLIB_TEST
(
p_hsi
.
h
==
9
);
...
...
@@ -566,6 +566,7 @@ namespace
assign_pixel
(
p_rgb
,
0
);
assign_pixel
(
p_lab
,
0
);
vector_to_pixel
(
p_float
,
m_float
);
vector_to_pixel
(
p_gray
,
m_gray
);
vector_to_pixel
(
p_hsi
,
m_hsi
);
vector_to_pixel
(
p_rgb
,
m_rgb
);
...
...
@@ -581,6 +582,7 @@ namespace
DLIB_TEST
(
p_rgba
.
alpha
==
7
);
DLIB_TEST
(
p_gray
==
8
);
DLIB_TEST
(
p_float
==
8.5
);
DLIB_TEST
(
p_hsi
.
h
==
9
);
DLIB_TEST
(
p_hsi
.
s
==
10
);
...
...
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