% Calcul d'une mosaique d'image à partir de 2 images : I1 et I2 % connaissant l'homographie H entre les 2. % L'image resultat est stockee dans Res. % On choisit de projeter I2 dans I1 pour construire la mosaique. % Attention !!! % On suppose un axe de rotation parallèle aux colonnes. % C'est la raison pour laquelle on inverse les lignes et les colonnes % dans la reconstruction de la mosaique. function [Imos] = mosaiqueN(TailleFenetre, NbPoints, k, seuil, varargin) Imos = im2double(varargin{1}); for i = 2:nargin - 4 Im1 = Imos; Im2 = im2double(varargin{i}); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Detection des points d'interet avec Harris % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Im1_gray = rgb2gray(Im1); Im2_gray = rgb2gray(Im2); XY_1 = harris(Im1_gray, TailleFenetre, NbPoints, k); XY_2 = harris(Im2_gray, TailleFenetre, NbPoints, k); % affichage temporaire figure; affichage_POI(Im1,XY_1,'POI Image 1',1,2,1); affichage_POI(Im2,XY_2,'POI Image 2',1,2,2); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Appariement des points d'interet % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% [XY_C1, XY_C2] = apparier_POI(Im1_gray, XY_1, Im2_gray, XY_2, TailleFenetre, seuil); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Estimation (et verification) de l'homographie % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% s = 4; t = 0.999; fitFuncHomo = @(XY) homographie(XY(:, 1:2), XY(:, 3:4)); disFuncHomo = @(H, XY) distance_homographie(XY(:, 1:2), XY(:, 3:4), H); [H, idx] = ransac([XY_C1, XY_C2], fitFuncHomo, disFuncHomo, s, t); figure('Name', 'Appariement des points d''interet RANSAC'); affichage_appariement(Im1, XY_C1(idx, 1), XY_C1(idx, 2), 'Points d''interet Image 1', 1, 2, 1); affichage_appariement(Im2, XY_C2(idx, 1), XY_C2(idx, 2), 'Points d''interet correspondants Image 2', 1, 2, 2); % https://github.com/hero9968/Multiple-View-Geometry-in-Computer-Vision/blob/master/vgg_examples/ransacfithomography_vgg.m %%%%%%%%%%%%%%%%%%%%%%%%%%% % Collage des deux images % %%%%%%%%%%%%%%%%%%%%%%%%%%% Imos = mosaiquecoul(Im1, Im2, H); figure; affichage_image(Imos,'Mosaique obtenue a partir des 2 images initiales',1,1,1); end end