兵马逐浪去,将象入海流。炮声震心动,惊起卧龙游。
我的博客园主页 --------- 我的知乎主页 --------- 我的github主页 --------- 我的csdn主页 --------- 我的新浪微博

图像配准:从SIFT到深度学习

转载于:  https://www.sicara.ai/blog/2019-07-16-image-registration-deep-learning

 

图像配准 是 的基本步骤 计算机视觉 。 本文介绍 OpenCV 的基于 功能的方法 了 之前 深度学习


什么是图像注册?

图像配准是将 一个场景的不同图像转换为相同坐标系的过程 。 这些图像可以在不同的时间(多时间配准),通过不同的传感器(多模式配准)和/或从不同的视角拍摄。 这些图像之间的空间关系可以是 刚性的 (平移和旋转), 仿射的 剪切 例如 ), 单应性 或复杂的 大变形模型

资料来源: CorrMap

图像配准具有广泛的应用:当手头的任务需要比较同一场景的多个图像时,这是必不可少的。 它在医学图像领域以及卫星图像分析和光流领域非常普遍

注册后的CT扫描和MRI | 资料来源: kevin-keraudren.blogspot

在本文中,我们将重点介绍几种在参考图像和感测图像之间执行图像配准的方法。 我们选择不使用 迭代 / 强度 基于 的方法,因为它们不那么常用。


传统的基于特征的方法

自2000年代初以来,图像配准大多使用传统 的基于特征的方法 。 这些方法基于三个步骤: 关键点检测和特征描述,特征匹配和图像变形 。 简而言之,我们选择两个图像中的兴趣点,将参考图像中的每个兴趣点与感应图像中的等效点相关联,并对感应图像进行变换,以使两个图像对齐。

单应变换关联的图像对的基于特征的方法| 资料来源: 无监督的深层摄影术:快速而稳健的摄影术
估算模型

关键点检测和功能描述

一个 关键点 是兴趣点。 它定义了图像中重要且与众不同的部分(拐角,边缘等)。 每个关键点都由一个 表示 描述符 :一个包含关键点本质特征的特征向量。 描述符应对图像转换(定位,比例,亮度等)具有鲁棒性。 许多算法执行 关键点检测和功能描述

  • SIFT (尺度不变特征变换) 是用于关键点检测的原始算法,但并非免费用于商业用途。 SIFT特征描述符对于均匀缩放,方向,亮度变化是不变的,而对于仿射失真则是部分不变的。
  • SURF (加速鲁棒功能) 是一种受SIFT启发的检测器和描述符。 它具有更快几倍的优势。 它也获得了专利。
  • ORBFASTBRIEF (Oriented FAST and Rotated BRIEF) is a fast binary descriptor based on the combination of the FAST (Features from Accelerated Segment Test) keypoint detector and the BRIEF (Binary robust independent elementary features) descriptor. It is rotation invariant and robust to noise. It was developed in OpenCV Labs and it is an efficient and free alternative to SIFT.
  • AKAZE(Accelerated-KAZE) is a sped-up version of KAZE. It presents a fast multiscale feature detection and description approach for non-linear scale spaces. It is both scale and rotation invariant. It is also free!

These algorithms are all available and easily usable in OpenCV. In the example below, we used the OpenCV implementation of AKAZE. The code remains roughly the same for the other algorithms: only the name of the algorithm needs to be modified.

import numpy as np
import cv2 as cv

img = cv.imread('image.jpg')
gray= cv.cvtColor(img, cv.COLOR_BGR2GRAY)

akaze = cv.AKAZE_create()
kp, descriptor = akaze.detectAndCompute(gray, None)

img=cv.drawKeypoints(gray, kp, img)
cv.imwrite('keypoints.jpg', img)

 

 

 

图像要点

有关功能检测和描述的更多详细信息,您可以查看此 OpenCV教程

特征匹配

