【事例介绍】通过sift检查实现图像拼接、python
【实例截图】
【核心代码】
function [hh,inliers ]=ransacfithomography (ref _ p,dst_P,npoints,threshold );
% 4-point RANSAC fitting
% Input:
% matcher _ a-matchpointsfromimagea,a matrix of 3xN,the third row is 1
% matcher _ B- matchpointsfromimageb,a matrix of 3xN,the third row is 1
% thd - distance threshold
% npoints - number of samples
%
%1. randomlyselectminimalsubsetofpoints
% 2. Hypothesize a model
%3.computer error函数
%4. selectpointsconsistentwithmodel
%5. repeat hypothesize-and-verify loop
%
ninlier=0;
fpoints=8; %number of fitting points
for i=1:2000
rd=randi([1npoints],1,fpoints );
pr=ref_p(:rd );
PD=dst_p(:rd );
h=gethomographymatrix(pr,pD,fpoints );
rref_P=h*ref_P;
ref _ p (1, )=rref _ p (1, ) ./rref _ p (3, );
ref _ p (2, )=rref _ p (2, ) ./rref _ p (3, );
n=NNZ(error
if(n=npoints*.95 ) ) )。
hh=h;
inliers=find(error
pause (;
布雷克;
ELSEif(nninlier ) )。
ninlier=n;
hh=h;
inliers=find(error
结束
结束