ai_ct_scans.keypoint_alignment module
Module to provide functions to perform keypoint detection alignment.
- ai_ct_scans.keypoint_alignment.align_image(image, reference, detector='SIFT')
Align an image to a reference image using keypoint detection.
- Parameters
image (np.ndarray) – A 2D greyscale image to be aligned.
reference (np.ndarray) – A 2D greyscale image that to be used as the reference.
detector (str) – The keypoint detector to use. Should be one of [‘SIFT’, ‘ORB’].
- Returns
A 2D greyscale image that is the result of the alignment.
- Return type
(np.ndarray)
- ai_ct_scans.keypoint_alignment.find_homography(key_points_1, key_points_2, good_matches)
Estimate the transformation that maps one set of keypoints to another.
- Parameters
key_points_1 (list of cv2.KeyPoint) – The keypoints extracted from the source image.
key_points_2 (list of cv2.KeyPoint) – The keypoints extracted from the destination image.
good_matches (list of cv2.DMatch) – Matched descriptors.
- Returns
A transformation matrix that maps the first set of keypoints to the second. (np.ndarray): Mask of inlier and outlier points used to estimate transformation.
- Return type
(np.ndarray)
- ai_ct_scans.keypoint_alignment.get_keypoints_and_descriptors(image, detector='SIFT')
Get keypoints and compute corresponding descriptors from an image.
- Parameters
image (np.ndarray) – A 2D greyscale image.
detector (str) – The keypoint detector to use. Should be one of [‘SIFT’, ‘ORB’].
- Returns
List of keypoints as cv2.KeyPoint (list): Descriptor corresponding to the returned keypoints
- Return type
(list)
- ai_ct_scans.keypoint_alignment.match_descriptors(descriptors_1, descriptors_2)
Match descriptors that have come from two separate images.
- Parameters
descriptors_1 (np.ndarray) – Descriptors that correspond to keypoints extracted from the first image.
descriptors_2 (np.ndarray) – Descriptors that correspond to keypoints extracted from the first image.
- Returns
Matched descriptors.
- Return type
(list of cv2.DMatch)
- ai_ct_scans.keypoint_alignment.sieve_matches_lowe(matches)
Apply Lowe’s ratio test to retain only good matches.
- Parameters
matches – (list of cv2.DMatch): Matched descriptors.
- Returns
Matched descriptors that passed the test.
- Return type
(list of cv2.DMatch)