Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
fff97234
Commit
fff97234
authored
May 27, 2018
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed label_connected_blobs_watershed() not giving contiguous labels as
outputs. Also cleaned up the code a bit.
parent
1a3f8d5b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
label_connected_blobs.h
dlib/image_transforms/label_connected_blobs.h
+14
-7
No files found.
dlib/image_transforms/label_connected_blobs.h
View file @
fff97234
...
...
@@ -217,20 +217,22 @@ namespace dlib
<<
"
\n\t
The input images can't be the same object."
);
using
label_pixel_type
=
typename
image_traits
<
out_image_type
>::
pixel_type
;
DLIB_ASSERT
(
smoothing
>=
0
);
COMPILE_TIME_ASSERT
(
is_unsigned_type
<
typename
image_traits
<
out_image_type
>::
pixel_type
>::
value
);
COMPILE_TIME_ASSERT
(
is_unsigned_type
<
label_
pixel_type
>::
value
);
struct
watershed_points
{
watershed_points
()
=
default
;
watershed_points
(
const
point
&
p_
,
float
score_
,
unsigned
int
label_
)
:
p
(
p_
),
score
(
score_
),
label
(
label_
)
{}
watershed_points
(
const
point
&
p_
,
float
score_
,
label_pixel_type
label_
)
:
p
(
p_
),
score
(
score_
),
label
(
label_
)
{}
point
p
;
float
score
=
0
;
unsigned
int
label
=
std
::
numeric_limits
<
unsigned
int
>::
max
();
label_pixel_type
label
=
std
::
numeric_limits
<
label_pixel_type
>::
max
();
bool
is_seed
()
const
{
return
label
==
std
::
numeric_limits
<
unsigned
int
>::
max
();
}
bool
is_seed
()
const
{
return
label
==
std
::
numeric_limits
<
label_pixel_type
>::
max
();
}
bool
operator
<
(
const
watershed_points
&
rhs
)
const
{
...
...
@@ -289,7 +291,7 @@ namespace dlib
continue
;
}
next
.
push
(
watershed_points
(
point
(
c
,
r
),
val
,
std
::
numeric_limits
<
unsigned
int
>::
max
()));
next
.
push
(
watershed_points
(
point
(
c
,
r
),
val
,
std
::
numeric_limits
<
label_pixel_type
>::
max
()));
}
}
...
...
@@ -297,7 +299,7 @@ namespace dlib
const
rectangle
area
=
get_rect
(
img
);
unsigned
int
next_label
=
1
;
label_pixel_type
next_label
=
1
;
std
::
vector
<
point
>
neighbors
;
...
...
@@ -307,14 +309,19 @@ namespace dlib
auto
p
=
next
.
top
();
next
.
pop
();
unsigned
int
label
;
label_pixel_type
label
;
// If the next pixel is a seed of a new blob and is still labeled as a
// background pixel (i.e. it hasn't been flooded over by a neighboring blob and
// consumed by it) then we create a new label for this new blob.
if
(
p
.
is_seed
()
&&
labels
[
p
.
p
.
y
()][
p
.
p
.
x
()]
==
0
)
{
label
=
next_label
++
;
labels
[
p
.
p
.
y
()][
p
.
p
.
x
()]
=
label
;
}
else
{
label
=
p
.
label
;
}
neighbors
.
clear
();
...
...
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