2017-04-02 4 views
0

Ich versuche, die normalized 8-point algorithm to estimate the fundamental matrix zu implementieren. Ein Schritt besteht darin, die Punkte so zu normalisieren, dass sie das Zentrum (0,0) und den mittleren Abstand von sqrt(2) haben. Ich weiß, wie man die Punkte übersetzt und skaliert, aber wie stelle ich die Schritte als eine Matrix dar, um sie in einem späteren Schritt zu verwenden?Wie wird die Übersetzung und Skalierung als Matrix dargestellt?

Meine aktuelle Funktion wandelt die Punkte als unten, aber ich muss auch um herauszufinden, was die Transformationsmatrix ist:

%% Normalize points to have center (0,0) and mean distance sqrt(2) 
function [pts1, T] = normalizePoints(pts) 
    Xs = pts(:,1); 
    Ys = pts(:,2); 

    %% Compute old center and translate 
    Xc = mean(Xs); 
    Yc = mean(Ys); 
    Xs = Xs - Xc; 
    Ys = Ys - Yc; 

    %% Compute mean distance and scale 
    Ds = sqrt(Xs .^ 2 + Ys .^ 2); 
    meanD = mean(Ds); 
    scale = sqrt(2)/meanD; 

    pts1 = [Xs .* scale, Ys .* scale]; 
    T = ... % How do I represent the previous operations as T? 
end 

Antwort

1

Verwendung Homogeneous coordinates:

T = [3;5]; 
% Normalize points to have center (0,0) and mean distance sqrt(2) 
pts = rand(10,2); 
Xs = pts(:,1); 
Ys = pts(:,2); 

% Compute old center and translate 
Xc = mean(Xs); 
Yc = mean(Ys); 
Xs = Xs - Xc; 
Ys = Ys - Yc; 

% Compute mean distance and scale 
Ds = sqrt(Xs .^ 2 + Ys .^ 2); 
meanD = mean(Ds); 
scale = sqrt(2)/meanD; 

% composing transformation matrix 
H = eye(3); 
H([1,5]) = H([1,5])*scale; 
H(1:2,3) = T(:); 
% making homogenous coordinates (add ones as z values) 
ptsHomo = [pts';ones(1,size(pts,1))]; 
% apply transform 
ptsRes = H*ptsHomo; 
ptsRes = bsxfun(@rdivide,ptsRes(1:2,:),ptsRes(3,:))'; 

subplot(121); 
plot(pts(:,1),pts(:,2),'o'); 
title('original points') 

subplot(122); 
plot(ptsRes(:,1),ptsRes(:,2),'o'); 
title('transformed points') 

enter image description here

Verwandte Themen