TP-vision/appliquerHomographie.m
2023-06-25 16:42:57 +02:00

31 lines
925 B
Matlab

% Calcul des coordonnees (xy2) des points (xy1)
% apres application d'une homographique H
function [xy2] = appliquerHomographie(H, xy1)
% Entrees :
%
% H : matrice (3x3) de l'homographie
% xy1 : matrice (nbPoints x 2) representant les coordonnees
% (colonne 1 : les x, colonne 2 : les y)
% des nbPoints points auxquels H est appliquee
%
% Sortie :
% xy2 : coordonnees des points apres application de l'homographie
% Nombre de points
N = size(xy1, 1);
% Construction des coordonnees homogenes pour appliquer l'homographie
xy1_tild = [xy1, ones(N, 1)];
% Application de l'homographie
xy1_homo = H * xy1_tild';
% On retourne les coordonnees homogenes (x,y,1)
% Pour cela, il faut diviser par z
% Attention il ne faut garder que les deux premieres coordonnees
xy1_homo = xy1_homo ./ xy1_homo(3, :);
xy2 = xy1_homo(1:2, :)';
end