pwspy.utility.machineVision.SIFTRegisterTransform

pwspy.utility.machineVision.SIFTRegisterTransform(reference, other, mask=None, debugPlots=False)[source]

Given a 2D reference image and a list of other images of the same scene but shifted a bit this function will use OpenCV to calculate the transform from each of the other images to the reference. The transforms can be inverted using cv2.invertAffineTransform(). It will return a list of transforms. Each transform is a 2x3 array in the form returned by opencv.estimateAffinePartial2d(). a boolean mask can be used to select which areas will be searched for features to be used in calculating the transform. This seems to work much better for normalized images. This code is basically a copy of this example, it can probably be improved upon: https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_feature_homography/py_feature_homography.html

Parameters
  • reference (np.ndarray) – The 2d reference image.

  • other (Iterable[np.ndarray]) – An iterable containing the images that you want to calculate the translations for.

  • mask (np.ndarray) – A boolean array indicating which parts of the reference image should be analyzed. If None then the whole image will be used.

  • debugPlots (bool) – Indicates if extra plots should be openend showing the process of the function.

Returns

A tuple containing:

List[np.ndarray]: Returns a list of transforms. Each transform is a 2x3 array in the form returned by opencv.estimateAffinePartial2d(). Note that even though they are returned as affine transforms they will only contain translation information, no scaling, shear, or rotation.

ArtistAnimation: A reference the animation used to diplay the results of the function.

Return type

tuple