mirror of https://github.com/davisking/dlib.git
Made assign_image() and assign_image_scaled() capable of assigning to
matrices.
This commit is contained in:
parent
d45a52ede7
commit
7b591aba7a
|
@ -10,6 +10,36 @@
|
|||
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 <
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<typename src_image_type::type> is defined
|
||||
- pixel_traits<typename dest_image_type::type> 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<typename src_image_type::type> is defined
|
||||
- pixel_traits<typename dest_image_type::type> is defined
|
||||
- thresh > 0
|
||||
|
|
Loading…
Reference in New Issue