图像配准:从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 theFAST(Features from Accelerated Segment Test)keypoint detector and theBRIEF(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 ofKAZE. It presents a fast multiscale feature detection and description approach for non-linearscale 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)
view raw detect_keypoints.py hosted with ❤ by GitHub
圖像要點
有關功能檢測和描述的更多詳細信息,您可以查看此 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 thisdocumentationfor 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 calledimage warping. Any two images of the same planar surface in space are related by ahomography. 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 thehomography matrixand apply it to the sensed image.
To ensure optimal warping, we use theRANSACalgorithm to detect outliers and remove them before determining the final homography. It is directly built in OpenCV’sfindHomographymethod. There exist alternatives to the RANSAC algorithm such asLMEDS: 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 foundhere. 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 directlylearn the geometric transformation to align two images.
Supervised Learning In 2016, DeTone et al. publishedDeep Image Homography Estimationthat describesRegression HomographyNet, a VGG style model thatlearns the homography relating two images. This algorithm presents the advantage of learning the homography and the CNN model parameters simultaneously in anend-to-end fashion: no need for the previous two-stage process!
回歸同構網
網絡產生八個實值數字作為輸出。 以有 訓練 監督的方式 由于 對它進行了 歐幾里得損失 輸出和 之間的 , 實地單應性 。
監督下的深度單應估計
像任何監督方法一樣,這種單應性估計方法也 需要標記的數據對 。 盡管很容易獲得人造圖像對的地面真相單應性,但 卻高得多 對真實數據進行成本 。
Unsupervised Learning
With this in mind, Nguyen et al. presented anunsupervised approach to deep image homography estimation. They kept the same CNN but had to use anew loss function adapted to the unsupervised approach: they chose the photometric loss thatdoes not require a ground-truth label. Instead, it computes thesimilaritybetween 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中顯示出可喜的結果。
復雜的轉變
Asignificant proportion of current researchin image registration concerns the field ofmedical imagery. Often times, the transformation between two medical imagescannot simply be described by a homographymatrix because of thelocal deformationsof 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 useneural networks to estimate these large deformation modelsthat have many parameters.
第一個示例是上文提到的Krebs等人的“強化學習”方法。
在2017年De Vos等人。 提出了 DIRNet 。 它是一個使用CNN來預測控制點網格的網絡,該控制點網格用于 生成位移矢量場, 以根據參考圖像對感測到的圖像進行扭曲。
DIRNet的示意圖,其中包含來自MNIST數據的兩個輸入圖像
Quicksilver注冊可以 解決類似的問題。 水銀使用 深編碼器-解碼器網絡 來 預測補丁明智變形 直接使圖像的外觀。
_________________________________________________________________________________________________________________________________________________
每一個不曾起舞的日子,都是對生命的辜負。
But it is the same with man as with the tree. The more he seeks to rise into the height and light, the more vigorously do his roots struggle earthward, downward, into the dark, the deep - into evil.
其實人跟樹是一樣的,越是向往高處的陽光,它的根就越要伸向黑暗的地底。----尼采
總結
以上是生活随笔為你收集整理的图像配准:从SIFT到深度学习的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在新浪sae上部署WeRoBot
- 下一篇: openmv4人脸采集