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
552196b0
Commit
552196b0
authored
Sep 25, 2011
by
Davis King
Browse files
Added missing assert and made minor refinements to spec.
parent
d7debab6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
dlib/image_transforms/label_connected_blobs.h
dlib/image_transforms/label_connected_blobs.h
+10
-0
dlib/image_transforms/label_connected_blobs_abstract.h
dlib/image_transforms/label_connected_blobs_abstract.h
+6
-2
No files found.
dlib/image_transforms/label_connected_blobs.h
View file @
552196b0
...
@@ -120,11 +120,21 @@ namespace dlib
...
@@ -120,11 +120,21 @@ namespace dlib
label_image_type
&
label_img
label_image_type
&
label_img
)
)
{
{
// make sure requires clause is not broken
DLIB_ASSERT
(
is_same_object
(
img
,
label_img
)
==
false
,
"
\t
unsigned long label_connected_blobs()"
<<
"
\n\t
The input image and output label image can't be the same object."
);
std
::
stack
<
point
>
neighbors
;
std
::
stack
<
point
>
neighbors
;
label_img
.
set_size
(
img
.
nr
(),
img
.
nc
());
label_img
.
set_size
(
img
.
nr
(),
img
.
nc
());
assign_all_pixels
(
label_img
,
0
);
assign_all_pixels
(
label_img
,
0
);
unsigned
long
next
=
1
;
unsigned
long
next
=
1
;
if
(
img
.
size
()
==
0
)
return
0
;
const
rectangle
area
=
get_rect
(
img
);
const
rectangle
area
=
get_rect
(
img
);
std
::
vector
<
point
>
window
;
std
::
vector
<
point
>
window
;
...
...
dlib/image_transforms/label_connected_blobs_abstract.h
View file @
552196b0
...
@@ -153,6 +153,7 @@ namespace dlib
...
@@ -153,6 +153,7 @@ namespace dlib
- get_neighbors(point(c,r), neighbors) is a legal expression where neighbors
- get_neighbors(point(c,r), neighbors) is a legal expression where neighbors
is of type std::vector<point>.
is of type std::vector<point>.
- is_connected(img, point(c,r), point(c2,r2)) is a valid expression.
- is_connected(img, point(c,r), point(c2,r2)) is a valid expression.
- is_same_object(img, label_img) == false
ensures
ensures
- This function labels each of the connected blobs in img with a unique integer
- This function labels each of the connected blobs in img with a unique integer
label.
label.
...
@@ -175,8 +176,11 @@ namespace dlib
...
@@ -175,8 +176,11 @@ namespace dlib
- #label_img[r][c] == 0
- #label_img[r][c] == 0
- else
- else
- #label_img[r][c] != 0
- #label_img[r][c] != 0
- returns max(array_to_matrix(label_img))+1
- if (img.size() != 0) then
(i.e. returns a number one greater than the maximum blob id number)
- returns max(array_to_matrix(label_img))+1
(i.e. returns a number one greater than the maximum blob id number)
- else
- returns 0
- blob labels are contiguous, therefore, the number returned by this function is
- blob labels are contiguous, therefore, the number returned by this function is
the number of blobs in the image (including the background blob).
the number of blobs in the image (including the background blob).
- It is guaranteed that is_connected() and is_background() will never be
- It is guaranteed that is_connected() and is_background() will never be
...
...
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