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
18695b7b
Commit
18695b7b
authored
Dec 23, 2015
by
Davis King
Browse files
Made the default input layer automatically normalize unsigned char pixel values
to the range [0,1].
parent
09564840
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
dlib/dnn/input.h
dlib/dnn/input.h
+11
-2
dlib/dnn/input_abstract.h
dlib/dnn/input_abstract.h
+4
-0
No files found.
dlib/dnn/input.h
View file @
18695b7b
...
...
@@ -58,6 +58,8 @@ namespace dlib
// initialize data to the right size to contain the stuff in the iterator range.
data
.
set_size
(
std
::
distance
(
ibegin
,
iend
),
pixel_traits
<
T
>::
num
,
nr
,
nc
);
typedef
typename
pixel_traits
<
T
>::
basic_pixel_type
bptype
;
const
size_t
offset
=
nr
*
nc
;
auto
ptr
=
data
.
host
();
for
(
auto
i
=
ibegin
;
i
!=
iend
;
++
i
)
...
...
@@ -70,6 +72,9 @@ namespace dlib
auto
p
=
ptr
++
;
for
(
long
j
=
0
;
j
<
temp
.
size
();
++
j
)
{
if
(
is_same_type
<
bptype
,
unsigned
char
>::
value
)
*
p
=
temp
(
j
)
/
256.0
;
else
*
p
=
temp
(
j
);
p
+=
offset
;
}
...
...
@@ -130,6 +135,7 @@ namespace dlib
// initialize data to the right size to contain the stuff in the iterator range.
data
.
set_size
(
std
::
distance
(
ibegin
,
iend
),
pixel_traits
<
T
>::
num
,
nr
,
nc
);
typedef
typename
pixel_traits
<
T
>::
basic_pixel_type
bptype
;
const
size_t
offset
=
nr
*
nc
;
auto
ptr
=
data
.
host
();
...
...
@@ -143,6 +149,9 @@ namespace dlib
auto
p
=
ptr
++
;
for
(
long
j
=
0
;
j
<
temp
.
size
();
++
j
)
{
if
(
is_same_type
<
bptype
,
unsigned
char
>::
value
)
*
p
=
temp
(
j
)
/
256.0
;
else
*
p
=
temp
(
j
);
p
+=
offset
;
}
...
...
dlib/dnn/input_abstract.h
View file @
18695b7b
...
...
@@ -135,6 +135,10 @@ namespace dlib
For example, a matrix<float,3,3> would turn into a tensor with 3 rows, 3
columns, and k()==1. Or a matrix<rgb_pixel,4,5> would turn into a tensor
with 4 rows, 5 columns, and k()==3 (since rgb_pixels have 3 channels).
- If the input data contains pixels of type unsigned char, rgb_pixel, or
other pixel types with a basic_pixel_type of unsigned char then each
value written to the output tensor is first divided by 256.0 so that the
resulting outputs are all in the range [0,1].
!*/
};
...
...
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