diff --git a/dlib/image_transforms/assign_image.h b/dlib/image_transforms/assign_image.h index d306541a6..534b819d7 100644 --- a/dlib/image_transforms/assign_image.h +++ b/dlib/image_transforms/assign_image.h @@ -10,6 +10,36 @@ namespace dlib { +// ---------------------------------------------------------------------------------------- + + template < + typename dest_image_type, + typename src_pixel_type + > + typename enable_if >::type impl_assign_single_pixel ( + dest_image_type& img, + long r, + long c, + const src_pixel_type& pix + ) + { + assign_pixel(img(r,c), pix); + } + + template < + typename dest_image_type, + typename src_pixel_type + > + typename disable_if >::type impl_assign_single_pixel ( + dest_image_type& img, + long r, + long c, + const src_pixel_type& pix + ) + { + assign_pixel(img[r][c], pix); + } + // ---------------------------------------------------------------------------------------- template < @@ -27,7 +57,7 @@ namespace dlib { for (long c = 0; c < src.nc(); ++c) { - assign_pixel(dest[r][c], src(r,c)); + impl_assign_single_pixel(dest,r,c, src(r,c)); } } } @@ -82,7 +112,7 @@ namespace dlib if (src.size() == 1) { - assign_pixel(dest[0][0], src(0,0)); + impl_assign_single_pixel(dest,0,0, src(0,0)); return; } @@ -126,7 +156,7 @@ namespace dlib { const double val = get_pixel_intensity(src(r,c)) - lower; - assign_pixel(dest[r][c], scale*val + dest_min); + impl_assign_single_pixel(dest,r,c, scale*val + dest_min); } } } diff --git a/dlib/image_transforms/assign_image_abstract.h b/dlib/image_transforms/assign_image_abstract.h index e335e0641..beb7d05ac 100644 --- a/dlib/image_transforms/assign_image_abstract.h +++ b/dlib/image_transforms/assign_image_abstract.h @@ -22,7 +22,8 @@ namespace dlib requires - src_image_type == is an implementation of array2d/array2d_kernel_abstract.h or a dlib::matrix or something convertible to a matrix via array_to_matrix() - - dest_image_type == is an implementation of array2d/array2d_kernel_abstract.h + - dest_image_type == is an implementation of array2d/array2d_kernel_abstract.h or + is a dlib::matrix. - pixel_traits is defined - pixel_traits is defined ensures @@ -48,7 +49,8 @@ namespace dlib requires - src_image_type == is an implementation of array2d/array2d_kernel_abstract.h or a dlib::matrix or something convertible to a matrix via array_to_matrix() - - dest_image_type == is an implementation of array2d/array2d_kernel_abstract.h + - dest_image_type == is an implementation of array2d/array2d_kernel_abstract.h or + is a dlib::matrix. - pixel_traits is defined - pixel_traits is defined - thresh > 0