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
|
clear all
close all
clc
format long
DEM=imread('DEM.tif');
mask=imread('MASK.tif');%j'utilise en fait cette image pour définir plus précisement les contours de mon nouveau masque mask2
s=size(mask);
Landsat=imread('Landsat.tif');
INFO=geotiffinfo('Landsat.tif');
INFO_LAT=INFO.BoundingBox(:,1);
INFO_LON=INFO.BoundingBox(:,2);
%Détermination des frontières de ma fenêtres
MIN_Y=min(INFO_LAT);
MAX_Y=max(INFO_LAT);
MIN_X=min(INFO_LON);
MAX_X=max(INFO_LON);
x=[1:s(1)]';
y=[1:s(2)]';
X=[MIN_X:15:MAX_X]';
Y=[MIN_Y:15:MAX_Y]';
X_N=X(x);
Y_N=Y(y);
%création d'une grille pour pouvoir récupérer les coordonnées de chaques points
[GRI_X GRI_Y]=meshgrid(X_N,Y_N);
GRI_X=GRI_X';
GRI_Y=GRI_Y';
figure
imagesc(mask,'XData',[MIN_X MAX_X],'YData',[MIN_Y MAX_Y])
axis([MIN_X MAX_X MIN_Y MAX_Y])
%ici je détermine mon nouveau masque
h=impoly(gca);
pos=getPosition(h);
mask2=createMask(h);
figure
v=imagesc(DEM,'XData',[MIN_X MAX_X],'YData',[MIN_Y MAX_Y])
set(v,'alphadata',mask2>0)
axis([MIN_X MAX_X MIN_Y MAX_Y])
f=find(mask2==1);
g=find(mask2==0);
DEM(g)=0;%je met toutes les valeurs en dehors de mon nouveau masque à 0
MAX_ALT=max(DEM(:));%je calcul le maximum de mon nouveau masque
coord_max=find(DEM==MAX_ALT);%j'extrait les indices de ce maximum
%ici j'en extrait les coordonnées
x_point=GRI_X(coord_max);
y_point=GRI_Y(coord_max);
hold on
plot(x_point,y_point,'o') |
Partager