eolearn.coregistration.coregistration

This module implements the co-registration transformers.

class eolearn.coregistration.coregistration.InterpolationType(value)[source]

Bases: enum.Enum

Types of interpolation, available are NEAREST, LINEAR and CUBIC

NEAREST = 0
LINEAR = 1
CUBIC = 3
class eolearn.coregistration.coregistration.RegistrationTask(*args, **kwargs)[source]

Bases: eolearn.core.eotask.EOTask, abc.ABC

Abstract class for multi-temporal image co-registration

The task uses a temporal stack of images of the same location (i.e. a temporal-spatial feature in EOPatch). Starting from the latest frame and proceeding backwards it calculates a transformation between two temporally adjacent images. The transformation is used to correct the earlier image to best fit the later. The reason for such reversed order is that the latest frames are supposed to be less affected by orthorectificational inaccuracies.

Each transformation is calculated using only a single channel of the images. If feature which contains masks of valid pixels is specified it is used during the calculation. At the end the transformations are applied to each of the specified features. Any additional registration parameters can be passed on to registration method class.

Parameters:

Parameters
  • registration_feature ((FeatureType, str) or str) – A feature which will be used for co-registration, e.g. feature=(FeatureType.DATA, ‘bands’). By default this feature is of type FeatureType.DATA therefore also only feature name can be given e.g. feature=’bands’

  • channel (int) – Index of feature’s channel to be used in co-registration

  • valid_mask_feature (str or (FeatureType, str) or None) – Feature containing a mask of valid pixels for registration_feature. By default no mask is set. It can be set to e.g. valid_mask_feature=(FeatureType.MASK, ‘IS_DATA’) or valid_mask_feature=’IS_DATA’ if the feature is of type FeatureType.MASK

  • apply_to_features (dict(FeatureType: set(str) or dict(str: str))) – A collection of features to which co-registration will be applied to. By default this is only registration_feature and valid_mask_feature if given. Note that each feature must have same temporal dimension as registration_feature.

  • interpolation_type (InterpolationType) – Type of interpolation used. Default is InterpolationType.CUBIC

  • params (object) – Any other registration setting which will be passed to registration method

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

abstract register(src, trg, trg_mask=None, src_mask=None)[source]

Method for registration

Parameters
  • src – src

  • trg – trg

  • trg_mask – trg_mask

  • src_mask – src_mask

abstract check_params()[source]

Method to validate registration parameters

abstract get_params()[source]

Method to print out registration parameters used

execute(eopatch)[source]

Method that estimates registrations and warps EOPatch objects

warp(warp_matrix, img, iflag=0)[source]

Function to warp input image given an estimated 2D linear transformation

Parameters
  • warp_matrix (ndarray) – Linear 2x3 matrix to use to linearly warp the input images

  • img (ndarray) – Image to be warped with estimated transformation

  • iflag (cv2.INTER_*) – Interpolation flag, specified interpolation using during resampling of warped image

Returns

Warped image using the linear matrix

static is_registration_suspicious(warp_matrix)[source]

Static method that check if estimated linear transformation could be unplausible

This function checks whether the norm of the estimated translation or the rotation angle exceed predefined values. For the translation, a maximum translation radius of 20 pixels is flagged, while larger rotations than 20 degrees are flagged.

Parameters

warp_matrix (ndarray) – Input linear transformation matrix

Returns

0 if registration doesn’t exceed threshold, 1 otherwise

class eolearn.coregistration.coregistration.ThunderRegistrationTask(*args, **kwargs)[source]

Bases: eolearn.coregistration.coregistration.RegistrationTask

Registration task implementing a translational registration using the thunder-registration package

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

register(src, trg, trg_mask=None, src_mask=None)[source]

Implementation of pair-wise registration using thunder-registration

For more information on the model estimation, refer to https://github.com/thunder-project/thunder-registration This function takes two 2D single channel images and estimates a 2D translation that best aligns the pair. The estimation is done by maximising the correlation of the Fourier transforms of the images. Once, the translation is estimated, it is applied to the (multi-channel) image to warp and, possibly, ot hte ground-truth. Different interpolations schemes could be more suitable for images and ground-truth values (or masks).

Parameters
  • src – 2D single channel source moving image

  • trg – 2D single channel target reference image

  • src_mask – Mask of source image. Not used in this method.

  • trg_mask – Mask of target image. Not used in this method.

Returns

Estimated 2D transformation matrix of shape 2x3

get_params()[source]

Method to print out registration parameters used

check_params()[source]

Method to validate registration parameters

class eolearn.coregistration.coregistration.ECCRegistrationTask(*args, **kwargs)[source]

Bases: eolearn.coregistration.coregistration.RegistrationTask

Registration task implementing an intensity-based method from OpenCV

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

get_params()[source]

Method to print out registration parameters used

check_params()[source]

Method to validate registration parameters

register(src, trg, trg_mask=None, src_mask=None)[source]

Implementation of pair-wise registration and warping using Enhanced Correlation Coefficient

This function estimates an Euclidean transformation (x,y translation + rotation) using the intensities of the pair of images to be registered. The similarity metric is a modification of the cross-correlation metric, which is invariant to distortions in contrast and brightness.

Parameters
  • src – 2D single channel source moving image

  • trg – 2D single channel target reference image

  • trg_mask – Mask of target image. Not used in this method.

  • src_mask – Mask of source image. Not used in this method.

Returns

Estimated 2D transformation matrix of shape 2x3

class eolearn.coregistration.coregistration.PointBasedRegistrationTask(*args, **kwargs)[source]

Bases: eolearn.coregistration.coregistration.RegistrationTask

Registration class implementing a point-based registration from OpenCV contrib package

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

get_params()[source]

Method to print out registration parameters used

check_params()[source]

Method to validate registration parameters

register(src, trg, trg_mask=None, src_mask=None)[source]

Implementation of pair-wise registration and warping using point-based matching

This function estimates a number of transforms (Euler, PartialAffine and Homography) using point-based matching. Features descriptor are first extracted from the pair of images using either SIFT or SURF descriptors. A brute-force point-matching algorithm estimates matching points and a transformation is computed. All transformations use RANSAC to robustly fit a tranform to the matching points. However, the feature extraction and point matching estimation can be very poor and unstable. In those cases, an identity transform is used to warp the images instead.

Parameters
  • src – 2D single channel source moving image

  • trg – 2D single channel target reference image

  • trg_mask – Mask of target image. Not used in this method.

  • src_mask – Mask of source image. Not used in this method.

Returns

Estimated 2D transformation matrix of shape 2x3

static rescale_image(image)[source]

Normalise and scale image in 0-255 range

eolearn.coregistration.coregistration.get_gradient(src)[source]

Method which calculates and returns the gradients for the input image, which are better suited for co-registration

Parameters

src (ndarray) – input image

Returns

ndarray

class eolearn.coregistration.coregistration.ThunderRegistration(*args, **kwargs)[source]

Bases: eolearn.coregistration.coregistration.ThunderRegistrationTask

A deprecated version of ThunderRegistrationTask

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

class eolearn.coregistration.coregistration.ECCRegistration(*args, **kwargs)[source]

Bases: eolearn.coregistration.coregistration.ECCRegistrationTask

A deprecated version of ECCRegistrationTask

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

class eolearn.coregistration.coregistration.PointBasedRegistration(*args, **kwargs)[source]

Bases: eolearn.coregistration.coregistration.PointBasedRegistrationTask

A deprecated version of PointBasedRegistrationTask

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