mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Gave create_tiled_pyramid() the ability to include padding around the outsides
of the pyramid image.
This commit is contained in:
parent
02cf246dce
commit
cf77875dce
@ -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
|
|||||||
}
|
}
|
||||||
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
|
|||||||
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));
|
||||||
|
@ -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
|
|||||||
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user