基于ICP算法的图像配准的MATLAB实现Word文档格式.docx

上传人:b****6 文档编号:18854855 上传时间:2023-01-01 格式:DOCX 页数:37 大小:20.84KB
下载 相关 举报
基于ICP算法的图像配准的MATLAB实现Word文档格式.docx_第1页
第1页 / 共37页
基于ICP算法的图像配准的MATLAB实现Word文档格式.docx_第2页
第2页 / 共37页
基于ICP算法的图像配准的MATLAB实现Word文档格式.docx_第3页
第3页 / 共37页
基于ICP算法的图像配准的MATLAB实现Word文档格式.docx_第4页
第4页 / 共37页
基于ICP算法的图像配准的MATLAB实现Word文档格式.docx_第5页
第5页 / 共37页
点击查看更多>>
下载资源
资源描述

基于ICP算法的图像配准的MATLAB实现Word文档格式.docx

《基于ICP算法的图像配准的MATLAB实现Word文档格式.docx》由会员分享,可在线阅读,更多相关《基于ICP算法的图像配准的MATLAB实现Word文档格式.docx(37页珍藏版)》请在冰豆网上搜索。

基于ICP算法的图像配准的MATLAB实现Word文档格式.docx

%max_iter-maximumnumberofiterations.Default=104

%min_iter-minimumnumberofiterations.Default=4

%fitting-=2Fitwithrespecttominimizethesumofsquareerrors.(default)

%alt.=[2,w],wherewisaweightvectorcorrespondingtodata.

%wisavectorofsamelengthasdata.

%Fitwithrespecttominimizetheweightedsumofsquareerrors.

%=3Fitwithrespecttominimizethesumtotheamount0.95

%oftheclosestsquareerrors.

%alt.=[3,lambda],0.0<

lambda<

=1.0,(lambda=0.95default)

%Ineachiterationonlytheamountlambdaoftheclosest

%pointswillaffectthetranslationandrotation.

%If1<

=size(data,2),lambdainteger,onlythenumberlambda

%oftheclosestpointswillaffectthetranslationand

%rotationineachiteration.

%thres-errordifferensthresholdforstopiterations.Default1e-5

%init_flag-=0noinitialstartingtransformation

%=1transformdatasothemeanvalueof

%dataisequaltomeanvalueofmodel.

%Norotation.(init_flag=1default)

%tes_flag-=0Nonewtesselationhastobedone.There

%alredyexistsoneforthecurrentmodelpoints.

%=1Anewtesselationofthemodelpointswill

%bedone.(default)

%=2Anewtesselationofthemodelpointswill

%bedone.Anothersearchstrategythantes_flag=1

%=3Theclosestpointwillbefindbytesting

%allcombinations.NoDelaunaytesselationwillbedone.

%refpnt-(optional)(Anemptyvectorisdefault.)refpntisapointcorrespondingtothe

%setofmodelpointswichcorrespondigdatapointhastobefind.

%Howthepointsareweighteddependsontheoutputfromthe

%functionweightfcnfoundintheendofthism-file.Theinputinweightfcnisthe

%distancebetweentheclosestmodelpointandrefpnt.

%Toclearoldglobaltesselationvariablesrun:

"

clearglobalTesirjc"

(tes_flag=1)

%orrun:

clearglobalTesTesindTesver"

(tes_flag=2)inCommandWindow.

%m-filecanbedownloadedforfreeat

%

%icpversion1.4

%writtenbyPerBergströ

m2007-03-07

ifnargin<

1

error('

Tofewinputarguments!

'

);

elseifor(nargin==1,nargin==2)

bol=1;

refpnt=[];

ifnargin==2

ifisempty(data)

tes_flag=1;

elseifisscalar(data)

tes_flag=data;

ifnot(tes_flag==1|tes_flag==2)

end

else

bol=0;

ifbol

globalMODEL

ifisempty(model)

Modelcannotbeanemptymatrix.'

if(size(model,2)<

size(model,1))

MODEL=model'

;

TR=eye(size(model,2));

TT=zeros(size(model,2),1);

MODEL=model;

TR=eye(size(model,1));

TT=zeros(size(model,1),1);

if(size(MODEL,2)==size(MODEL,1))

ThisicpmethoddemandsthenumberofMODELpointstobegreaterthenthedimension.'

icp_struct(tes_flag);

return

end

globalMODELDATATRTT

ifisempty(model)

