【问题标题】:Image alignment with ORB and RANSAC in scikit-image在 scikit-image 中使用 ORB 和 RANSAC 进行图像对齐
【发布时间】:2020-09-28 11:55:52
【问题描述】:

我正在尝试使用skimage.feature.orb 对齐延时图像以提取关键点,然后使用skimage.measure.ransac 过滤它们。然后,由 RANSAC 建模的变换应该能够对齐我的图像。

该过程似乎运行良好,我得到了大量的关键点匹配,然后由 RANSAC 很好地过滤。模型化的变换完美地纠正了旋转,但每次都发生了平移。

我是否只是误解了应该如何应用转换,或者 RANSAC 如何对其建模?

# Extract and match features from both images
descriptor_extractor = ORB(n_keypoints = 400, harris_k = 0.0005)
descriptor_extractor.detect_and_extract(image_ref)
descriptors_ref, keypoints_ref = descriptor_extractor.descriptors, descriptor_extractor.keypoints
descriptor_extractor.detect_and_extract(image)
descriptors, keypoints = descriptor_extractor.descriptors, descriptor_extractor.keypoints

# Match features in both images
matches = match_descriptors(descriptors_ref, descriptors, cross_check = True)

# Filter keypoints to remove non-matching
matches_ref, matches = keypoints_ref[matches[:, 0]], keypoints[matches[:, 1]]

# Robustly estimate transform model with RANSAC
transform_robust, inliers = ransac((matches_ref, matches), EuclideanTransform, min_samples = 5, residual_threshold = 0.5, max_trials = 1000)

# Apply transformation to image
image = warp(image, transform_robust.inverse, order = 1, mode = "constant", cval = 0, clip = True, preserve_range = True)

我得到与其他图像类似的结果。我也尝试过将 RANSAC 的内点与 skimage.transform.estimate_transform 一起使用,但它提供的结果与直接使用 transform_robust 相同。

【问题讨论】:

    标签: python image-processing scikit-image coordinate-transformation ransac


    【解决方案1】:

    事实证明,我需要在应用转换之前反转翻译:

    # Robustly estimate transform model with RANSAC
    transform_robust, inliers = ransac((matches_ref, matches), EuclideanTransform, min_samples = 5, residual_threshold = 0.5, max_trials = 1000)
    
    # Invert the translation
    transform_robust = transform(rotation = transform_robust.rotation) + transform(translation = -flip(transform_robust.translation))
    
    # Apply transformation to image
    image = warp(image, transform_robust.inverse, order = 1, mode = "constant", cval = 0, clip = True, preserve_range = True)
    

    结果并不完美,但调整我的关键点选择应该让它对齐

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-11
    • 2017-04-22
    • 2019-11-01
    • 2015-01-16
    • 1970-01-01
    • 1970-01-01
    • 2016-07-22
    相关资源
    最近更新 更多