Commit d2ecb3f0 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed incorrect handling of classification map nodata value in...


Fixed incorrect handling of classification map nodata value in SpectralHomogenizer (default is now -9999). Updated minimal version of specclassify to 0.2.8.
Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 43780a94
......@@ -2,6 +2,13 @@
History
=======
0.9.3 (2020-12-15)
------------------
* Fixed incorrect handling of classification map nodata value in SpectralHomogenizer (default is now -9999).
* Updated minimal version of specclassify to 0.2.8.
0.9.2 (2020-12-15)
------------------
......
......@@ -52,7 +52,7 @@ req = [
'scikit-learn>=0.23.2',
'scipy',
'seaborn',
'specclassify>=0.2.0',
'specclassify>=0.2.8',
'tabulate',
'tqdm',
]
......
......@@ -152,7 +152,7 @@ class SpectralHomogenizer(object):
:param global_clf_threshold: If given, all pixels where the computed similarity metric (set by 'classif_alg')
exceeds the given threshold are predicted using the global classifier (based on a
single transformation per band).
- only usable for 'MinDist', 'SAM' and 'SID'
- only usable for 'MinDist', 'SAM' and 'SID' as well as their kNN variants
- may be given as float, integer or string to label a certain distance percentile
- if given as string, it must match the format, e.g., '10%' for labelling the
worst 10 % of the distances as unclassified
......@@ -210,17 +210,19 @@ class SpectralHomogenizer(object):
if cls:
self.logger.info('Performing spectral homogenization using %s. Target is %s %s %s.'
% (method, tgt_satellite, tgt_sensor, tgt_LBA))
cmap_nodataVal = src_nodataVal if src_nodataVal is not None else -9999
im_homo = RSI_CP.predict(arrcube,
classifier=cls,
in_nodataVal=src_nodataVal,
cmap_nodataVal=src_nodataVal,
cmap_nodataVal=cmap_nodataVal,
out_nodataVal=out_nodataVal,
global_clf_threshold=global_clf_threshold) # type: GeoArray
if compute_errors:
errors = RSI_CP.compute_prediction_errors(im_homo, cls,
nodataVal=src_nodataVal,
cmap_nodataVal=src_nodataVal)
cmap_nodataVal=cmap_nodataVal)
if not bandwise_errors:
errors = np.median(errors, axis=2).astype(errors.dtype)
......@@ -355,7 +357,7 @@ class RSImage_ClusterPredictor(object):
return CL
def predict(self, image, classifier, in_nodataVal=None, out_nodataVal=None, cmap_nodataVal=None,
def predict(self, image, classifier, in_nodataVal=None, out_nodataVal=None, cmap_nodataVal=-9999,
global_clf_threshold=None, unclassified_pixVal=-1):
# type: (Union[np.ndarray, GeoArray], Cluster_Learner, float, float, float, Union[str, int, float], int) -> GeoArray # noqa
"""Apply the prediction function of the given specifier to the given remote sensing image.
......@@ -369,7 +371,7 @@ class RSImage_ClusterPredictor(object):
:param out_nodataVal: no data value written into the predicted image
(copied from the input image if not given)
:param cmap_nodataVal: no data value for the classification map
in case more than one sub-classes are used for prediction
in case more than one sub-classes are used for prediction (default: -9999)
:param global_clf_threshold: If given, all pixels where the computed similarity metric (set by 'classif_alg')
exceeds the given threshold are predicted using the global classifier (based on a
single transformation per band).
......@@ -385,6 +387,7 @@ class RSImage_ClusterPredictor(object):
# ensure image.nodata is present (important for classify_image() -> overwrites cmap at nodata positions)
image.nodata = in_nodataVal if in_nodataVal is not None else image.nodata # might be auto-computed here
in_nodataVal = image.nodata
##########################
# get classification map #
......
......@@ -12,7 +12,7 @@ dependencies:
- pandas
- pyrsr
- scikit-learn=0.23.2 # Classifiers have been trained with this version. Different versions might cause breaking code.
- specclassify>=0.2.0
- specclassify>=0.2.8
- pip:
- dill
......
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