if(size(model,2)<

else

if(size(data,2)<

size(data,1))

data=data'

DATA=data;

ifsize(DATA,1)~=size(MODEL,1)

DifferentdimensionsofDATAandMODEL!

9

ifnargin<

8

7

init_flag=1;

6

thres=1e-5;

%thresholdtoicpiterations

5

fitting=2;

%fittingmethod

4

min_iter=4;

%minnumberoficpiterations

3

max_iter=104;

%maxnumberoficpiterations

elseifnargin>

warning('

Toomanyinputarguments!

ifisempty(tes_flag)

elseifnot(tes_flag==0|tes_flag==1|tes_flag==2|tes_flag==3)

init_flaghasbeenchangedto1'

ifand((size(MODEL,2)==size(MODEL,1)),tes_flag~=0)

Thisicpmethoddemandsthenumberofmodelpointstobegreaterthenthedimension.'

ifisempty(min_iter)

ifisempty(max_iter)

max_iter=100+min_iter;

ifmax_iter<

min_iter;

max_iter=min_iter;

max_iter<

min_iter,max_iterhasbeenchangedtobeequalmin_iter'

ifmin_iter<

0;

min_iter=0;

min_iter<

0,min_iterhasbeenchangedtobeequal0'

ifisempty(thres)

elseifthres<

thres=abs(thres);

thresnegative,threshavebeenchangedto-thres'

ifisempty(fitting)

elseiffitting

(1)==2

[fi1,fi2]=size(fitting);

lef=max([fi1,fi2]);

iflef>

iffi1<

fi2

fitting=fitting'

iflef<

(size(data,2)+1)

Illegealsizeoffitting!

Unweightedminimizationwillbeused.'

elseifmin(fitting(2:

(size(data,2)+1)))<

Illegealvalueoftheweights!

elseifmax(fitting(2:

(size(data,2)+1)))==0

Illegealvaluesoftheweights!

su=sum(fitting(2:

(size(data,2)+1)));

fitting(2:

(size(data,2)+1))=fitting(2:

(size(data,2)+1))/su;

thres=thres/su;

elseiffitting

(1)==3

iflength(fitting)<

2

fitting=[fitting,round(0.95*size(data,2))];

elseiffitting

(2)>

iffitting

(2)>

floor(fitting

(2))

fitting

(2)=floor(fitting

(2));

warning(['

lambdahasbeenchangedto'

num2str(fitting

(2)),'

!

]);

size(data,2)

fitting

(2)=size(data,2);

iffitting

(2)<

=0.5

lambdasmall.Troublesmightoccur!

fitting

(2)=round(fitting

(2)*size(data,2));

elseiffitting

(2)<

=0

fitting

(2)=round(0.95*size(data,2));

fittinghasbeenchangedto2'

ifisempty(init_flag)

elseifnot(init_flag==0|init_flag==1)

if(size(refpnt,2)>

size(refpnt,1))

refpnt=refpnt'

if(size(refpnt,1)~=size(DATA,1))

ifnot(isempty(refpnt))

Dimensionofrefpntdismatch.refpntisputto[](emptymatrix).'

1)

refpnt=refpnt(:

1);

Onlythefirstpointinrefpntisused.'

%StarttheICPalgorithm

N=size(DATA,2);

icp_init(init_flag,fitting);

%initiateastartingrotationmatrixandstartingtranslationvector

tes_flag=icp_struct(tes_flag);

%constructaDelaunaytesselationandtwovectorsmakeiteasytofindinTes

ERROR=icp_closest_start(tes_flag,fitting);

%initiateavectorwithindicesofclosestMODELpoints

icp_transformation(fitting,[]);

%findtransformation

DATA=TR*data;

%applytransformation

DATA=DATA+repmat(TT,1,N);

%

foriter=1:

max_iter

olderror=ERROR;

ERROR=icp_closest(tes_flag,fitting);

%findindicesofclosestMODELpointsandtotalerror

ifiter<

min_iter

icp_transformation(fitting,[]);

icp_transformation(fitting,refpnt);

DATA=TR*data;

DATA=DATA+repmat(TT,1,N);

ifiter>

=min_iter

ifabs(olderror-ERROR)<

thres

break

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

functionicp_init(init_flag,fitting)

%functionicp_init(init_flag)

%ICP_INITInitialalignmentforICP.

ifinit_flag==0

TR=eye(size(MODEL,1));

TT=zeros(size(MODEL,1),1);

elseifinit_flag==1

N=size(DATA,2);

iffitting

(1)==2

iflength(fitting)==1

mem=mean(MODEL,2);

med=mean(DATA,2);

mem=MODEL*fitting(2:

(N+1));

med=DATA*fitting(2:

TT=mem-med;

Wronginit_flag'

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

functiontes_flag=icp_struct(tes_flag)

iftes_flag==0

globalir

ifisempty(ir)

globalTesind

ifisempty(Tesind)

Notesselationsystemexists'

tes_flag=2;

elseiftes_flag==3

globalMODELTes

[m,n]=size(MODEL);

ifm==1

[so1,ind1]=sort(MODEL);

Tes=zeros(n,2);

Tes(1:

(n-1),1)=ind1(2:

n)'

Tes(2:

n,2)=ind1(1:

(n-1))'

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 建筑土木

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1