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
cf77875d
Commit
cf77875d
authored
Aug 25, 2017
by
Davis King
Browse files
Gave create_tiled_pyramid() the ability to include padding around the outsides
of the pyramid image.
parent
02cf246d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
dlib/image_transforms/image_pyramid.h
dlib/image_transforms/image_pyramid.h
+8
-6
dlib/image_transforms/image_pyramid_abstract.h
dlib/image_transforms/image_pyramid_abstract.h
+4
-2
No files found.
dlib/image_transforms/image_pyramid.h
View file @
cf77875d
...
@@ -988,7 +988,8 @@ namespace dlib
...
@@ -988,7 +988,8 @@ namespace dlib
const
image_type1
&
img
,
const
image_type1
&
img
,
image_type2
&
out_img
,
image_type2
&
out_img
,
std
::
vector
<
rectangle
>&
rects
,
std
::
vector
<
rectangle
>&
rects
,
const
unsigned
long
padding
=
10
const
unsigned
long
padding
=
10
,
const
unsigned
long
outer_padding
=
0
)
)
{
{
DLIB_ASSERT
(
!
is_same_object
(
img
,
out_img
));
DLIB_ASSERT
(
!
is_same_object
(
img
,
out_img
));
...
@@ -1038,14 +1039,15 @@ namespace dlib
...
@@ -1038,14 +1039,15 @@ namespace dlib
}
}
height
-=
padding
;
// don't add unnecessary padding to the very right side.
height
-=
padding
;
// don't add unnecessary padding to the very right side.
set_image_size
(
out_img
,
height
,
img
.
nc
());
const
long
width
=
img
.
nc
();
set_image_size
(
out_img
,
height
+
outer_padding
*
2
,
width
+
outer_padding
*
2
);
assign_all_pixels
(
out_img
,
0
);
assign_all_pixels
(
out_img
,
0
);
long
y
=
0
;
long
y
=
outer_padding
;
size_t
i
=
0
;
size_t
i
=
0
;
while
(
y
<
height
)
while
(
y
<
height
+
outer_padding
)
{
{
rectangle
rect
=
translate_rect
(
get_rect
(
pyramid
[
i
]),
point
(
0
,
y
));
rectangle
rect
=
translate_rect
(
get_rect
(
pyramid
[
i
]),
point
(
outer_padding
,
y
));
DLIB_ASSERT
(
get_rect
(
out_img
).
contains
(
rect
));
DLIB_ASSERT
(
get_rect
(
out_img
).
contains
(
rect
));
rects
.
push_back
(
rect
);
rects
.
push_back
(
rect
);
auto
si
=
sub_image
(
out_img
,
rect
);
auto
si
=
sub_image
(
out_img
,
rect
);
...
@@ -1056,7 +1058,7 @@ namespace dlib
...
@@ -1056,7 +1058,7 @@ namespace dlib
y
-=
padding
;
y
-=
padding
;
while
(
i
<
pyramid
.
size
())
while
(
i
<
pyramid
.
size
())
{
{
point
p1
(
img
.
nc
()
-
1
,
y
-
1
);
point
p1
(
outer_padding
+
width
-
1
,
y
-
1
);
point
p2
=
p1
-
get_rect
(
pyramid
[
i
]).
br_corner
();
point
p2
=
p1
-
get_rect
(
pyramid
[
i
]).
br_corner
();
rectangle
rect
(
p1
,
p2
);
rectangle
rect
(
p1
,
p2
);
DLIB_ASSERT
(
get_rect
(
out_img
).
contains
(
rect
));
DLIB_ASSERT
(
get_rect
(
out_img
).
contains
(
rect
));
...
...
dlib/image_transforms/image_pyramid_abstract.h
View file @
cf77875d
...
@@ -219,7 +219,8 @@ namespace dlib
...
@@ -219,7 +219,8 @@ namespace dlib
const
image_type1
&
img
,
const
image_type1
&
img
,
image_type2
&
out_img
,
image_type2
&
out_img
,
std
::
vector
<
rectangle
>&
rects
,
std
::
vector
<
rectangle
>&
rects
,
const
unsigned
long
padding
=
10
const
unsigned
long
padding
=
10
,
const
unsigned
long
outer_padding
=
0
);
);
/*!
/*!
requires
requires
...
@@ -237,7 +238,8 @@ namespace dlib
...
@@ -237,7 +238,8 @@ namespace dlib
pyramid levels are generated from pyramid_type's downsampling. The entire
pyramid levels are generated from pyramid_type's downsampling. The entire
resulting pyramid is packed into a single image and stored in out_img.
resulting pyramid is packed into a single image and stored in out_img.
- When packing pyramid levels into out_img, there will be padding pixels of
- When packing pyramid levels into out_img, there will be padding pixels of
space between each sub-image.
space between each sub-image. There will also be outer_padding pixels of
padding around the edge of the image. All padding pixels have a value of 0.
- The resulting pyramid will be composed of #rects.size() images packed into
- The resulting pyramid will be composed of #rects.size() images packed into
out_img. Moreover, #rects[i] is the location inside out_img of the i-th
out_img. Moreover, #rects[i] is the location inside out_img of the i-th
pyramid level.
pyramid level.
...
...
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