轉自html
最近也注意一些圖像拼接方面的文章,不少不少,尤爲是全景圖拼接的,實際上相似佳能相機附加的軟件,好多具有全景圖拼接,多幅圖像自動軟件實現拼接,構成(合成)一幅全景圖像(風景)。
Sift算法,我略知一二,沒法仔細描述(剛也貼了2個最近的資料)。
當就尺度空間(scale space),我想,其在計算機視覺(Computer Vision)\圖像的多分辨率分析(尤爲近年來小波的多分辨率分析)是常見的概念。
人類視覺捕捉景物的時候,先粗略(rough),後細節(fine)的習慣,被研究圖像視覺的採用。2點採樣使用的狀況,則總體圖像被不斷的1/2邊長劃 分,不一樣的圖像(矩陣)構成了不一樣分辨率的尺度空間(咱們理解爲不一樣層面的矩陣),尺度,Scale,這裏就表明不一樣的空間比例。
我注意到David Lowe關於Sfit算法,2004年發表在Int. Journal of Computer Vision的經典論文中,對尺度空間(scal space)是這樣定義的 :
It has been shown by Koenderink (1984) and Lindeberg (1994) that under a variety of
reasonable assumptions the only possible scale-space kernel is the Gaussian function. Therefore,
the scale space of an image is defined as a function, L(x; y; delta) that is produced from the convolution of a variable-scale Gaussian, G(x; y; delta), with an input image, I(x; y):
所以 ,一個圖像的尺度空間,L(x,y,delta) ,定義爲原始圖像I (x,y)與一個可變尺度的2維高斯函數G(x,y,delta) 卷積運算。
關於圖象處理中的空間域卷積運算,能夠參考經典的圖像處理教材(好比 美國 岡薩雷斯的圖象處理,第二版,或者其 Matlab版,都有如何在離散空間進行運算的例子和說明)
注:原文中 delta爲希臘字母,這裏沒法表示,用delta代替。
Sift算法中,提到了尺度空間,請問什麼是尺度和尺度空間呢?
在上述理解的基礎上,尺度 就是受delta這個參數控制的表示。
而不一樣的L(x,y,delta)就構成了尺度空間( Space ,我理解,因爲描述圖像的時候,通常用連續函數比較好描述公式,因此,採用空間集合 ,空間的概念正規一些),實際上,具體計算的時候,即便連續的高斯函數,都要被離散爲(通常爲奇數大小)(2*k+1) *(2*k+1)矩陣,來和數字圖像進行卷積運算。
算法
一、 SIFT 算法提出及其改進數據庫
SIFT算法由D.G.Lowe 1999年提出,2004年完善總結。表明性文獻編程
[1]David G. Lowe, "Object recognition from local scale-invariant features,"International Conference on Computer Vision, Corfu, Greece (September 1999), pp.1150-1157.數組
[2] David G. Lowe, "Distinctive image features from scale-invariant keypoints,"International Journal of Computer Vision, 60, 2 (2004), pp. 91-110.數據結構
具體的MATLAB代碼在app
http://www.cs.ubc.ca/~lowe/keypoints/能夠下載。ide
Rob Hess 基於GSL和Opencv編寫了C語言程序。具體的代碼能夠在函數
http://web.engr.oregonstate.edu/~hess/index.html 中下載,能夠在VC++.net環境中運行,在調試時要注意對GSL和Opencv的正確配置。
後來Y.Ke將其描述子部分用PCA代替直方圖的方式,對其進行改進。
[3] Y. Ke and R. Sukthankar. PCA-SIFT: A More Distinctive Representation for Local Image Descriptors.Computer Vision and Pattern Recognition, 2004
Yanke’s homepage:
http://www.andrew.cmu.edu/user/yke/
二、SIFT 算法主要思想
SIFT算法是一種提取局部特徵的算法,在尺度空間尋找極值點,提取位置,尺度,旋轉不變量。
三、 SIFT算法的主要特色:
a) SIFT特徵是圖像的局部特徵,其對旋轉、尺度縮放、亮度變化保持不變性,對視角變化、仿射變換、噪聲也保持必定程度的穩定性。
b) 獨特性(Distinctiveness)好,信息量豐富,適用於在海量特徵數據庫中進行快速、準確的匹配[23]。
c) 多量性,即便少數的幾個物體也能夠產生大量SIFT特徵向量。
d) 高速性,經優化的SIFT匹配算法甚至能夠達到實時的要求。
e) 可擴展性,能夠很方便的與其餘形式的特徵向量進行聯合。
四、SIFT算法步驟:
1)檢測尺度空間極值點
2)精肯定位極值點
3)爲每一個關鍵點指定方向參數
4)關鍵點描述子的生成
SIFT算法的介紹參見:SIFT 算法學習小記
前面有朋友問到Sift特徵點的提取方法,這裏簡單作個介紹。
做爲一種匹配能力較強的局部描述算子,SIFT算法的實現至關複雜,但從軟件開發的角度來講,只要會使用其中幾個比較重要的函數就好了。這裏要感謝 David Lowe這個大牛,不但提供了一種強悍的特徵匹配算法,還給出了C++的實現代碼,後來有人用C#實現了這個算法,須要的朋友可到網上自行下載。
關鍵函數一:
int sift_features( IplImage* img, struct feature** feat )
這個函數就是用來提取圖像中的特徵向量。參數img爲一個指向IplImage數據類型的指針,用來表示須要進行特徵提取的圖像。IplImage是 opencv庫定義的圖像基本類型(關於opencv是一個著名的圖像處理類庫,詳細的介紹能夠參見 http://www.opencv.org.cn)。參數feat 是一個數組指針,用來存儲圖像的特徵向量。函數調用成功將返回特徵向量的數目,不然返回-1.
關鍵函數二:
int _sift_features( IplImage* img, struct feature** feat, int intvls,double sigma, double contr_thr, int curv_thr, int img_dbl, int descr_width, int descr_hist_bins )
這個函數是函數一的重載,做用是同樣的,實際上函數一隻不過是使用默認參數調用了函數二,核心的代碼都是在函數二中實現的。下面將詳細介紹一下其餘的幾個參數。
intvls: 每一個尺度空間的採樣間隔數,默認值爲3.
sigma: 高斯平滑的數量,默認值1.6.
contr_thr:斷定特徵點是否穩定,取值(0,1),默認爲0.04,這個值越大,被剔除的特徵點就越多。
curv_thr:斷定特徵點是否邊緣點,默認爲6.
img_dbl:在創建尺度空間前若是圖像被放大了1倍則取值爲1,不然爲0.
descr_width:計算特徵描述符時鄰域子塊的寬度,默認爲4.
descr_hist_bins:計算特徵描述符時將特徵點鄰域進行投影的方向數,默認爲8,分別是 0,45,90,135,180,215,270,315共8個方向。
若是隻是作特徵提取,上面這個函數就足夠了,不一樣圖像之間的匹配都是創建在這個基礎上的,若是你有足夠強的編程能力即便不懂這個算法也可以編寫出像樣的程 序來,由於下面的比較說白了都是數據結構的比較,跟算法已經沒有太多關係了。若是想要深刻了解算法,仍是認真的看論文和代碼吧。
、ubc:DAVID LOWE---SIFT算法的創始人,兩篇巨經典經典的文章
二、cmu:YanKe---PCASIFT,總結的SIFT方面的文章SO全,巨經典
三、ubc:MBROWN---SIFT算法用於圖像拼接的經典應用autopano-sift,包括一個SIFTLIB庫
四、toronto:Jepson---Matlab SIFT tutorial, 超級超級超級經典~
五、ucla:Vedaldi---加州大學一個博士生編的SIFT,Matlab、C的都有,但沒用過
六、一個小的拼接軟件ptasmblr
幾個關於sift的算法連接網址,之後要養成這種隨時保存資料的好習慣!不然後面不知道又要花多少時間去找,最重要的是影響心情。
SIFT 關鍵點檢測和匹配算法,這個算法在圖像匹配方面具備很好的性能。
比原有的harris點匹配方式具備各高的佩準準確度,只是算法速度較慢
SIFT Keypoint Detector
This page provides access to a demo version of David Lowe's SIFT keypoint detector in the form of compiled binaries that can run under Linux or Windows. The demo software uses PGM format for image input. It can output keypoints and all information needed for matching them to a file in a simple ASCII format. A Matlab program and sample C code are provided that can read the keypoints and match them between images.
The image on the right shows an example of matching produced by the demo software. Features are extracted from each of the two images, and lines are drawn between features that have close matches. In this example, many matches are found and only a small fraction are incorrect.
This software is provided for research purposes only, and a license must be obtained from the University of British Columbia for commercial applications. See the LICENSE file provided with the software.
The program can be accessed from the following link in the form of a zip file containing the compiled binaries and demo code. To unpack, use "unzip siftDemoV4.zip" from Linux or an unzip utility in Windows. The code comes with a file README giving full details.
SIFT demo program (Version 4, July 2005)
Release historyVersion 4 (July 2005) There is now a Windows binary as well as one for Linux. The Matlab scripts have been improved and include code for matching keypoints between images. Version 3 (August 2004) This fixes a bug in the displayed orientation of arrows drawn for each keypoint when using the "-display" option. This affects only arrow display and not the keypoint features themselves (thanks to Yannik Fournier, Tom Stepleton, and Rob Sim for identifying the bug). In addition, a Matlab program is now provided for running the binary and loading the keypoints into Matlab when running under Linux (thanks to D. Alvaro and J.J. Guerrero for the Matlab program). Version 2 (September 2003) Fixes a bug in Version 1 of the sample code for doing matching (not the keypoints themselves) that incorrectly declared "unsigned char" as "char" (thanks to Yongqin Xiao and Suresh Lodha for their assistance in reporting this bug). This new version now finds more correct matches. The new version also contains more test data and raises the matching threshold. Version 1 (June 2003) Initial demo release. Related papers
The most complete and up-to-date reference for the SIFT feature detector is given in the following journal paper:
David G. Lowe, "Distinctive image features from scale-invariant keypoints," International Journal of Computer Vision, 60, 2 (2004), pp. 91-110. [PDF]
The SIFT approach to invariant keypoint detection was first described in the following ICCV 1999 conference paper, which also gives some more information on the applications to object recognition:
David G. Lowe, "Object recognition from local scale-invariant features," International Conference on Computer Vision, Corfu, Greece (September 1999), pp. 1150-1157. [PDF];
The following paper gives methods for performing 3D object recognition by interpolating between 2D views. It also provides a probabilistic model for verification of recognition.
David G. Lowe, "Local feature view clustering for 3D object recognition," IEEE Conference on Computer Vision and Pattern Recognition, Kau