function [tform, inlier_points1, inlier_points2, status] = estimateGeometricTransform(matched_points1, matched_points2,transform_type, varargin)
估计匹配点的几何变换
tform = estimateGeometricTransform(matchedPoints1,matchedPoints2, transformType)
返回二维矩阵,即变换矩阵。matchedPoints1 和matchedPoints2 可以是 cornerPoints objects,SURFPoints objects, MSERRegions objects, BRISKPoints objects, or M-by-2
matrices of [x,y] coordinates.
transformType参数可以是:‘similarity’或‘affine’或‘projective’。
matchedPoints1和matchedPoints1之间的异常点使用M-estimator SAmple Consensus(MSAC)算法进行排除。MSAC是Random Sample Consensus(RANSAC)的变形。如果transformType设置成‘similarity’或‘affine’返回值tform是一个affine2d类型,否则是projective2d。
[tform,inlierPoints1,inlierPoints2] = estimateGeometricTransform(...)也返回了相匹配的特征点。
[tform,inlierPoints1,inlierPoints2,status] = estimateGeometricTransform(...)还返回了以下可能状态值。
0:没有错误
1:matchedPoints1和matchedPoints2中没有足够的点
2:没有发现足够的匹配点
当STATUS没有输出时,函数将会给出错误。如上
[...] = estimateGeometricTransform(matchedPoints1,matchedPoints2, transformType,Name,Value)
附加name-value参数对,描述如下:
‘MaxNumTrails’ 正整数:随机特征,值变大鞥能够提高输出的鲁棒性
Default value: 1000
‘Confidence’ 0<C<100,寻找最大值的可信度(百分比)。值变大能够提高输出鲁棒性
Default value: 99
‘MaxDistance’ 正值,投影位置和相关位置之间的最大像素距离
Default value: 1.5
% Class Support
% -------------
% matchedPoints1 and matchedPoints2 must be cornerPoints objects,
% SURFPoints objects, MSERRegions objects, BRISKPoints objects, or M-by-2
% matrices of [x,y] coordinates.
%
% % EXAMPLE: Recover a transformed image using SURF feature points
% % --------------------------------------------------------------
% Iin = imread('cameraman.tif'); imshow(Iin); title('Base image');
% Iout = imresize(Iin, 0.7); Iout = imrotate(Iout, 31);
% figure; imshow(Iout); title('Transformed image');
%
% % Detect and extract features from both images
% ptsIn = detectSURFFeatures(Iin);
% ptsOut = detectSURFFeatures(Iout);
% [featuresIn, validPtsIn] = extractFeatures(Iin, ptsIn);
% [featuresOut, validPtsOut] = extractFeatures(Iout, ptsOut);
%
% % Match feature vectors
% index_pairs = matchFeatures(featuresIn, featuresOut);
% matchedPtsIn = validPtsIn(index_pairs(:,1));
% matchedPtsOut = validPtsOut(index_pairs(:,2));
% figure; showMatchedFeatures(Iin,Iout,matchedPtsIn,matchedPtsOut);
% title('Matched SURF points, including outliers');
%
% % Exclude the outliers and compute the transformation matrix
% [tform,inlierPtsOut,inlierPtsIn] = estimateGeometricTransform(...
% matchedPtsOut,matchedPtsIn,'similarity');
% figure; showMatchedFeatures(Iin,Iout,inlierPtsIn,inlierPtsOut);
% title('Matched inlier points');
%
% % Recover the original image Iin from Iout
% outputView = imref2d(size(Iin));
% Ir = imwarp(Iout, tform, 'OutputView', outputView);
% figure; imshow(Ir); title('Recovered image');