一旦在形成一对图像的两个图像中确定了关键点,我们就需要将两个图像中实际上与同一点相对应的关键点进行关联或“匹配”。 一种可能的方法是 BFMatcher.knnMatch()。 该匹配器测量每对关键点描述符之间的距离,并为每个关键点返回其 k个 最小距离的最佳匹配。

然后,我们应用比率过滤器以仅保留正确的匹配项。 实际上,为了获得可靠的匹配,匹配的关键点应该比最接近的不正确匹配要近得多。

 

import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt

img1 = cv.imread('image1.jpg', cv.IMREAD_GRAYSCALE)  # referenceImage
img2 = cv.imread('image2.jpg', cv.IMREAD_GRAYSCALE)  # sensedImage

# Initiate AKAZE detector
akaze = cv.AKAZE_create()
# Find the keypoints and descriptors with SIFT
kp1, des1 = akaze.detectAndCompute(img1, None)
kp2, des2 = akaze.detectAndCompute(img2, None)

# BFMatcher with default params
bf = cv.BFMatcher()
matches = bf.knnMatch(des1, des2, k=2)

# Apply ratio test
good_matches = []
for m,n in matches:
    if m.distance < 0.75*n.distance:
        good_matches.append([m])
        
# Draw matches
img3 = cv.drawMatchesKnn(img1,kp1,img2,kp2,good_matches,None,flags=cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS)
cv.imwrite('matches.jpg', img3)

 

 
 
 
matching.py 通过托管❤ GitHub上

Matched Keypoints

Check out this documentation for other feature matching methods implemented in OpenCV.

Image Warping

After matching at least four pairs of keypoints, we can transform one image relatively to the other one. This is called image warping. Any two images of the same planar surface in space are related by a homography. Homographies are geometric transformations that have 8 free parameters and are represented by a 3x3 matrix. They represent any distortion made to an image as a whole (as opposed to local deformations). Therefore, to obtain the transformed sensed image, we compute the homography matrix and apply it to the sensed image.

To ensure optimal warping, we use the RANSAC algorithm to detect outliers and remove them before determining the final homography. It is directly built in OpenCV’s findHomography method. There exist alternatives to the RANSAC algorithm such as LMEDS: Least-Median robust method.

# Select good matched keypoints
ref_matched_kpts = np.float32([kp1[m[0].queryIdx].pt for m in good_matches])
sensed_matched_kpts = np.float32([kp2[m[0].trainIdx].pt for m in good_matches])

# Compute homography
H, status = cv.findHomography(sensed_matched_kpts, ref_matched_kpts, cv.RANSAC,5.0)

# Warp image
warped_image = cv.warpPerspective(img2, H, (img2.shape[1], img2.shape[0]))
            
cv.imwrite('warped.jpg', warped_image)
 
 
warping.py hosted with ❤ by GitHub

变形后感测到的图像

如果您对这三个步骤的更多细节感兴趣,则OpenCV整理了 一系列有用的教程


深度学习方法

如今,有关图像配准的大多数研究都涉及 的使用 深度学习 。 在过去的几年中,深度学习已使 Computer Vision任务( 具有最先进的性能 例如图像分类,对象检测和分割) 。 没有理由为什么图像注册不会如此。

特征提取

深度学习用于图像配准的第一种方法是 特征提取 卷积神经网络 的连续层设法 捕获越来越复杂的图像特征 学习特定于任务的特征 。 自2014年以来,研究人员已将这些网络应用于特征提取步骤,而不是SIFT或类似算法。

  • 2014年,Dosovitskiy等人。 提出只使用未标记的数据来训练卷积神经网络。 的 这些功能 通用 具有 性使其对转换 鲁棒性 。 这些功能或描述符在匹配任务方面胜过SIFT描述符。
  • 在2018年,Yang等。 开发了一种 非刚性的注册方法 基于相同的想法 。 他们使用了经过 各层, 预训练的VGG网络的 以生成既保留卷积信息又保留本地化功能的特征描述符。 这些描述符似乎也胜过类似SIFT的检测器,特别是在SIFT包含许多异常值或无法匹配足够数量的特征点的情况下。

Results for SIFT and deep learning-based non-rigid registration method descriptors

