eolearn.ml_tools.postprocessing

Module contains tools and EOTasks for morphological and postprocessing operations

class eolearn.ml_tools.postprocessing.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.ml_tools.postprocessing.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.ml_tools.postprocessing.PostprocessingTask(*args, **kwargs)[source]

Bases: eolearn.core.eotask.EOTask

Base class for all post-processing tasks

Parameters

feature ((FeatureType, str)) – A feature to be processed

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

abstract process(raster)[source]

Abstract method for processing the raster

execute(eopatch)[source]

Execute method takes EOPatch and changes the specified feature

class eolearn.ml_tools.postprocessing.MorphologicalFilterTask(*args, **kwargs)[source]

Bases: eolearn.ml_tools.postprocessing.PostprocessingTask

EOTask that performs morphological operations on masks.

Parameters
  • feature ((FeatureType, str)) – A feature to be processed

  • morph_operation (MorphologicalOperations or function that operates on image) – Morphological operation

  • struct_elem (numpy.ndarray) – The structuring element to be used with the morphological operation; usually generated with a factory method from MorphologicalStructElements

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

process(raster)[source]

Applies the morphological operation to the mask object