Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
otbtf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lozac'h Loic
otbtf
Commits
03982953
Commit
03982953
authored
Dec 13, 2018
by
Cresson Remi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: pre allocate containers
parent
a5191935
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
app/otbPatchesSelection.cxx
app/otbPatchesSelection.cxx
+14
-5
No files found.
app/otbPatchesSelection.cxx
View file @
03982953
...
...
@@ -370,22 +370,28 @@ public:
otbAppLogINFO
(
"Spatial sampling step "
<<
samplingStep
);
float
step
=
0
;
std
::
vector
<
SampleBundle
>
seed
;
std
::
vector
<
SampleBundle
>
candidates
;
std
::
vector
<
SampleBundle
>
seed
(
count
)
;
std
::
vector
<
SampleBundle
>
candidates
(
count
)
;
unsigned
int
seedCount
=
0
;
unsigned
int
candidatesCount
=
0
;
for
(
auto
&
d
:
bundles
)
{
if
(
step
>=
samplingStep
)
{
seed
.
push_back
(
d
)
;
seed
[
seedCount
]
=
d
;
step
=
fmod
(
step
,
samplingStep
);
seedCount
++
;
}
else
{
candidates
.
push_back
(
d
);
candidates
[
candidatesCount
]
=
d
;
candidatesCount
++
;
}
step
++
;
}
seed
.
resize
(
seedCount
);
candidates
.
resize
(
candidatesCount
);
otbAppLogINFO
(
"Spatial seed size : "
<<
seed
.
size
());
...
...
@@ -410,6 +416,7 @@ public:
DistributionType
idealDist
(
nbOfClasses
,
1.0
/
std
::
sqrt
(
static_cast
<
float
>
(
nbOfClasses
)));
float
minCos
=
0
;
unsigned
int
samplesAdded
=
0
;
seed
.
resize
(
seed
.
size
()
+
candidates
.
size
(),
SampleBundle
(
nbOfClasses
));
while
(
candidates
.
size
()
>
0
)
{
// Sort by cos
...
...
@@ -426,7 +433,8 @@ public:
if
(
idealCos
>
minCos
)
{
minCos
=
idealCos
;
seed
.
push_back
(
candidate
);
seed
[
seedCount
]
=
candidate
;
seedCount
++
;
candidates
.
pop_back
();
samplesAdded
++
;
}
...
...
@@ -435,6 +443,7 @@ public:
break
;
}
}
seed
.
resize
(
seedCount
);
otbAppLogINFO
(
"Final samples number: "
<<
seed
.
size
()
<<
" ("
<<
samplesAdded
<<
" samples added)"
);
otbAppLogINFO
(
"Final samples distribution: "
<<
seedDist
.
ToString
());
...
...
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