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
| % Recuperation des donnees
a = load('bathy_02.txt');
% Reduction de la taille du probleme
N = 20;
x = a(1:N:end,1);
y = a(1:N:end,2);
z = a(1:N:end,3);
% Identification des 4 sommets du losange
[idx,idx] = min(x);
A = [x(idx) y(idx)];
[idx,idx] = min(y);
B = [x(idx) y(idx)];
[idx,idx] = max(x);
C = [x(idx) y(idx)];
[idx,idx] = max(y);
D = [x(idx) y(idx)];
TS = [A ; B ; C ; D];
% Centrage des coordonnees sur le sommet A
TS(:,1) = TS(:,1)-A(1);
TS(:,2) = TS(:,2)-A(2);
% Coordonnees des sommets du carre unitaire
US = [0 0 ; 1 0 ; 1 1 ; 0 1];
% Calcul de la matrice de transformation
K = US\TS;
% Application de la transformation aux points d'origine
xyz = [x(:)-A(1) y(:)-A(2) z(:)];
xyz(:,1:2) = xyz(:,1:2)/K;
% Interpolation des valeurs dans le domaine carré
X = linspace(min(xyz(:,1)),max(xyz(:,1)),100);
Y = linspace(min(xyz(:,2)),max(xyz(:,2)),100);
g = gridfit(xyz(:,1),xyz(:,2),xyz(:,3),X,Y);
% Application de la transformation inverse aux point d'interpolation
[XX,YY] = meshgrid(X,Y);
XYT = [XX(:) YY(:)]*K;
XYT(:,1) = XYT(:,1)+A(1);
XYT(:,2) = XYT(:,2)+A(2);
XX(:) = XYT(:,1);
YY(:) = XYT(:,2);
% Trace du résultat
figure
% plot3(x,y,z,'r+')
% hold on
colormap(hsv(256))
surf(XX,YY,g);
camlight right;
lighting phong;
shading interp
axis tight |
Partager