-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculate_mean_potsdam.py
77 lines (67 loc) · 2.05 KB
/
calculate_mean_potsdam.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
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
import os
import numpy as np
from libtiff import TIFF
from cv2 import imread
BASE_DIRECTORY = '../ISPRS_semantic_labeling_Potsdam'
""" mean =[]
for filename in os.listdir(BASE_DIRECTORY+'/4_Ortho_RGBIR'):
if '.tif' in filename:
image = TIFF.open(BASE_DIRECTORY+'/4_Ortho_RGBIR/'+filename,'r')
image = image.read_image()
image = image[:,:,0]
mean.append(np.mean(image))
print('R:')
print(np.mean(np.array(mean)))
print()
mean =[]
for filename in os.listdir(BASE_DIRECTORY+'/4_Ortho_RGBIR'):
if '.tif' in filename:
image = TIFF.open(BASE_DIRECTORY+'/4_Ortho_RGBIR/'+filename,'r')
image = image.read_image()
image = image[:,:,1]
mean.append(np.mean(image))
print('G:')
print(np.mean(np.array(mean)))
print()
mean =[]
for filename in os.listdir(BASE_DIRECTORY+'/4_Ortho_RGBIR'):
if '.tif' in filename:
image = TIFF.open(BASE_DIRECTORY+'/4_Ortho_RGBIR/'+filename,'r')
image = image.read_image()
image = image[:,:,2]
mean.append(np.mean(image))
print('B:')
print(np.mean(np.array(mean)))
print()
mean =[]
for filename in os.listdir(BASE_DIRECTORY+'/4_Ortho_RGBIR'):
if '.tif' in filename:
image = TIFF.open(BASE_DIRECTORY+'/4_Ortho_RGBIR/'+filename,'r')
image = image.read_image()
image = image[:,:,3]
mean.append(np.mean(image))
print('IR:')
print(np.mean(np.array(mean)))
print() """
mean =[]
for filename in os.listdir(BASE_DIRECTORY+'/1_DSM'):
if '.tif' in filename:
image = TIFF.open(BASE_DIRECTORY+'/1_DSM/'+filename,'r').read_image()
mean.append(np.mean(image))
print('DSM:')
print(np.mean(np.array(mean)))
print()
mean =[]
for filename in os.listdir(BASE_DIRECTORY+'/1_DSM_normalisation'):
if 'lastools' in filename:
image = imread(BASE_DIRECTORY+'/1_DSM_normalisation/'+filename, -1)
mean.append(np.mean(image))
print('NDSM:')
print(np.mean(np.array(mean)))
print()
# R: 86.55175021564328
# G: 92.54522770394738
# B: 85.91596489181288
# IR: 97.639895122076
# DSM: 37.69138
# nDSM: 45.548982715963994