Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
eeb6ffa9
Commit
eeb6ffa9
authored
Feb 04, 2016
by
Davis King
Browse files
Options
Browse Files
Download
Plain Diff
merged
parents
6886042c
032e5e3f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
214 additions
and
3 deletions
+214
-3
core_abstract.h
dlib/dnn/core_abstract.h
+6
-3
image_transforms.h
dlib/image_transforms.h
+1
-0
random_color_transform.h
dlib/image_transforms/random_color_transform.h
+100
-0
random_color_transform_abstract.h
dlib/image_transforms/random_color_transform_abstract.h
+77
-0
imaging.xml
docs/docs/imaging.xml
+28
-0
term_index.xml
docs/docs/term_index.xml
+2
-0
No files found.
dlib/dnn/core_abstract.h
View file @
eeb6ffa9
...
...
@@ -1135,7 +1135,8 @@ namespace dlib
);
/*!
requires
- net_type is an object of type add_layer, add_loss_layer, add_skip_layer, or add_tag_layer.
- net_type is an object of type add_layer, add_loss_layer, add_skip_layer, or
add_tag_layer.
ensures
- This function chains together i calls to n.subnet() and returns the
result. So for example:
...
...
@@ -1160,7 +1161,8 @@ namespace dlib
);
/*!
requires
- net_type is an object of type add_layer, add_loss_layer, add_skip_layer, or add_tag_layer.
- net_type is an object of type add_layer, add_loss_layer, add_skip_layer, or
add_tag_layer.
ensures
- returns the first layer in n that is of type Match. E.g. if net_type is
fc<relu<fc<input<sample_type>>>> then calling layer<relu>(n) would return
...
...
@@ -1177,7 +1179,8 @@ namespace dlib
);
/*!
requires
- net_type is an object of type add_layer, add_loss_layer, add_skip_layer, or add_tag_layer.
- net_type is an object of type add_layer, add_loss_layer, add_skip_layer, or
add_tag_layer.
ensures
- returns layer<i>(layer<Match>(n))
!*/
...
...
dlib/image_transforms.h
View file @
eeb6ffa9
...
...
@@ -24,6 +24,7 @@
#include "image_transforms/interpolation.h"
#include "image_transforms/fhog.h"
#include "image_transforms/lbp.h"
#include "image_transforms/random_color_transform.h"
#endif // DLIB_IMAGE_TRANSFORMs_
dlib/image_transforms/random_color_transform.h
0 → 100644
View file @
eeb6ffa9
// Copyright (C) 2016 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_RANDOM_cOLOR_TRANSFORM_Hh_
#define DLIB_RANDOM_cOLOR_TRANSFORM_Hh_
#include "random_color_transform_abstract.h"
#include "../image_processing/generic_image.h"
#include "../pixel.h"
#include "../rand.h"
namespace
dlib
{
// ----------------------------------------------------------------------------------------
class
random_color_transform
{
public
:
random_color_transform
(
dlib
::
rand
&
rnd
,
const
double
gamma_magnitude
=
0
.
5
,
const
double
color_magnitude
=
0
.
2
)
{
// pick a random gamma correction factor.
double
gamma
=
std
::
max
(
0
.
0
,
1
+
gamma_magnitude
*
(
rnd
.
get_random_double
()
-
0
.
5
));
// pick a random color balancing scheme.
double
red_scale
=
1
-
rnd
.
get_random_double
()
*
color_magnitude
;
double
green_scale
=
1
-
rnd
.
get_random_double
()
*
color_magnitude
;
double
blue_scale
=
1
-
rnd
.
get_random_double
()
*
color_magnitude
;
const
double
m
=
255
*
std
::
max
(
std
::
max
(
red_scale
,
green_scale
),
blue_scale
);
red_scale
/=
m
;
green_scale
/=
m
;
blue_scale
/=
m
;
// Now compute a lookup table for all the color channels. The table tells us
// what the transform does.
table
.
resize
(
256
*
3
);
unsigned
long
i
=
0
;
for
(
int
k
=
0
;
k
<
256
;
++
k
)
{
double
v
=
255
*
std
::
pow
(
k
*
red_scale
,
gamma
);
table
[
i
++
]
=
(
unsigned
char
)(
v
+
0
.
5
);
}
for
(
int
k
=
0
;
k
<
256
;
++
k
)
{
double
v
=
255
*
std
::
pow
(
k
*
green_scale
,
gamma
);
table
[
i
++
]
=
(
unsigned
char
)(
v
+
0
.
5
);
}
for
(
int
k
=
0
;
k
<
256
;
++
k
)
{
double
v
=
255
*
std
::
pow
(
k
*
blue_scale
,
gamma
);
table
[
i
++
]
=
(
unsigned
char
)(
v
+
0
.
5
);
}
}
rgb_pixel
operator
()(
rgb_pixel
p
)
const
{
p
.
red
=
table
[(
unsigned
int
)
p
.
red
];
p
.
green
=
table
[(
unsigned
int
)
p
.
green
+
256
];
p
.
blue
=
table
[(
unsigned
int
)
p
.
blue
+
512
];
return
p
;
}
private
:
std
::
vector
<
unsigned
char
>
table
;
};
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
void
disturb_colors
(
image_type
&
img_
,
dlib
::
rand
&
rnd
,
const
double
gamma_magnitude
=
0
.
5
,
const
double
color_magnitude
=
0
.
2
)
{
image_view
<
image_type
>
img
(
img_
);
random_color_transform
tform
(
rnd
,
gamma_magnitude
,
color_magnitude
);
for
(
long
r
=
0
;
r
<
img
.
nr
();
++
r
)
{
for
(
long
c
=
0
;
c
<
img
.
nc
();
++
c
)
{
rgb_pixel
temp
;
assign_pixel
(
temp
,
img
[
r
][
c
]);
temp
=
tform
(
temp
);
assign_pixel
(
img
[
r
][
c
],
temp
);
}
}
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_RANDOM_cOLOR_TRANSFORM_Hh_
dlib/image_transforms/random_color_transform_abstract.h
0 → 100644
View file @
eeb6ffa9
// Copyright (C) 2016 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_RANDOM_cOLOR_TRANSFORM_ABSTRACT_Hh_
#ifdef DLIB_RANDOM_cOLOR_TRANSFORM_ABSTRACT_Hh_
#include "../image_processing/generic_image.h"
#include "../pixel.h"
#include "../rand.h"
namespace
dlib
{
// ----------------------------------------------------------------------------------------
class
random_color_transform
{
/*!
WHAT THIS OBJECT REPRESENTS
This object generates a random color balancing and gamma correction
transform. It then allows you to apply that specific transform to as many
rgb_pixel objects as you like.
!*/
public
:
random_color_transform
(
dlib
::
rand
&
rnd
,
const
double
gamma_magnitude
=
0
.
5
,
const
double
color_magnitude
=
0
.
2
);
/*!
requires
- 0 <= gamma_magnitude
- 0 <= color_magnitude <= 1
ensures
- This constructor generates a random color transform which can be applied
by calling this object's operator() method.
- The color transform is a gamma correction and color rebalancing. If
gamma_magnitude == 0 and color_magnitude == 0 then the transform doesn't
change any colors at all. However, the larger these parameters the more
noticeable the resulting transform.
!*/
rgb_pixel
operator
()(
rgb_pixel
p
)
const
;
/*!
ensures
- returns the color transformed version of p.
!*/
};
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
void
disturb_colors
(
image_type
&
img
,
dlib
::
rand
&
rnd
,
const
double
gamma_magnitude
=
0
.
5
,
const
double
color_magnitude
=
0
.
2
);
/*!
requires
- image_type == an image object that implements the interface defined in
dlib/image_processing/generic_image.h
ensures
- Applies a random color transform to the given image. This is done by
creating a random_color_transform with the given parameters and then
transforming each pixel in the image with the resulting transform.
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_RANDOM_cOLOR_TRANSFORM_ABSTRACT_Hh_
docs/docs/imaging.xml
View file @
eeb6ffa9
...
...
@@ -244,6 +244,8 @@
<item>
zero_border_pixels
</item>
<item>
integral_image
</item>
<item>
integral_image_generic
</item>
<item>
disturb_colors
</item>
<item>
random_color_transform
</item>
</section>
...
...
@@ -293,6 +295,32 @@
<!-- ************************************************************************* -->
<component>
<name>
disturb_colors
</name>
<file>
dlib/image_transforms.h
</file>
<spec_file
link=
"true"
>
dlib/image_transforms/random_color_transform_abstract.h
</spec_file>
<description>
Applies a random color transform an image. This is done by
creating a
<a
href=
"#random_color_transform"
>
random_color_transform
</a>
with the given parameters and then
transforming each pixel in the image with the resulting transform.
</description>
</component>
<!-- ************************************************************************* -->
<component>
<name>
random_color_transform
</name>
<file>
dlib/image_transforms.h
</file>
<spec_file
link=
"true"
>
dlib/image_transforms/random_color_transform_abstract.h
</spec_file>
<description>
This object generates a random color balancing and gamma correction
transform. It then allows you to apply that specific transform to as many
<a
href=
"#rgb_pixel"
>
rgb_pixel
</a>
objects as you like.
</description>
</component>
<!-- ************************************************************************* -->
<component>
<name>
integral_image_generic
</name>
<file>
dlib/image_transforms.h
</file>
...
...
docs/docs/term_index.xml
View file @
eeb6ffa9
...
...
@@ -1321,6 +1321,8 @@
<term
file=
"imaging.html"
name=
"integral_image"
include=
"dlib/image_transforms.h"
/>
<term
file=
"imaging.html"
name=
"integral_image_generic"
include=
"dlib/image_transforms.h"
/>
<term
file=
"imaging.html"
name=
"disturb_colors"
include=
"dlib/image_transforms.h"
/>
<term
file=
"imaging.html"
name=
"random_color_transform"
include=
"dlib/image_transforms.h"
/>
<term
file=
"imaging.html"
name=
"hough_transform"
include=
"dlib/image_transforms.h"
/>
<term
file=
"imaging.html"
name=
"skeleton"
include=
"dlib/image_transforms.h"
/>
<term
file=
"imaging.html"
name=
"hessian_pyramid"
include=
"dlib/image_keypoint.h"
/>
...
...
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