From 759170d3d6cae1607290b0b88efce7b1423ebeec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= <1671644+arrufat@users.noreply.github.com> Date: Fri, 2 Jun 2023 10:52:11 +0900 Subject: [PATCH] Fix pixel saturation in interpolate_quadratic (#2806) * Fix pixel saturation in interpolate_quadratic * Use pixel_type_t alias --- dlib/image_transforms/interpolation.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlib/image_transforms/interpolation.h b/dlib/image_transforms/interpolation.h index 83c9ae522..22fcea6e9 100644 --- a/dlib/image_transforms/interpolation.h +++ b/dlib/image_transforms/interpolation.h @@ -310,7 +310,9 @@ namespace dlib pixel_to_vector(img[r+1][c ])(i), pixel_to_vector(img[r+1][c+1])(i)); typename image_view_type::pixel_type temp; - vector_to_pixel(temp, pvout); + const auto min_val = pixel_traits>::min(); + const auto max_val = pixel_traits>::max(); + vector_to_pixel(temp, clamp(pvout, min_val, max_val)); assign_pixel(result, temp); return true; }