eolearn.geometry.morphology

Module containing tasks for morphological operations

class eolearn.geometry.morphology.ErosionTask(mask_feature, disk_radius=1, erode_labels=None, no_data_label=0)[source]

Bases: EOTask

The task performs an erosion to the provided mask

Parameters:
  • mask_feature (SingleFeatureSpec) – The mask which is to be eroded

  • disk_radius (int) – Radius of the erosion disk (in pixels). Default is set to 1

  • erode_labels (list[int] | None) – List of labels to erode. If None, all unique labels are eroded. Default is None

  • no_data_label (int) – Value used to replace eroded pixels. Default is set to 0

Stores initialization parameters and the order to the instance attribute init_args.

execute(eopatch)[source]

Override to specify action performed by task.

Parameters:

eopatch (EOPatch) –

Return type:

EOPatch

class eolearn.geometry.morphology.MorphologicalOperations(value)[source]

Bases: Enum

Enum class of morphological operations

OPENING = 'opening'
CLOSING = 'closing'
DILATION = 'dilation'
EROSION = 'erosion'
classmethod get_operation(morph_type)[source]

Maps morphological operation type to function

Parameters:

morph_type (MorphologicalOperations) – Morphological operation type

Return type:

int

class eolearn.geometry.morphology.MorphologicalStructFactory[source]

Bases: object

Factory methods for generating morphological structuring elements

static get_disk(radius)[source]
Parameters:

radius (int) – Radius of disk

Returns:

The structuring element where elements of the neighborhood are 1 and 0 otherwise.

Return type:

ndarray

static get_rectangle(width, height)[source]
Parameters:
  • width (int) – Width of rectangle

  • height (int) – Height of rectangle

Returns:

A structuring element consisting only of ones, i.e. every pixel belongs to the neighborhood.

Return type:

ndarray

static get_square(width)[source]
Parameters:

width (int) – Size of square

Returns:

A structuring element consisting only of ones, i.e. every pixel belongs to the neighborhood.

Return type:

ndarray

class eolearn.geometry.morphology.MorphologicalFilterTask(input_features, output_features=None, *, morph_operation, struct_elem=None)[source]

Bases: MapFeatureTask

Performs morphological operations on masks.

Parameters:
  • input_features (FeaturesSpecification) – Input features to be processed.

  • output_features (FeaturesSpecification | None) – Outputs of input features. If not provided the input_features are overwritten.

  • morph_operation (MorphologicalOperations) – A morphological operation.

  • struct_elem (np.ndarray | None) – A structuring element to be used with the morphological operation. Usually it is generated with a factory method from MorphologicalStructElements

map_method(feature)[source]

Applies the morphological operation to a raster feature.

Parameters:

feature (ndarray) –

Return type:

ndarray