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
4329935f
Commit
4329935f
authored
Nov 05, 2013
by
Davis King
Browse files
Added an overload of zero_border_pixels() that lets you give a rectangle as
input to define the non-border area.
parent
2fef9dcc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
dlib/image_transforms/assign_image.h
dlib/image_transforms/assign_image.h
+33
-0
dlib/image_transforms/assign_image_abstract.h
dlib/image_transforms/assign_image_abstract.h
+22
-0
No files found.
dlib/image_transforms/assign_image.h
View file @
4329935f
...
@@ -274,6 +274,39 @@ namespace dlib
...
@@ -274,6 +274,39 @@ namespace dlib
assign_border_pixels
(
img
,
x_border_size
,
y_border_size
,
zero_pixel
);
assign_border_pixels
(
img
,
x_border_size
,
y_border_size
,
zero_pixel
);
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
void
zero_border_pixels
(
image_type
&
img
,
rectangle
inside
)
{
inside
=
inside
.
intersect
(
get_rect
(
img
));
if
(
inside
.
is_empty
())
return
;
for
(
long
r
=
0
;
r
<
inside
.
top
();
++
r
)
{
for
(
long
c
=
0
;
c
<
img
.
nc
();
++
c
)
assign_pixel
(
img
[
r
][
c
],
0
);
}
for
(
long
r
=
inside
.
top
();
r
<=
inside
.
bottom
();
++
r
)
{
for
(
long
c
=
0
;
c
<
inside
.
left
();
++
c
)
assign_pixel
(
img
[
r
][
c
],
0
);
for
(
long
c
=
inside
.
right
()
+
1
;
c
<
img
.
nc
();
++
c
)
assign_pixel
(
img
[
r
][
c
],
0
);
}
for
(
long
r
=
inside
.
bottom
()
+
1
;
r
<
img
.
nr
();
++
r
)
{
for
(
long
c
=
0
;
c
<
img
.
nc
();
++
c
)
assign_pixel
(
img
[
r
][
c
],
0
);
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
dlib/image_transforms/assign_image_abstract.h
View file @
4329935f
...
@@ -165,6 +165,28 @@ namespace dlib
...
@@ -165,6 +165,28 @@ namespace dlib
(i.e. assigns 0 to every pixel in the border of img)
(i.e. assigns 0 to every pixel in the border of img)
!*/
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
void
zero_border_pixels
(
image_type
&
img
,
rectangle
inside
);
/*!
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- pixel_traits<typename image_type::type> is defined
ensures
- #img.nc() == img.nc()
- #img.nr() == img.nr()
(i.e. the size of img isn't changed by this function)
- All the pixels in img that are not contained inside the inside rectangle
given to this function are set to 0. That is, anything not "inside" is on
the border and set to 0.
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
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