图像配准求变换矩阵

r=35;
points1=detectHarrisFeatures(Eouts(:,:,1));
points2=detectHarrisFeatures(Eouts(:,:,r));

[features1,valid_points1]=extractFeatures(Eouts(:,:,1),points1);
[features2,valid_points2]=extractFeatures(Eouts(:,:,r),points2);
indexPairs=matchFeatures(features1,features2);
matchedPoints1=valid_points1(indexPairs(:,1),:);
matchedPoints2=valid_points2(indexPairs(:,2),:);
figure,showMatchedFeatures(Eouts(:,:,1),Eouts(:,:,r),matchedPoints1,matchedPoints2);
a=matchedPoints1.Location;
b=matchedPoints2.Location;
a=double(a),b=double(b);
%a1=[a(1,:);a(13,:);a(24,:);a(33,:);a(38,:)];
%b1=[b(1,:);b(13,:);b(24,:);b(33,:);b(38,:)];
tform2=cp2tform(a,b,'affine');
Iout2=imtransform(Eouts(:,:,1),tform2);
u=[0,1];
v=[0,0];
[x,y]=tformfwd(tform2,u,v);
dx=x(2)-x(1);
dy=y(2)-y(1);
angle=180/pi*atan2(dy,dx)+180
scale=1/sqrt(dx^2+dy^2)
InRandomdegs8(r)

你可能感兴趣的:(数字图像处理笔记)