1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| function [H] =calculSIFTBloc(ptsHarris,IgPad,IorPad,k,Mg,kIndice)
%Créer l'histogramme d'orientation pour un point et un bloc donné
% @param ptsHarris : la liste des points
% @param IgPad : le module du gradiant paddé
% @param IorPad : l'image discrétisé en 8 Bins paddé
% @param k : le numéro de bloc
% @param Mg : the Gaussian SIFT mask
% @param kIndice : matrice d'indexation de bloc
% Coordonées du points de Harris
x=ptsHarris(1,1);
y=ptsHarris(1,2);
% Size of padding
t=8;
%% Trouve le voisinage de 16x16 au point indiqué
for i=8:(size(IorPad,1)-8)
for j=8:(size(IorPad,2)-8)
if (i-8==x && j-8==y)
blocIorPad(:,:)=IorPad((i-t):(i+t -1),(j-t):(j+t -1));
blocIgPad(:,:) =IgPad ((i-t):(i+t -1),(j-t):(j+t -1));
%%% Mode DEBUG %%%
save('blocIorPad.txt','blocIorPad', '-ascii');
save('blocIgPad.txt','blocIgPad', '-ascii');
end
end
end
%%% Mode DEBUG %%%
load('blocIorPad.txt');
load('blocIgPad.txt');
%% Invariance a la rotation
% Calcul l'histogramme discrétisé en 8 bin
HRot=zeros(1,8);
MatH=blocIgPad.*Mg;
for i=1:16
for j=1:16
valH1=blocIorPad(i,j);
if (valH1 ~= 0)
HRot(valH1)=HRot(valH1)+MatH(i,j);
end
end
end
% Trouve le maximum du descripteur de Ig
maxHRot=max(max(HRot));
for i=1:8
if (HRot(i)==maxHRot)
thetaiIor=i;
end
end
%[val,pos] = max(C(:));
%% Calcul le descripteur SIFT en fonction du sous bloc défini
% Trouve les indices du sous-bloc
valInd=kIndice(:,:,k);
valx=valInd(1,1);
valy=valInd(1,2);
% Trouve les sous-blocs
ssBlocIorPad(:,:)=blocIorPad(valx:valx+3,valy:valy+3);
ssBlocMatCste(:,:)=MatH(valx:valx+3,valy:valy+3);
% Calcul le descripteur SIFT NON Invariant à la rotation
HNonrect=zeros(1,8);
for i=1:4
for j=1:4
val1=ssBlocIorPad(i,j);
if (val1 > 0)
HNonrect(val1)=HNonrect(val1)+ssBlocMatCste(i,j);
end
end
end
%Recalage Géométrique
Hrect=[HNonrect HNonrect];
H=Hrect(thetaiIor:thetaiIor+7);
end |
Partager