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
4ec1d827
Commit
4ec1d827
authored
Jan 06, 2017
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #922 from cbalint13:slic
parents
46af5dc0
5d73f997
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
37 deletions
+14
-37
lsc.cpp
modules/ximgproc/src/lsc.cpp
+4
-4
slic.cpp
modules/ximgproc/src/slic.cpp
+10
-33
No files found.
modules/ximgproc/src/lsc.cpp
View file @
4ec1d827
...
...
@@ -1742,10 +1742,6 @@ inline void SuperpixelLSCImpl::PerformLSC( const int& itrnum )
&
centerC1
,
&
centerC2
,
m_nr_channels
,
m_chvec_max
,
m_dist_coeff
,
m_color_coeff
,
m_stepx
,
m_stepy
)
);
// parallel reduce structure
FeatureCenterDists
fcd
(
m_chvec
,
m_W
,
m_klabels
,
m_nr_channels
,
m_chvec_max
,
m_dist_coeff
,
m_color_coeff
,
m_stepx
,
m_stepy
,
m_numlabels
);
// K-Means
for
(
int
itr
=
0
;
itr
<
itrnum
;
itr
++
)
{
...
...
@@ -1759,6 +1755,10 @@ inline void SuperpixelLSCImpl::PerformLSC( const int& itrnum )
m_nr_channels
,
m_chvec_max
,
m_dist_coeff
,
m_color_coeff
,
m_stepx
,
m_stepy
)
);
// parallel reduce structure
FeatureCenterDists
fcd
(
m_chvec
,
m_W
,
m_klabels
,
m_nr_channels
,
m_chvec_max
,
m_dist_coeff
,
m_color_coeff
,
m_stepx
,
m_stepy
,
m_numlabels
);
// accumulate center distances
parallel_reduce
(
BlockedRange
(
0
,
m_width
),
fcd
);
...
...
modules/ximgproc/src/slic.cpp
View file @
4ec1d827
...
...
@@ -732,17 +732,6 @@ struct SeedsCenters
clustersize
.
assign
(
numlabels
,
0
);
}
void
ClearArrays
(
)
{
// refill with zero all arrays
for
(
int
b
=
0
;
b
<
nr_channels
;
b
++
)
fill
(
sigma
[
b
].
begin
(),
sigma
[
b
].
end
(),
0.0
f
);
fill
(
sigmax
.
begin
(),
sigmax
.
end
(),
0.0
f
);
fill
(
sigmay
.
begin
(),
sigmay
.
end
(),
0.0
f
);
fill
(
clustersize
.
begin
(),
clustersize
.
end
(),
0
);
}
SeedsCenters
(
const
SeedsCenters
&
counter
,
Split
)
{
*
this
=
counter
;
...
...
@@ -1006,10 +995,7 @@ inline void SuperpixelSLICImpl::PerformSLICO( const int& itrnum )
// this is the variable value of M, just start with 10
vector
<
float
>
maxxy
(
m_numlabels
,
FLT_MIN
);
// note: this is different from how usual SLIC/LKM works
float
xywt
=
float
(
m_region_size
*
m_region_size
);
// parallel reduce structure
SeedsCenters
sc
(
m_chvec
,
m_klabels
,
m_numlabels
,
m_nr_channels
);
const
float
xywt
=
float
(
m_region_size
*
m_region_size
);
for
(
int
itr
=
0
;
itr
<
itrnum
;
itr
++
)
{
...
...
@@ -1051,6 +1037,9 @@ inline void SuperpixelSLICImpl::PerformSLICO( const int& itrnum )
// Recalculate the centroid and store in the seed values
//-----------------------------------------------------------------
// parallel reduce structure
SeedsCenters
sc
(
m_chvec
,
m_klabels
,
m_numlabels
,
m_nr_channels
);
// accumulate center distances
parallel_reduce
(
BlockedRange
(
0
,
m_width
),
sc
);
...
...
@@ -1058,8 +1047,6 @@ inline void SuperpixelSLICImpl::PerformSLICO( const int& itrnum )
parallel_for_
(
Range
(
0
,
m_numlabels
),
SeedNormInvoker
(
&
m_kseeds
,
&
sc
.
sigma
,
&
sc
.
clustersize
,
&
sc
.
sigmax
,
&
sc
.
sigmay
,
&
m_kseedsx
,
&
m_kseedsy
,
m_nr_channels
)
);
// refill arrays
sc
.
ClearArrays
();
}
}
...
...
@@ -1190,20 +1177,9 @@ struct SLICGrowInvoker : ParallelLoopBody
*/
inline
void
SuperpixelSLICImpl
::
PerformSLIC
(
const
int
&
itrnum
)
{
vector
<
vector
<
float
>
>
sigma
(
m_nr_channels
);
for
(
int
b
=
0
;
b
<
m_nr_channels
;
b
++
)
sigma
[
b
].
resize
(
m_numlabels
,
0
);
vector
<
float
>
sigmax
(
m_numlabels
,
0
);
vector
<
float
>
sigmay
(
m_numlabels
,
0
);
vector
<
int
>
clustersize
(
m_numlabels
,
0
);
Mat
distvec
(
m_height
,
m_width
,
CV_32F
);
float
xywt
=
(
m_region_size
/
m_ruler
)
*
(
m_region_size
/
m_ruler
);
// parallel reduce structure
SeedsCenters
sc
(
m_chvec
,
m_klabels
,
m_numlabels
,
m_nr_channels
);
const
float
xywt
=
(
m_region_size
/
m_ruler
)
*
(
m_region_size
/
m_ruler
);
for
(
int
itr
=
0
;
itr
<
itrnum
;
itr
++
)
{
...
...
@@ -1225,15 +1201,16 @@ inline void SuperpixelSLICImpl::PerformSLIC( const int& itrnum )
//-----------------------------------------------------------------
// instead of reassigning memory on each iteration, just reset.
// parallel reduce structure
SeedsCenters
sc
(
m_chvec
,
m_klabels
,
m_numlabels
,
m_nr_channels
);
// accumulate center distances
parallel_reduce
(
BlockedRange
(
0
,
m_width
),
sc
);
// normalize centers
parallel_for_
(
Range
(
0
,
m_numlabels
),
SeedNormInvoker
(
&
m_kseeds
,
&
sigma
,
&
clustersize
,
&
sigmax
,
&
sigmay
,
&
m_kseedsx
,
&
m_kseedsy
,
m_nr_channels
)
);
parallel_for_
(
Range
(
0
,
m_numlabels
),
SeedNormInvoker
(
&
m_kseeds
,
&
s
c
.
s
igma
,
&
sc
.
clustersize
,
&
sc
.
sigmax
,
&
sc
.
sigmay
,
&
m_kseedsx
,
&
m_kseedsy
,
m_nr_channels
)
);
// refill arrays
sc
.
ClearArrays
();
}
}
...
...
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