Commit 2d086b45 authored by Davis King's avatar Davis King

Added sum_filter_assign().

parent ca13ff7c
......@@ -621,7 +621,10 @@ namespace dlib
// ----------------------------------------------------------------------------------------
namespace impl
{
template <
bool add_to,
typename image_type1,
typename image_type2
>
......@@ -710,10 +713,40 @@ namespace dlib
// add in the new right side of the rect and subtract the old right side.
cur_sum = cur_sum + column_sum[c+width] - column_sum[c];
out[r][c] += static_cast<typename image_type2::type>(cur_sum);
if (add_to)
out[r][c] += static_cast<typename image_type2::type>(cur_sum);
else
out[r][c] = static_cast<typename image_type2::type>(cur_sum);
}
}
}
}
template <
typename image_type1,
typename image_type2
>
void sum_filter (
const image_type1& img,
image_type2& out,
const rectangle& rect
)
{
impl::sum_filter<true>(img,out,rect);
}
template <
typename image_type1,
typename image_type2
>
void sum_filter_assign (
const image_type1& img,
image_type2& out,
const rectangle& rect
)
{
impl::sum_filter<false>(img,out,rect);
}
// ----------------------------------------------------------------------------------------
......
......@@ -338,6 +338,33 @@ namespace dlib
- #out[r][c] == out[r][c] + SUM(r,c)
!*/
// ----------------------------------------------------------------------------------------
template <
typename image_type1,
typename image_type2
>
void sum_filter_assign (
const image_type1& img,
image_type2& out,
const rectangle& rect
);
/*!
requires
- out.nr() == img.nr()
- out.nc() == img.nc()
- image_type1 == an implementation of array2d/array2d_kernel_abstract.h
and it must contain a scalar type
- image_type2 == an implementation of array2d/array2d_kernel_abstract.h
and it must contain a scalar type
- is_same_object(img,out) == false
ensures
- for all valid r and c:
- let SUM(r,c) == sum of pixels from img which are inside the rectangle
translate_rect(rect, point(c,r)).
- #out[r][c] == SUM(r,c)
!*/
// ----------------------------------------------------------------------------------------
template <
......
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