資源簡介
ransac算法隨機一致性采樣方法被廣泛應(yīng)用于影像匹配中剔除匹配點對中的誤配點對,效果明顯,這段代碼系網(wǎng)友所寫,詳細(xì)介紹了該方法的基本原理

代碼片段和文件信息
/*************************************************************************
Copyright?(c)?2008?The?University?of?Western?Ontario.??All?rights?reserved.
Contributors:
????*?Islam?Ali?(Computer?Science?Department)
Redistribution?and?use?in?source?and?binary?forms?with?or?without
modification?are?permitted?provided?that?the?following?conditions?are
met:
-?Redistributions?of?source?code?must?retain?the?above?copyright
??notice?this?list?of?conditions?and?the?following?disclaimer.
-?Redistributions?in?binary?form?must?reproduce?the?above?copyright
??notice?this?list?of?conditions?and?the?following?disclaimer?listed
??in?this?license?in?the?documentation?and/or?other?materials
??provided?with?the?distribution.
-?Neither?the?name?of?the?copyright?holders?nor?the?names?of?its
??contributors?may?be?used?to?endorse?or?promote?products?derived?from
??this?software?without?specific?prior?written?permission.
*************************************************************************/
#include?
#include?
#include?“Ransac.h“
#include?
using?namespace?std;
int?main()
{
double**?x1?=?new?double*[3];
double**?x2?=?new?double*[3];
double**?x1_inliers?=?new?double*[3];
double**?x2_inliers?=?new?double*[3];
double**?x1_outliers?=?new?double*[3];
double**?x2_outliers?=?new?double*[3];
double**?new_x1?=?new?double*[3];
double**?new_x2?=?new?double*[3];
double**?T1?=?new?double*[3];
double**?T2?=?new?double*[3];
double**?H?=?new?double*[3];
double**?H_temp=?new?double*[3]; //Temporary?matrix?for?Homography?denormalization
fstream?in(“xy.txt“);
if(in.is_open())
{
//Read?the?Number?and?Location?of?the?Features?returned?by?SIFT
int?nof;
in>>nof;
for(int?i?=?0;?i?3;?i++)
{
x1[i]?=?new?double[nof];
x2[i]?=?new?double[nof];
}
for(int?i=0;?i in>>?x1[1][i];
for(int?i=0;?i in>>?x1[0][i];
for(int?i=0;?i x1[2][i]?=?1;
for(int?i=0;?i in>>?x2[1][i];
for(int?i=0;?i in>>?x2[0][i];
for(int?i=0;?i x2[2][i]?=?1;
for(int?i?=?0;?i?3;?i++)
{
x1_inliers[i]?=?new?double[nof];
x2_inliers[i]?=?new?double[nof];
x1_outliers[i]?=?new?double[nof];
x2_outliers[i]?=?new?double[nof];
}
double?t?=?0.0001; //Define?your?RANSAC?threshold
Ransac?R1(x1x2noft);
for(int?i?=?0;?i?3;?i++)
{
new_x1[i]?=?new?double[nof];
new_x2[i]?=?new?double[nof];
T1[i]?=?new?double[3];
T2[i]?=?new?double[3];
H[i]?=?new?double[3];
}
//Normalize?the?Data?Sets
R1.Normalize(new_x1?T1?new_x2?T2);
int*?inliers?=?new?int[nof];
int?noi; //?TO?return?number?of?inliers
int?noo; //?TO?return?number?of?outliers
//The?Main?Loop?of?the?RANSAC
R1.MainLoop(new_x1?new_x2?nof?4?t?H?inliers?noi?noo);
//Separate?the?inliers?and?outliers
int?j=0;
int?k=0;
for(int?i=0;?i {
if
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????.......?????18639??2008-04-16?08:43??RANSAC\ap.h
????.......?????98862??2008-05-06?10:18??RANSAC\ap.obj
????.......?????21627??2008-04-16?08:43??RANSAC\apvt.h
????.......??????7095??2008-04-16?08:43??RANSAC\bdsvd.h
????.......????101699??2008-05-06?10:18??RANSAC\bdsvd.obj
????.......?????13521??2008-04-16?08:43??RANSAC\bidiagonal.h
????.......?????97457??2008-05-06?10:18??RANSAC\bidiagonal.obj
????.......??????3491??2008-04-16?08:43??RANSAC\blas.h
????.......?????71164??2008-05-06?10:18??RANSAC\blas.obj
????.......??????5988??2008-04-16?08:43??RANSAC\lq.h
????.......?????60693??2008-05-06?10:18??RANSAC\lq.obj
?????文件???????5543??2008-05-08?13:44??RANSAC\main.cpp
????.......??????1488??2008-05-05?17:09??RANSAC\matinv.cpp
????.......??????6467??2008-04-16?08:43??RANSAC\qr.h
????.......?????72949??2008-05-06?10:18??RANSAC\qr.obj
?????文件??????16596??2008-05-08?13:44??RANSAC\Ransac.cpp
?????文件???????1977??2008-05-08?13:44??RANSAC\Ransac.h
?????文件????2173952??2008-05-08?13:13??RANSAC\RANSAC.ncb
????.......???????876??2008-05-05?11:54??RANSAC\RANSAC.sln
????..A..H.?????64512??2008-05-08?13:13??RANSAC\RANSAC.suo
????.......??????4518??2008-05-07?19:02??RANSAC\RANSAC.vcproj
?????文件???????1413??2008-05-08?13:13??RANSAC\RANSAC.vcproj.NINTH.Administrator.user
????.......??????6688??2008-04-16?08:43??RANSAC\reflections.h
????.......?????37450??2008-05-06?10:18??RANSAC\reflections.obj
????.......??????5190??2008-04-16?08:43??RANSAC\rotations.h
????.......?????58793??2008-05-06?10:18??RANSAC\rotations.obj
????.......??????1358??2008-05-06?10:17??RANSAC\stdafx.h
????.......?????89045??2008-05-06?10:18??RANSAC\stdafx.obj
????.......????155648??2008-05-06?10:18??RANSAC\SVD.dll
????.......??????5354??2008-04-16?08:43??RANSAC\svd.h
............此處省略7個文件信息
- 上一篇:ZLG240128F液晶驅(qū)動
- 下一篇:單片機C51自動循跡小車程序
評論
共有 條評論