Commit 7b591aba authored by Davis King's avatar Davis King

Made assign_image() and assign_image_scaled() capable of assigning to

matrices.
parent d45a52ed
...@@ -10,6 +10,36 @@ ...@@ -10,6 +10,36 @@
namespace dlib namespace dlib
{ {
// ----------------------------------------------------------------------------------------
template <
typename dest_image_type,
typename src_pixel_type
>
typename enable_if<is_matrix<dest_image_type> >::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<is_matrix<dest_image_type> >::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 < template <
...@@ -27,7 +57,7 @@ namespace dlib ...@@ -27,7 +57,7 @@ namespace dlib
{ {
for (long c = 0; c < src.nc(); ++c) 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 ...@@ -82,7 +112,7 @@ namespace dlib
if (src.size() == 1) if (src.size() == 1)
{ {
assign_pixel(dest[0][0], src(0,0)); impl_assign_single_pixel(dest,0,0, src(0,0));
return; return;
} }
...@@ -126,7 +156,7 @@ namespace dlib ...@@ -126,7 +156,7 @@ namespace dlib
{ {
const double val = get_pixel_intensity(src(r,c)) - lower; 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);
} }
} }
} }
......
...@@ -22,7 +22,8 @@ namespace dlib ...@@ -22,7 +22,8 @@ namespace dlib
requires requires
- src_image_type == is an implementation of array2d/array2d_kernel_abstract.h or - 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() 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<typename src_image_type::type> is defined - pixel_traits<typename src_image_type::type> is defined
- pixel_traits<typename dest_image_type::type> is defined - pixel_traits<typename dest_image_type::type> is defined
ensures ensures
...@@ -48,7 +49,8 @@ namespace dlib ...@@ -48,7 +49,8 @@ namespace dlib
requires requires
- src_image_type == is an implementation of array2d/array2d_kernel_abstract.h or - 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() 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<typename src_image_type::type> is defined - pixel_traits<typename src_image_type::type> is defined
- pixel_traits<typename dest_image_type::type> is defined - pixel_traits<typename dest_image_type::type> is defined
- thresh > 0 - thresh > 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment