Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
d486e415
Commit
d486e415
authored
Dec 15, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
parents
18f1c023
9ed5fbdb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
9 deletions
+41
-9
slic.cpp
modules/ximgproc/src/slic.cpp
+19
-9
test_slic.cpp
modules/ximgproc/test/test_slic.cpp
+22
-0
No files found.
modules/ximgproc/src/slic.cpp
View file @
d486e415
...
...
@@ -247,14 +247,14 @@ void SuperpixelSLICImpl::initialize()
// intitialize label storage
m_klabels
=
Mat
(
m_height
,
m_width
,
CV_32S
,
Scalar
::
all
(
0
)
);
// storage for edge magnitudes
Mat
edgemag
=
Mat
(
m_height
,
m_width
,
CV_32F
,
Scalar
::
all
(
0
)
);
// perturb seeds is not absolutely necessary,
// one can set this flag to false
bool
perturbseeds
=
true
;
if
(
perturbseeds
)
DetectChEdges
(
edgemag
);
// storage for edge magnitudes
Mat
edgemag
;
if
(
perturbseeds
)
DetectChEdges
(
edgemag
);
if
(
m_algorithm
==
SLICO
)
GetChSeedsK
();
...
...
@@ -268,7 +268,8 @@ void SuperpixelSLICImpl::initialize()
m_numlabels
=
(
int
)
m_kseeds
[
0
].
size
();
// perturb seeds given edges
if
(
perturbseeds
)
PerturbSeeds
(
edgemag
);
if
(
perturbseeds
)
PerturbSeeds
(
edgemag
);
if
(
m_algorithm
==
MSLIC
)
{
...
...
@@ -569,12 +570,21 @@ inline void SuperpixelSLICImpl::DetectChEdges( Mat &edgemag )
Sobel
(
m_chvec
[
c
],
dy
,
CV_32F
,
0
,
1
,
1
,
1.0
f
,
0.0
f
,
BORDER_DEFAULT
);
// acumulate ^2 derivate
S_dx
=
S_dx
+
dx
.
mul
(
dx
);
S_dy
=
S_dy
+
dy
.
mul
(
dy
);
MatExpr
dx2
=
dx
.
mul
(
dx
);
MatExpr
dy2
=
dy
.
mul
(
dy
);
if
(
S_dx
.
empty
())
{
S_dx
=
dx2
;
S_dy
=
dy2
;
}
else
{
S_dx
+=
dx2
;
S_dy
+=
dy2
;
}
}
// total magnitude
edgemag
+
=
S_dx
+
S_dy
;
edgemag
=
S_dx
+
S_dy
;
}
/*
...
...
modules/ximgproc/test/test_slic.cpp
0 → 100644
View file @
d486e415
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
namespace
opencv_test
{
namespace
{
TEST
(
ximgproc_SuperpixelSLIC
,
smoke
)
{
Mat
img
=
imread
(
cvtest
::
findDataFile
(
"cv/shared/lena.png"
),
IMREAD_COLOR
);
Mat
labImg
;
cvtColor
(
img
,
labImg
,
COLOR_BGR2Lab
);
Ptr
<
SuperpixelSLIC
>
slic
=
createSuperpixelSLIC
(
labImg
);
slic
->
iterate
(
5
);
Mat
outLabels
;
slic
->
getLabels
(
outLabels
);
EXPECT_FALSE
(
outLabels
.
empty
());
int
numSuperpixels
=
slic
->
getNumberOfSuperpixels
();
EXPECT_GT
(
numSuperpixels
,
0
);
}
}}
// namespace
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