Skip to content
Snippets Groups Projects
Commit 9f205b4b authored by Frisinghelli Daniel's avatar Frisinghelli Daniel
Browse files

Added a generic class to define label mappings.

parent 1be8822b
No related branches found
No related tags found
No related merge requests found
...@@ -77,24 +77,6 @@ class Sentinel2(MultiSpectralSensor): ...@@ -77,24 +77,6 @@ class Sentinel2(MultiSpectralSensor):
swir2 = 12 swir2 = 12
class Gdal2Numpy(enum.Enum):
"""Data type mapping from gdal to numpy."""
Byte = np.uint8
UInt8 = np.uint8
Int8 = np.int8
UInt16 = np.uint16
Int16 = np.int16
UInt32 = np.uint32
Int32 = np.int32
Float32 = np.float32
Float64 = np.float64
CInt16 = np.complex64
CInt32 = np.complex64
CFloat32 = np.complex64
CFloat64 = np.complex64
class Label(enum.Enum): class Label(enum.Enum):
"""Generic enumeration for class labels.""" """Generic enumeration for class labels."""
...@@ -112,8 +94,34 @@ class Label(enum.Enum): ...@@ -112,8 +94,34 @@ class Label(enum.Enum):
def label_dict(cls): def label_dict(cls):
"""Return the enumeration as a nested dictionary.""" """Return the enumeration as a nested dictionary."""
return {label.id: {'label': label.name.replace('_', ' '), return {label.id: {'label': label.name.replace('_', ' '),
'color': label.color} 'color': label.color} for label in cls}
for _, label in cls.__members__.items()}
class LabelMapping(enum.Enum):
"""Generic enumeration for mapping label classes."""
@classmethod
def label_map(cls):
"""Return the label mapping dictionary."""
return {label.name: label.value for label in cls}
class Gdal2Numpy(LabelMapping):
"""Data type mapping from gdal to numpy."""
Byte = np.uint8
UInt8 = np.uint8
Int8 = np.int8
UInt16 = np.uint16
Int16 = np.int16
UInt32 = np.uint32
Int32 = np.int32
Float32 = np.float32
Float64 = np.float64
CInt16 = np.complex64
CInt32 = np.complex64
CFloat32 = np.complex64
CFloat64 = np.complex64
class SparcsLabels(Label): class SparcsLabels(Label):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment