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
geomultisens
gms_preprocessing
Commits
11d3bed4
Commit
11d3bed4
authored
Jun 19, 2019
by
Daniel Scheffler
Browse files
Fixed missing cmap sorting.
Signed-off-by:
Daniel Scheffler
<
danschef@gfz-potsdam.de
>
parent
3cee4c9b
Pipeline
#4201
failed with stage
in 2 minutes
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gms_preprocessing/algorithms/classification.py
View file @
11d3bed4
...
...
@@ -278,17 +278,17 @@ class kNN_MinimumDistance_Classifier(MinimumDistance_Classifier):
if
self
.
n_neighbors
<
dists
.
shape
[
2
]:
cmap
=
np
.
argpartition
(
dists
,
k
,
axis
=
2
)[:,
:,
:
k
].
astype
(
np
.
int16
)
dists_min_k
=
np
.
partition
(
dists
,
k
,
axis
=
2
)[:,
:,
:
k
].
astype
(
np
.
float32
)
# sort cmap by ascending spectral distances
idx_2D
=
np
.
argsort
(
dists_min_k
,
axis
=
2
).
reshape
(
-
1
,
cmap
.
shape
[
2
])
cmap
=
\
cmap
.
reshape
(
-
1
,
cmap
.
shape
[
2
])[
np
.
arange
(
cmap
.
shape
[
0
]
*
cmap
.
shape
[
1
])[:,
np
.
newaxis
],
idx_2D
]
\
.
reshape
(
*
cmap
.
shape
)
dists_min_k
=
np
.
sort
(
dists_min_k
,
axis
=
2
)
else
:
cmap
=
np
.
tile
(
np
.
arange
(
dists
.
shape
[
2
]).
reshape
(
1
,
1
,
-
1
),
(
*
dists
.
shape
[:
2
],
1
))
dists_min_k
=
dists
# sort cmap by ascending spectral distances
idx_2D
=
np
.
argsort
(
dists_min_k
,
axis
=
2
).
reshape
(
-
1
,
cmap
.
shape
[
2
])
cmap
=
\
cmap
.
reshape
(
-
1
,
cmap
.
shape
[
2
])[
np
.
arange
(
cmap
.
shape
[
0
]
*
cmap
.
shape
[
1
])[:,
np
.
newaxis
],
idx_2D
]
\
.
reshape
(
*
cmap
.
shape
)
dists_min_k
=
np
.
sort
(
dists_min_k
,
axis
=
2
)
if
global_shared_im2classify
.
nodata
is
not
None
and
self
.
_cmap_nodataVal
is
not
None
:
cmap
=
self
.
overwrite_cmap_at_nodata_positions
(
cmap
,
tileimdata
,
self
.
_cmap_nodataVal
,
global_shared_im2classify
.
nodata
)
...
...
@@ -402,17 +402,17 @@ class kNN_SAM_Classifier(SAM_Classifier):
if
self
.
n_neighbors
<
angles
.
shape
[
2
]:
cmap
=
np
.
argpartition
(
angles
,
k
,
axis
=
2
)[:,
:,
:
k
].
astype
(
np
.
int16
)
angles_min_k
=
np
.
partition
(
angles
,
k
,
axis
=
2
)[:,
:,
:
k
].
astype
(
np
.
float32
)
# sort cmap by ascending angles
idx_2D
=
np
.
argsort
(
angles_min_k
,
axis
=
2
).
reshape
(
-
1
,
cmap
.
shape
[
2
])
cmap
=
\
cmap
.
reshape
(
-
1
,
cmap
.
shape
[
2
])[
np
.
arange
(
cmap
.
shape
[
0
]
*
cmap
.
shape
[
1
])[:,
np
.
newaxis
],
idx_2D
]
\
.
reshape
(
*
cmap
.
shape
)
angles_min_k
=
np
.
sort
(
angles_min_k
,
axis
=
2
)
else
:
cmap
=
np
.
tile
(
np
.
arange
(
angles
.
shape
[
2
]).
reshape
(
1
,
1
,
-
1
),
(
*
angles
.
shape
[:
2
],
1
))
angles_min_k
=
angles
# sort cmap by ascending angles
idx_2D
=
np
.
argsort
(
angles_min_k
,
axis
=
2
).
reshape
(
-
1
,
cmap
.
shape
[
2
])
cmap
=
\
cmap
.
reshape
(
-
1
,
cmap
.
shape
[
2
])[
np
.
arange
(
cmap
.
shape
[
0
]
*
cmap
.
shape
[
1
])[:,
np
.
newaxis
],
idx_2D
]
\
.
reshape
(
*
cmap
.
shape
)
angles_min_k
=
np
.
sort
(
angles_min_k
,
axis
=
2
)
if
global_shared_im2classify
.
nodata
is
not
None
and
self
.
_cmap_nodataVal
is
not
None
:
cmap
=
self
.
overwrite_cmap_at_nodata_positions
(
cmap
,
tileimdata
,
self
.
_cmap_nodataVal
,
global_shared_im2classify
.
nodata
)
...
...
@@ -519,17 +519,17 @@ class kNN_FEDSA_Classifier(FEDSA_Classifier):
if
self
.
n_neighbors
<
fedsa
.
shape
[
2
]:
cmap
=
np
.
argpartition
(
fedsa
,
k
,
axis
=
2
)[:,
:,
:
k
].
astype
(
np
.
int16
)
fedsa_min_k
=
np
.
partition
(
fedsa
,
k
,
axis
=
2
)[:,
:,
:
k
].
astype
(
np
.
float32
)
# sort cmap by ascending angles
idx_2D
=
np
.
argsort
(
fedsa_min_k
,
axis
=
2
).
reshape
(
-
1
,
cmap
.
shape
[
2
])
cmap
=
\
cmap
.
reshape
(
-
1
,
cmap
.
shape
[
2
])[
np
.
arange
(
cmap
.
shape
[
0
]
*
cmap
.
shape
[
1
])[:,
np
.
newaxis
],
idx_2D
]
\
.
reshape
(
*
cmap
.
shape
)
fedsa_min_k
=
np
.
sort
(
fedsa_min_k
,
axis
=
2
)
else
:
cmap
=
np
.
tile
(
np
.
arange
(
fedsa
.
shape
[
2
]).
reshape
(
1
,
1
,
-
1
),
(
*
fedsa
.
shape
[:
2
],
1
))
fedsa_min_k
=
fedsa
# sort cmap by ascending angles
idx_2D
=
np
.
argsort
(
fedsa_min_k
,
axis
=
2
).
reshape
(
-
1
,
cmap
.
shape
[
2
])
cmap
=
\
cmap
.
reshape
(
-
1
,
cmap
.
shape
[
2
])[
np
.
arange
(
cmap
.
shape
[
0
]
*
cmap
.
shape
[
1
])[:,
np
.
newaxis
],
idx_2D
]
\
.
reshape
(
*
cmap
.
shape
)
fedsa_min_k
=
np
.
sort
(
fedsa_min_k
,
axis
=
2
)
if
global_shared_im2classify
.
nodata
is
not
None
and
self
.
_cmap_nodataVal
is
not
None
:
cmap
=
self
.
overwrite_cmap_at_nodata_positions
(
cmap
,
tileimdata
,
self
.
_cmap_nodataVal
,
global_shared_im2classify
.
nodata
)
...
...
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