Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Main Repositories
otb
Commits
8cab5ffd
Commit
8cab5ffd
authored
Sep 20, 2018
by
Cédric Traizet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH : Code review
parent
2653222b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
11 deletions
+18
-11
Modules/Applications/AppSegmentation/app/otbSmallRegionsMerging.cxx
...plications/AppSegmentation/app/otbSmallRegionsMerging.cxx
+2
-2
Modules/Segmentation/Conversion/include/otbLabelImageSmallRegionMergingFilter.hxx
...version/include/otbLabelImageSmallRegionMergingFilter.hxx
+16
-9
No files found.
Modules/Applications/AppSegmentation/app/otbSmallRegionsMerging.cxx
View file @
8cab5ffd
...
...
@@ -63,7 +63,7 @@ private:
{
SetName
(
"SmallRegionsMerging"
);
SetDescription
(
"This application merges small regions of a segmentation "
"result
to connected region
."
);
"result."
);
SetDocName
(
"Small Region Merging"
);
SetDocLongDescription
(
"Given a segmentation result and the original image,"
...
...
@@ -173,7 +173,7 @@ private:
const
auto
&
LUT
=
regionMergingFilter
->
GetLUT
();
for
(
auto
label
:
LUT
)
for
(
auto
const
&
label
:
LUT
)
{
if
(
label
.
first
!=
label
.
second
)
{
...
...
Modules/Segmentation/Conversion/include/otbLabelImageSmallRegionMergingFilter.hxx
View file @
8cab5ffd
...
...
@@ -69,10 +69,11 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
double
proximity
=
itk
::
NumericTraits
<
double
>::
max
();
InputLabelType
label
=
neighbours
.
first
;
InputLabelType
closestNeighbour
=
label
;
auto
const
&
statsLabel
=
m_LabelStatistic
[
label
];
for
(
auto
neighbour
:
neighbours
.
second
)
{
auto
statsLabel
=
m_LabelStatistic
[
label
];
auto
statsNeighbour
=
m_LabelStatistic
[
neighbour
];
auto
const
&
statsNeighbour
=
m_LabelStatistic
[
neighbour
];
assert
(
statsLabel
.
Size
()
==
statsNeighbour
.
Size
()
);
double
distance
=
(
statsLabel
-
statsNeighbour
).
GetSquaredNorm
();
...
...
@@ -106,16 +107,22 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
// Update statistics : for each newly merged segments, sum the population, and
// recompute the mean.
for
(
auto
label
:
m_LUT
)
for
(
auto
const
&
label
:
m_LUT
)
{
if
((
m_L
abel
Population
[
label
.
first
]
!=
0
)
&&
(
l
abel
.
second
!=
label
.
first
))
if
((
l
abel
.
second
!=
label
.
first
)
&&
(
m_L
abel
Population
[
label
.
first
]
!=
0
))
{
// Cache values to reduce number of lookups
auto
const
&
populationFirst
=
m_LabelPopulation
[
label
.
first
];
auto
const
&
populationSecond
=
m_LabelPopulation
[
label
.
second
];
auto
const
&
statisticFirst
=
m_LabelStatistic
[
label
.
first
];
auto
const
&
statisticSecond
=
m_LabelStatistic
[
label
.
second
];
m_LabelStatistic
[
label
.
second
]
=
(
m_LabelStatistic
[
label
.
first
]
*
m_LabelP
opulation
[
label
.
f
irst
]
+
m_LabelStatistic
[
label
.
second
]
*
m_LabelP
opulation
[
label
.
s
econd
]
)
/
(
m_LabelP
opulation
[
label
.
first
]
+
m_LabelP
opulation
[
label
.
s
econd
]
);
m_LabelPopulation
[
label
.
second
]
+=
m_LabelP
opulation
[
label
.
f
irst
]
;
(
(
statisticFirst
*
p
opulation
F
irst
)
+
(
statisticSecond
*
p
opulation
S
econd
)
)
/
(
p
opulation
First
+
p
opulation
S
econd
);
m_LabelPopulation
[
label
.
second
]
+=
p
opulation
F
irst
;
// Do not use this label anymore
m_LabelPopulation
[
label
.
first
]
=
0
;
...
...
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