diff --git a/dlib/image_transforms/interpolation.h b/dlib/image_transforms/interpolation.h index 32f935d66..f928103ff 100644 --- a/dlib/image_transforms/interpolation.h +++ b/dlib/image_transforms/interpolation.h @@ -1275,6 +1275,36 @@ namespace dlib } } + template < + typename pyramid_type, + typename image_array_type + > + void upsample_image_dataset ( + image_array_type& images, + std::vector>& objects + ) + { + // make sure requires clause is not broken + DLIB_ASSERT( images.size() == objects.size(), + "\t void upsample_image_dataset()" + << "\n\t Invalid inputs were given to this function." + << "\n\t images.size(): " << images.size() + << "\n\t objects.size(): " << objects.size() + ); + + typename image_array_type::value_type temp; + pyramid_type pyr; + for (unsigned long i = 0; i < images.size(); ++i) + { + pyramid_up(images[i], temp, pyr); + swap(temp, images[i]); + for (unsigned long j = 0; j < objects[i].size(); ++j) + { + objects[i][j].rect = pyr.rect_up(objects[i][j].rect); + } + } + } + template < typename pyramid_type, typename image_array_type diff --git a/dlib/image_transforms/interpolation_abstract.h b/dlib/image_transforms/interpolation_abstract.h index dcb441b7b..0bd353787 100644 --- a/dlib/image_transforms/interpolation_abstract.h +++ b/dlib/image_transforms/interpolation_abstract.h @@ -651,6 +651,33 @@ namespace dlib #objects[i].size() == objects[i].size() !*/ +// ---------------------------------------------------------------------------------------- + + template < + typename pyramid_type, + typename image_array_type + > + void upsample_image_dataset ( + image_array_type& images, + std::vector>& objects + ); + /*! + requires + - image_array_type == a dlib::array or std::vector of image objects that each + implement the interface defined in dlib/image_processing/generic_image.h + - images.size() == objects.size() + ensures + - This function replaces each image in images with an upsampled version of that + image. Each image is upsampled using pyramid_up() and the given + pyramid_type. Therefore, #images[i] will contain the larger upsampled + version of images[i]. It also adjusts all the rectangles in objects so that + they still bound the same visual objects in each image. + - #images.size() == image.size() + - #objects.size() == objects.size() + - for all valid i: + #objects[i].size() == objects[i].size() + !*/ + // ---------------------------------------------------------------------------------------- template <