Unverified Commit 46bcd205 authored by Juha Reunanen's avatar Juha Reunanen Committed by GitHub
Browse files

If nearest-neighbor interpolation is wanted, then don't use an image pyramid. (#1986)

parent 44302188
...@@ -1888,6 +1888,12 @@ namespace dlib ...@@ -1888,6 +1888,12 @@ namespace dlib
} }
#endif #endif
// If nearest-neighbor interpolation is wanted, then don't use an image pyramid.
constexpr bool image_pyramid_enabled = !std::is_same<
std::remove_const_t<std::remove_reference_t<decltype(interp)>>,
interpolate_nearest_neighbor
>::value;
pyramid_down<2> pyr; pyramid_down<2> pyr;
long max_depth = 0; long max_depth = 0;
// If the chip is supposed to be much smaller than the source subwindow then you // If the chip is supposed to be much smaller than the source subwindow then you
...@@ -1902,7 +1908,7 @@ namespace dlib ...@@ -1902,7 +1908,7 @@ namespace dlib
long depth = 0; long depth = 0;
double grow = 2; double grow = 2;
drectangle rect = pyr.rect_down(chip_locations[i].rect); drectangle rect = pyr.rect_down(chip_locations[i].rect);
while (rect.area() > chip_locations[i].size()) while (rect.area() > chip_locations[i].size() && image_pyramid_enabled)
{ {
rect = pyr.rect_down(rect); rect = pyr.rect_down(rect);
++depth; ++depth;
...@@ -1950,7 +1956,7 @@ namespace dlib ...@@ -1950,7 +1956,7 @@ namespace dlib
// figure out which level in the pyramid to use to extract the chip // figure out which level in the pyramid to use to extract the chip
int level = -1; int level = -1;
drectangle rect = translate_rect(chip_locations[i].rect, -bounding_box.tl_corner()); drectangle rect = translate_rect(chip_locations[i].rect, -bounding_box.tl_corner());
while (pyr.rect_down(rect).area() > chip_locations[i].size()) while (pyr.rect_down(rect).area() > chip_locations[i].size() && image_pyramid_enabled)
{ {
++level; ++level;
rect = pyr.rect_down(rect); rect = pyr.rect_down(rect);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment