Commit 087a05c0 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Changed minimum and maximum values used for normalization of spectral distance...

Changed minimum and maximum values used for normalization of spectral distance measures. SAM values are now normalized between 0 and 15 degrees SA and all other measures use the 90% percentile as maximum value. This fixes issue #9

 (Harmonization weights are affected by extreme values in the computed spectral distances between spectrum and available regressors.).
Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent d2ecb3f0
Pipeline #17055 passed with stage
in 21 minutes and 8 seconds
......@@ -6,13 +6,18 @@ History
------------------
* Fixed incorrect handling of classification map nodata value in SpectralHomogenizer (default is now -9999).
* Updated minimal version of specclassify to 0.2.8.
* Updated minimal version of specclassify to 0.2.8. This fixes issue #8 (Homogenization using kNN classifiers uses
faulty weights in case SpectralHomogenizer.predict_by_machine_learner() is called with global_clf_threshold=None.).
* Changed minimum and maximum values used for normalization of spectral distance measures. SAM values are now
normalized between 0 and 15 degrees SA and all other measures use the 90% percentile as maximum value.
This fixes issue #9 (Harmonization weights are affected by extreme values in the computed spectral distances between
spectrum and available regressors.).
0.9.2 (2020-12-15)
------------------
* Cluster classifiers can now be saved as JSON files.
* Cluster classifiers can now be saved as JSON files (relates to issue #5).
* Added attributes 'spechomo_version' and 'spechomo_versionalias' to ClusterLearner.
......
......@@ -472,11 +472,22 @@ class RSImage_ClusterPredictor(object):
if classifier.n_clusters > 1 and\
self.classif_map.ndim > 2:
dist_min, dist_max = np.min(self.distance_metrics),\
np.max(self.distance_metrics)
if self.classif_alg == 'kNN_SAM':
# scale SAM values between 0 and 15 degrees spectral angle
dist_min, dist_max = 0, 15
else:
if in_nodataVal is not None:
# exclude distances where cmap contains nodata (-9999) or unclassified (-1) values
dists4stats = self.distance_metrics[self.classif_map[:, :, 0] > 0]
else:
dists4stats = self.distance_metrics
dist_min, dist_max = np.min(dists4stats), np.percentile(dists4stats, 90)
dist_norm = (self.distance_metrics - dist_min) /\
(dist_max - dist_min)
weights = 1 - dist_norm
weights[weights < 0] = 1e-10 # FIXME 0 causes ZeroDivisionError later
else:
weights = None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment