eolearn.features.utils

Utilities for EOPatch feature modification

class eolearn.features.utils.ResizeParam(value)[source]

Bases: Enum

Descriptors of spatial-resizing parameter options.

NEW_SIZE = 'new_size'
SCALE_FACTORS = 'scale_factors'
RESOLUTION = 'resolution'
class eolearn.features.utils.ResizeMethod(value)[source]

Bases: Enum

Methods available for spatial resizing of data.

NEAREST = 'nearest'
LINEAR = 'linear'
CUBIC = 'cubic'
get_cv2_method(dtype)[source]

Obtain the constant specifying the interpolation method for the CV2 library.

Parameters:

dtype (dtype | type) –

Return type:

int

get_pil_method()[source]

Obtain the constant specifying the interpolation method for the PIL library.

Return type:

Image.Resampling

class eolearn.features.utils.ResizeLib(value)[source]

Bases: Enum

Backends available for spatial resizing of data.

PIL = 'PIL'
CV2 = 'cv2'
get_compatible_dtype(dtype)[source]

Returns a suitable dtype with which the library can work. Warns if information loss could occur.

Parameters:

dtype (dtype | type) –

Return type:

dtype

eolearn.features.utils.spatially_resize_image(data, new_size=None, scale_factors=None, spatial_axes=None, resize_method=ResizeMethod.LINEAR, resize_library=ResizeLib.CV2)[source]

Resizes the image(s) according to given size or scale factors.

To specify the new scale use one of new_size or scale_factors parameters.

Parameters:
  • data (ndarray) – input image array

  • new_size (tuple[int, int] | None) – New size of the data (height, width)

  • scale_factors (tuple[float, float] | None) – Factors (f_height, f_width) by which to resize the image

  • spatial_axes (tuple[int, int] | None) – Which two axes of input data represent height and width. If left as None they are selected according to standards of eo-learn features.

  • resize_method (ResizeMethod) – Interpolation method used for resizing.

  • resize_library (ResizeLib) – Which Python library to use for resizing. Default is CV2 because it is faster, but one can use PIL, which features anti-aliasing.

Return type:

ndarray