mirror of https://github.com/davisking/dlib.git
Added a version of resize_image() that works inplace.
This commit is contained in:
parent
ce3ed6591d
commit
0a7a75a245
|
@ -1007,6 +1007,29 @@ namespace dlib
|
||||||
resize_image(in_img, out_img, interpolate_bilinear());
|
resize_image(in_img, out_img, interpolate_bilinear());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template <
|
||||||
|
typename image_type
|
||||||
|
>
|
||||||
|
void resize_image (
|
||||||
|
double size_scale,
|
||||||
|
image_type& img
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// make sure requires clause is not broken
|
||||||
|
DLIB_ASSERT( size_scale > 0 ,
|
||||||
|
"\t void resize_image()"
|
||||||
|
<< "\n\t Invalid inputs were given to this function."
|
||||||
|
<< "\n\t size_scale: " << size_scale
|
||||||
|
);
|
||||||
|
|
||||||
|
image_type temp;
|
||||||
|
set_image_size(temp, std::round(size_scale*num_rows(img)), std::round(size_scale*num_columns(img)));
|
||||||
|
resize_image(img, temp);
|
||||||
|
swap(img, temp);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
template <
|
template <
|
||||||
|
|
|
@ -414,6 +414,28 @@ namespace dlib
|
||||||
- Uses the bilinear interpolation to perform the necessary pixel interpolation.
|
- Uses the bilinear interpolation to perform the necessary pixel interpolation.
|
||||||
!*/
|
!*/
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template <
|
||||||
|
typename image_type
|
||||||
|
>
|
||||||
|
void resize_image (
|
||||||
|
double size_scale,
|
||||||
|
image_type& img
|
||||||
|
);
|
||||||
|
/*!
|
||||||
|
requires
|
||||||
|
- image_type == an image object that implements the interface defined in
|
||||||
|
dlib/image_processing/generic_image.h
|
||||||
|
- pixel_traits<typename image_traits<image_type>::pixel_type>::has_alpha == false
|
||||||
|
ensures
|
||||||
|
- Resizes img so that each of it's dimensions are size_scale times larger than img.
|
||||||
|
In particular, we will have:
|
||||||
|
- #img.nr() == std::round(size_scale*img.nr())
|
||||||
|
- #img.nc() == std::round(size_scale*img.nc())
|
||||||
|
- #img == a bilinearly interpolated copy of the input image.
|
||||||
|
!*/
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
template <
|
template <
|
||||||
|
|
Loading…
Reference in New Issue