mirror of https://github.com/davisking/dlib.git
Made the default input layer automatically normalize unsigned char pixel values
to the range [0,1].
This commit is contained in:
parent
09564840a1
commit
18695b7b4b
|
@ -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,7 +72,10 @@ namespace dlib
|
|||
auto p = ptr++;
|
||||
for (long j = 0; j < temp.size(); ++j)
|
||||
{
|
||||
*p = temp(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,7 +149,10 @@ namespace dlib
|
|||
auto p = ptr++;
|
||||
for (long j = 0; j < temp.size(); ++j)
|
||||
{
|
||||
*p = temp(j);
|
||||
if (is_same_type<bptype,unsigned char>::value)
|
||||
*p = temp(j)/256.0;
|
||||
else
|
||||
*p = temp(j);
|
||||
p += offset;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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].
|
||||
!*/
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue