首页 > 编程知识 正文

opencv拼接图片,python算法详解

时间:2023-05-03 17:14:57 阅读:143592 作者:1430

【事例介绍】通过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

结束

结束

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。