Why SVD is required in estimation of homography matrix using RANSAC method? & what is the input for SVD?

6 次查看(过去 30 天)
Hello, I have tried a code given for imagestitching. But I am getting error in the following function: in P matrix calculation.
function [P,S,V,q,A] = estimateTransform(img1_points,img2_points)
%%Initialization
%format long
ncorr = length(img1_points);
%%Setting the P matrix 10x9
P = [img1_points(1:ncorr,:),ones(ncorr,1),zeros(ncorr,3),...
-1*img2_points(1:ncorr,1).*img1_points(1:ncorr,:),...
-1*img2_points(1:ncorr,1);...
zeros(ncorr,3),-1*img1_points(1:ncorr,:),-1*ones(ncorr,1),...
img2_points(1:ncorr,2).*img1_points(1:ncorr,:),...
img2_points(1:ncorr,2)];
%%Calculating r 8x1
%r = img2_points(:);
%%SVD Decomposition
[~,S,V] = svd(P);
%%Extracting Diagonal elements of S
sigmas = diag(S);
%%Detecting minimum diagonal element
if length(sigmas) >= 9 %trivial solution
minSigma = min(sigmas);
[~,minSigmaCol] = find(S==minSigma);
%%Calculating q
q = double(vpa(V(:,minSigmaCol)));
elseif length(sigmas)<9 %non-trivial solution
%%Calculating q
q = double(vpa(V(:,9)));
end
%%Calculating A
A = reshape(q,[3,3])';
end
The error is: in .* the dimension must agree. Somebody please help me.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by