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