-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_diff.py
executable file
·44 lines (36 loc) · 1.24 KB
/
test_diff.py
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
# -*- coding: utf-8 -*-
"""
Script d'application des courbes sur une image
"""
import sys
from osgeo import gdal
import numpy as np
# doc du format ACV
# https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
def load_image(nom):
"""chargement d'une image avec son georef"""
fic = gdal.Open(nom)
return fic.ReadAsArray().astype("int32"), fic.GetGeoTransform()
def save_image(nom, image, _geo_trans):
"""sauvegarde d'une image avec son georef"""
cols = image.shape[2]
rows = image.shape[1]
bands = image.shape[0]
print(bands, cols, rows)
driver = gdal.GetDriverByName("GTiff")
out_raster = driver.Create(nom, cols, rows, bands, gdal.GDT_Byte)
band = out_raster.GetRasterBand(1)
band.WriteArray(image[0].astype("uint8"))
band = out_raster.GetRasterBand(2)
band.WriteArray(image[1].astype("uint8"))
band = out_raster.GetRasterBand(3)
band.WriteArray(image[2].astype("uint8"))
img_1, ref = load_image(sys.argv[1])
img_2, ref = load_image(sys.argv[2])
diff = np.absolute(img_1 - img_2)
e_max = np.max(diff)
if e_max > 0:
print('Attention, ecart max : ', e_max)
save_image('ecart.tif', diff, None)
sys.exit(1)
print('Pas de difference')