Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
45b4f4f3
Commit
45b4f4f3
authored
Aug 25, 2012
by
Jason Newton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
connectedComponents: warning free version
parent
4d059e9e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
18 deletions
+19
-18
imgproc.hpp
modules/imgproc/include/opencv2/imgproc/imgproc.hpp
+5
-0
connectedcomponents.cpp
modules/imgproc/src/connectedcomponents.cpp
+0
-0
connected_components.cpp
samples/cpp/connected_components.cpp
+14
-18
No files found.
modules/imgproc/include/opencv2/imgproc/imgproc.hpp
View file @
45b4f4f3
...
@@ -1091,6 +1091,11 @@ enum { TM_SQDIFF=0, TM_SQDIFF_NORMED=1, TM_CCORR=2, TM_CCORR_NORMED=3, TM_CCOEFF
...
@@ -1091,6 +1091,11 @@ enum { TM_SQDIFF=0, TM_SQDIFF_NORMED=1, TM_CCORR=2, TM_CCORR_NORMED=3, TM_CCOEFF
CV_EXPORTS_W
void
matchTemplate
(
InputArray
image
,
InputArray
templ
,
CV_EXPORTS_W
void
matchTemplate
(
InputArray
image
,
InputArray
templ
,
OutputArray
result
,
int
method
);
OutputArray
result
,
int
method
);
//! computes the connected components labeled image of boolean image I with 4 or 8 way connectivity - returns N, the total
//number of labels [0, N-1] where 0 represents the background label.
CV_EXPORTS_W
uint64_t
connectedComponents
(
Mat
&
L
,
const
Mat
&
I
,
int
connectivity
=
8
);
//! mode of the contour retrieval algorithm
//! mode of the contour retrieval algorithm
enum
enum
{
{
...
...
modules/imgproc/src/connectedcomponents.cpp
0 → 100644
View file @
45b4f4f3
This diff is collapsed.
Click to expand it.
samples/cpp/connected_components.cpp
View file @
45b4f4f3
...
@@ -11,25 +11,21 @@ int threshval = 100;
...
@@ -11,25 +11,21 @@ int threshval = 100;
static
void
on_trackbar
(
int
,
void
*
)
static
void
on_trackbar
(
int
,
void
*
)
{
{
Mat
bw
=
threshval
<
128
?
(
img
<
threshval
)
:
(
img
>
threshval
);
Mat
bw
=
threshval
<
128
?
(
img
<
threshval
)
:
(
img
>
threshval
);
Mat
labelImage
(
img
.
size
(),
CV_32S
);
vector
<
vector
<
Point
>
>
contours
;
int
nLabels
=
connectedComponents
(
labelImage
,
bw
,
8
);
vector
<
Vec4i
>
hierarchy
;
Vec3b
colors
[
nLabels
];
colors
[
0
]
=
Vec3b
(
0
,
0
,
0
);
//background
findContours
(
bw
,
contours
,
hierarchy
,
CV_RETR_CCOMP
,
CV_CHAIN_APPROX_SIMPLE
);
for
(
int
label
=
1
;
label
<
nLabels
;
++
label
){
colors
[
label
]
=
Vec3b
(
(
rand
()
&
255
),
(
rand
()
&
255
),
(
rand
()
&
255
)
);
Mat
dst
=
Mat
::
zeros
(
img
.
size
(),
CV_8UC3
);
if
(
!
contours
.
empty
()
&&
!
hierarchy
.
empty
()
)
{
// iterate through all the top-level contours,
// draw each connected component with its own random color
int
idx
=
0
;
for
(
;
idx
>=
0
;
idx
=
hierarchy
[
idx
][
0
]
)
{
Scalar
color
(
(
rand
()
&
255
),
(
rand
()
&
255
),
(
rand
()
&
255
)
);
drawContours
(
dst
,
contours
,
idx
,
color
,
CV_FILLED
,
8
,
hierarchy
);
}
}
}
Mat
dst
(
img
.
size
(),
CV_8UC3
);
for
(
int
r
=
0
;
r
<
dst
.
rows
;
++
r
){
for
(
int
c
=
0
;
c
<
dst
.
cols
;
++
c
){
int
label
=
labelImage
.
at
<
int
>
(
r
,
c
);
Vec3b
&
pixel
=
dst
.
at
<
Vec3b
>
(
r
,
c
);
pixel
=
colors
[
label
];
}
}
imshow
(
"Connected Components"
,
dst
);
imshow
(
"Connected Components"
,
dst
);
}
}
...
...
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