Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Main Repositories
otb
Commits
d436514b
Commit
d436514b
authored
Sep 17, 2018
by
Cédric Traizet
Browse files
ENH : replaced vector by unordered maps
parent
424152d5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Modules/Applications/AppSegmentation/app/otbSmallRegionsMerging.cxx
View file @
d436514b
...
...
@@ -125,20 +125,22 @@ private:
labelStatsFilter
->
SetInputLabelImage
(
labelIn
);
AddProcess
(
labelStatsFilter
->
GetStreamer
()
,
"Computing stats on input image ..."
);
labelStatsFilter
->
Update
();
// Convert Map to Vector
// Convert Map to Unordered map
auto
labelPopulationMap
=
labelStatsFilter
->
GetLabelPopulationMap
();
std
::
vector
<
double
>
labelPopulation
;
for
(
unsigned
int
i
=
0
;
i
<=
labelPopulationMap
.
rbegin
()
->
first
;
i
++
)
std
::
unordered_map
<
unsigned
int
,
double
>
labelPopulation
;
for
(
population
:
labelPopulationMap
)
{
labelPopulation
.
push_back
(
labelP
opulation
Map
[
i
])
;
labelPopulation
[
population
.
first
]
=
p
opulation
.
second
;
}
auto
meanValueMap
=
labelStatsFilter
->
GetMeanValueMap
();
std
::
vector
<
itk
::
VariableLengthVector
<
double
>
>
meanValues
;
for
(
unsigned
int
i
=
0
;
i
<=
meanValueMap
.
rbegin
()
->
first
;
i
++
)
std
::
unordered_map
<
unsigned
int
,
itk
::
VariableLengthVector
<
double
>
>
meanValues
;
for
(
mean
:
meanValueMap
)
{
meanValues
.
push_back
(
meanValueMap
[
i
]);
}
meanValues
[
mean
.
first
]
=
mean
.
second
;
}
// Compute the LUT from the original label image to the merged output label image.
auto
regionMergingFilter
=
LabelImageSmallRegionMergingFilterType
::
New
();
...
...
Modules/Segmentation/Conversion/include/otbLabelImageSmallRegionMergingFilter.h
View file @
d436514b
...
...
@@ -24,6 +24,8 @@
#include
"otbPersistentImageFilter.h"
#include
"otbPersistentFilterStreamingDecorator.h"
#include
<unordered_map>
namespace
otb
{
...
...
@@ -76,9 +78,10 @@ public:
typedef
itk
::
VariableLengthVector
<
double
>
RealVectorPixelType
;
typedef
std
::
map
<
InputLabelType
,
std
::
set
<
InputLabelType
>
>
NeigboursMapType
;
typedef
std
::
vector
<
RealVectorPixelType
>
LabelStatisticType
;
typedef
std
::
vector
<
double
>
LabelPopulationType
;
typedef
std
::
vector
<
InputLabelType
>
LUTType
;
typedef
std
::
unordered_map
<
InputLabelType
,
RealVectorPixelType
>
LabelStatisticType
;
typedef
std
::
unordered_map
<
InputLabelType
,
double
>
LabelPopulationType
;
typedef
std
::
unordered_map
<
InputLabelType
,
InputLabelType
>
LUTType
;
/** Set/Get size of segments to be merged */
itkGetMacro
(
Size
,
unsigned
int
);
...
...
@@ -88,12 +91,12 @@ public:
void
SetLabelPopulation
(
LabelPopulationType
const
&
labelPopulation
)
{
m_LabelPopulation
=
labelPopulation
;
// Initialize m_CorrespondingMap to the identity (i.e. m[label] = label)
m_LUT
.
resize
(
labelPopulation
.
size
()
);
for
(
unsigned
int
i
=
0
;
i
<
labelPopulation
.
size
();
i
++
)
for
(
label
:
m_LabelPopulation
)
{
m_LUT
[
i
]
=
i
;
}
m_LUT
[
label
.
first
]
=
label
.
first
;
}
}
/** Get the Label population */
...
...
Modules/Segmentation/Conversion/include/otbLabelImageSmallRegionMergingFilter.hxx
View file @
d436514b
...
...
@@ -210,7 +210,6 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
{
assert
(
!
itN
.
IsAtEnd
()
);
int
currentLabel
=
FindCorrespondingLabel
(
it
.
Get
());
if
(
m_LabelPopulation
[
currentLabel
]
==
m_Size
)
{
for
(
auto
ci
=
itN
.
Begin
()
;
!
ci
.
IsAtEnd
();
ci
++
)
...
...
Write
Preview
Supports
Markdown
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