darsia.TranslationAnalysis#
- class TranslationAnalysis(base, N_patches, rel_overlap, translation_estimator, mask=None)[source]#
Bases:
objectClass for translation analysis.
Constructor for TranslationAnalysis.
It allows to determine the translation of any image to a given baseline image in order to provide a best-possible match, based on feature detection.
- Parameters:
- base
image Baseline image; it serves as fixed point in the analysis, which is relevant if a series of translations is analyzed. Furthermore, the baseline image provides all reference values as the coordinate system, e.g.
- N_patches
listoftwoint Number of patches in x and y direction.
- rel_overlap
float Relative overal related to patch size in each direction.
- base
Methods
add_translation_analysis(translation_analysis)Add another translation analysis to the existing one.
bc_x(units)Prescribed (boundary) conditions for the displacement in x direction.
bc_y(units)Prescribed (boundary) conditions for the displacement in y direction.
deduct_translation_analysis(translation_analysis)Overwrite translation analysis by deducting from external one.
find_translation([units])Find translation map as translation from image to baseline image such that these match as best as possible, measure on features.
load_image(img[, mask])Load an image to be inspected in futher analysis.
plot_translation([reverse, scaling, mask])Translate centers of the test image and plot in terms of displacement arrows.
return_patch_translation([reverse, units])Translate patch centers of the test image.
translate_image([reverse])Apply translation to an entire image by using piecwise perspective transformation.
update_base(base)Update baseline image.
Update patches of baseline.
update_params([N_patches, rel_overlap])Routine allowing to update parameters for creating patches.
Attributes
Number of patches in matrix indexing.
Relative overlap.
Translation estimator.
Cache of current translation.
Mask of flags storing success of finding translations for patches.
Mask.
- add_translation_analysis(translation_analysis)[source]#
Add another translation analysis to the existing one. Modifies the interpolation object by redefinition.
- Parameters:
- translation_analysis
darsia.TranslationAnalysis Translation analysis holding an interpolation object.
- translation_analysis
- bc_x(units)[source]#
Prescribed (boundary) conditions for the displacement in x direction.
Can be overwritten. Here, tailored to FluidFlower scenarios, fix the displacement in x-direction at the vertical boundaries of the image.
- deduct_translation_analysis(translation_analysis)[source]#
Overwrite translation analysis by deducting from external one. (Re)defines the interpolation object.
- Parameters:
- translation_analysis
darsia.TranslationAnalysis Translation analysis holding an interpolation object.
- translation_analysis
- find_translation(units=['pixel', 'pixel'])[source]#
Find translation map as translation from image to baseline image such that these match as best as possible, measure on features.
The final translation map will be stored as callable function. And it allows various input and output spaces (metric vs. pixel).
- plot_translation(reverse=True, scaling=1.0, mask=None)[source]#
Translate centers of the test image and plot in terms of displacement arrows.
- return_patch_translation(reverse=True, units='metric')[source]#
Translate patch centers of the test image.
- Parameters:
- Returns:
np.ndarrayDeformation in patch centers.
- translate_image(reverse=True)[source]#
Apply translation to an entire image by using piecwise perspective transformation.
- Parameters:
- reversebool
Flag whether the translation is understood as from the test image to the baseline image, or reversed. The default is the latter.
- Returns:
darsia.ImageTranslated image.
- update_base(base)[source]#
Update baseline image.
- Parameters:
- base
darsia.Image Baseline image.
- base
- update_params(N_patches=None, rel_overlap=None)[source]#
Routine allowing to update parameters for creating patches.
If any of the parameters is changed, a new patch of the base image is created.
- N_patches#
Number of patches in matrix indexing.
- have_translation#
Mask of flags storing success of finding translations for patches.
- mask_base#
Mask.
- rel_overlap#
Relative overlap.
- translation#
Cache of current translation.
- translation_estimator#
Translation estimator.