darsia.TranslationEstimator#

class TranslationEstimator(max_features=200, tol=0.05, keep_percent=0.1)[source]#

Bases: object

Estimator of translation to align images based on feature detection.

Estimation is performed by restriction to ROIs.

Setup of user-defined tuning parameters.

Parameters:
max_featuresint

Feature detection parameter.

tolfloat

Tolerance used to detect whether matching transformation is a translation.

Methods

find_effective_translation(img_src, img_dst)

Find a translation aligning two images through feature matching.

match_roi(img_src, img_dst[, roi_src, ...])

Align two images through feature matching in provided ROIs.

find_effective_translation(img_src, img_dst, roi_src=None, roi_dst=None, mask_src=None, mask_dst=None, plot_matches=False)[source]#

Find a translation aligning two images through feature matching.

All lengths are in pixels.

Parameters:
img_src, img_dstnumpy.ndarray

Source and destination images.

roi_src, roi_dsttuple of slices, optional

Regions of interest in the source and destination images.

mask_src, mask_dstnumpy.ndarray, optional

Boolean masks of the pixels considered; None means all pixels.

plot_matchesbool, optional

Plot the matched features (debugging). Default False.

Returns:
matrixnumpy.ndarray

Transformation matrix on pixel coordinates (reverse matrix indexing).

successbool

Whether the procedure succeeded.

match_roi(img_src, img_dst, roi_src=None, roi_dst=None, plot_matches=False)[source]#

Align two images through feature matching in provided ROIs.

Parameters:
img_srcnp.ndarray or darsia.Image

Source image.

img_dstnp.ndarray or darsia.Image

Destination image.

roi_srctuple of slices

Region of interested associated to the source image.

roi_dsttuple of slices

Region of interested associated to the destination image translation.

plot_matchesbool

Flag controlling whether the matching features are plotted; useful for debugging; default value is False.

Returns:
np.ndarray, optional

Aligned source image, if input of type array.