The code for this last paper can be found here. While we were able to test this registration method on our own images within 15 minutes, the algorithm is approximatively 70 times slower than the SIFT-like methods implemented earlier in this article.

Homography Learning

Instead of limiting the use of deep learning to feature extraction, researchers tried to use a neural network to directly learn the geometric transformation to align two images.

Supervised Learning In 2016, DeTone et al. published Deep Image Homography Estimation that describes Regression HomographyNet, a VGG style model that learns the homography relating two images. This algorithm presents the advantage of learning the homography and the CNN model parameters simultaneously in an end-to-end fashion: no need for the previous two-stage process!

回归同构网

网络产生八个实值数字作为输出。 以有 训练 监督的方式 由于 对它进行了 欧几里得损失 输出和 之间的 , 实地单应性

监督下的深度单应估计

像任何监督方法一样,这种单应性估计方法也 需要标记的数据对 。 尽管很容易获得人造图像对的地面真相单应性,但 却高得多 对真实数据进行成本

Unsupervised Learning

With this in mind, Nguyen et al. presented an unsupervised approach to deep image homography estimation. They kept the same CNN but had to use a new loss function adapted to the unsupervised approach: they chose the photometric loss that does not require a ground-truth label. Instead, it computes the similarity between the reference image and the sensed transformed image.

L1 photometric loss function

Their approach introduces two new network structures: a Tensor Direct Linear Transform and a Spatial Transformation Layer. We will not go into the details of these components here, we can simply consider that these are used to obtain a transformed sensed image using the homography parameter outputs of the CNN model, that we then use to compute the photometric loss.

无监督深度单应估计

作者声称,与传统的基于特征的方法相比,这种无监督的方法在照明变化方面具有可比或更高的准确性和鲁棒性,并且推理速度更快。 此外, ,它具有 出色的适应性 与监督方法相比 和性能。

其他方法

强化学习

深度强化学习作为医学应用的注册方法正逐渐受到关注。 与预定义的优化算法相反,在这种方法中,我们使用 受过训练的代理执行注册

强化学习技术的注册管道的可视化

  • 2016年,廖等人。 率先使用强化学习进行图像配准。 他们的方法 基于 的 用于端到端训练 贪婪监督算法 。 它的目标是通过找到 来对齐图像 最佳的动作顺序 。 该方法优于几种最新方法,但 仅用于刚性转换
  • 强化学习也已用于更复杂的转换。 在 通过基于主体的行动学习进行的鲁棒的非刚性注册中 Krebs等人 。 应用 人工代理优化变形模型的参数 。 该方法在前列腺MRI图像的受试者间配准上进行了评估,并在2-D和3-D中显示出可喜的结果。

复杂的转变

A significant proportion of current research in image registration concerns the field of medical imagery. Often times, the transformation between two medical images cannot simply be described by a homography matrix because of the local deformations of the subject (due to breathing, anatomical changes, etc.). More complex transformations models are necessary, such as diffeomorphisms that can be represented by displacement vector fields.

Example of deformation grid and displacement vector field on cardiac MRI images

Researchers have tried to use neural networks to estimate these large deformation models that have many parameters.

  • 第一个示例是上文提到的Krebs等人的“强化学习”方法。
  • 在2017年De Vos等人。 提出了 DIRNet 。 它是一个使用CNN来预测控制点网格的网络,该控制点网格用于 生成位移矢量场, 以根据参考图像对感测到的图像进行扭曲。

DIRNet的示意图,其中包含来自MNIST数据的两个输入图像

    • Quicksilver注册可以 解决类似的问题。 水银使用 深编码器-解码器网络 预测补丁明智变形 直接使图像的外观。

 

 
posted @ 2021-04-02 18:03  leoking01  阅读(763)  评论(0编辑  收藏  举报
#back-to-top { background-color: #00CD00; bottom: 0; box-shadow: 0 0 6px #00CD00; color: #444444; padding: 10px 10px; position: fixed; right: 50px; cursor: pointer; }