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: eolearn.core.eotask.EOTask

The task performs an erosion to the provided mask

Parameters
  • mask_feature ((FeatureType, str)) – 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)) – 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.

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

Bases: enum.Enum

Enum class of morphological operations

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

Maps morphological operation type to function

Parameters

morph_type (MorphologicalOperations) – Morphological operation type

Returns

function

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

numpy.ndarray

static get_diamond(radius)[source]
Parameters

radius (int) – Radius of diamond

Returns

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

Return type

numpy.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

numpy.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

numpy.ndarray

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

Bases: eolearn.core.core_tasks.MapFeatureTask

Performs morphological operations on masks.

Parameters
  • input_features – Input features to be processed.

  • output_features – Outputs of input features. If not provided the input_features are overwritten.

  • morph_operation (Union[eolearn.geometry.morphology.MorphologicalOperations, Callable]) – A morphological operation.

  • struct_elem (Optional[numpy.ndarray]) – 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.