Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
2d086b45
Commit
2d086b45
authored
Jul 15, 2012
by
Davis King
Browse files
Added sum_filter_assign().
parent
ca13ff7c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
1 deletion
+61
-1
dlib/image_transforms/spatial_filtering.h
dlib/image_transforms/spatial_filtering.h
+34
-1
dlib/image_transforms/spatial_filtering_abstract.h
dlib/image_transforms/spatial_filtering_abstract.h
+27
-0
No files found.
dlib/image_transforms/spatial_filtering.h
View file @
2d086b45
...
@@ -621,7 +621,10 @@ namespace dlib
...
@@ -621,7 +621,10 @@ namespace dlib
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
namespace
impl
{
template
<
template
<
bool
add_to
,
typename
image_type1
,
typename
image_type1
,
typename
image_type2
typename
image_type2
>
>
...
@@ -710,10 +713,40 @@ namespace dlib
...
@@ -710,10 +713,40 @@ namespace dlib
// add in the new right side of the rect and subtract the old right side.
// 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
];
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
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
dlib/image_transforms/spatial_filtering_abstract.h
View file @
2d086b45
...
@@ -338,6 +338,33 @@ namespace dlib
...
@@ -338,6 +338,33 @@ namespace dlib
- #out[r][c] == out[r][c] + SUM(r,c)
- #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
<
template
<
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment