From 6d55fcc260d0a2e48aed5f03b6bfdb55a86bd3bc Mon Sep 17 00:00:00 2001 From: Davis King Date: Sun, 20 Jul 2014 08:07:59 -0400 Subject: [PATCH] Made the disabled version of pyramid_down support the new image interface. Also added an overload of operator() for pyramid_down that takes just a single image and downsamples it. --- dlib/image_transforms/image_pyramid.h | 49 ++++++++++++++++++- .../image_transforms/image_pyramid_abstract.h | 18 +++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/dlib/image_transforms/image_pyramid.h b/dlib/image_transforms/image_pyramid.h index 39d3668bf..a3248317a 100644 --- a/dlib/image_transforms/image_pyramid.h +++ b/dlib/image_transforms/image_pyramid.h @@ -124,7 +124,19 @@ namespace dlib COMPILE_TIME_ASSERT( pixel_traits::has_alpha == false ); COMPILE_TIME_ASSERT( pixel_traits::has_alpha == false ); - down.clear(); + set_image_size(down, 0, 0); + } + + template < + typename image_type + > + void operator() ( + image_type& img + ) const + { + typedef typename image_traits::pixel_type pixel_type; + COMPILE_TIME_ASSERT( pixel_traits::has_alpha == false ); + set_image_size(img, 0, 0); } }; @@ -454,6 +466,18 @@ namespace dlib } + template < + typename image_type + > + void operator() ( + image_type& img + ) const + { + image_type temp; + (*this)(img, temp); + swap(temp, img); + } + private: @@ -788,6 +812,17 @@ namespace dlib } } + template < + typename image_type + > + void operator() ( + image_type& img + ) const + { + image_type temp; + (*this)(img, temp); + swap(temp, img); + } private: @@ -911,6 +946,18 @@ namespace dlib set_image_size(down, ((N-1)*num_rows(original))/N, ((N-1)*num_columns(original))/N); resize_image(original, down); } + + template < + typename image_type + > + void operator() ( + image_type& img + ) const + { + image_type temp; + (*this)(img, temp); + swap(temp, img); + } }; template <> diff --git a/dlib/image_transforms/image_pyramid_abstract.h b/dlib/image_transforms/image_pyramid_abstract.h index 0b32ee751..0c7635461 100644 --- a/dlib/image_transforms/image_pyramid_abstract.h +++ b/dlib/image_transforms/image_pyramid_abstract.h @@ -64,6 +64,24 @@ namespace dlib points outside the #down image. !*/ + template < + typename image_type + > + void operator() ( + image_type& img + ) const; + /*! + requires + - image_type == an image object that implements the interface defined in + dlib/image_processing/generic_image.h + - pixel_traits::pixel_type>::has_alpha == false + ensures + - This function downsamples the given image and stores the results in #img. + In particular, it is equivalent to performing: + (*this)(img, temp); + swap(img, temp); + !*/ + // ------------------------------- template