-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01_Q_01.py
More file actions
66 lines (55 loc) · 1.84 KB
/
01_Q_01.py
File metadata and controls
66 lines (55 loc) · 1.84 KB
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
import os
import csv
import math
import string
import osgeo.ogr
import numpy as np
import pandas as pd
from osgeo import gdal
import matplotlib.pyplot as plt
from osgeo import ogr , gdal , gdal_array as gdarr
#########
# Q1 1.1
#########
# As we are interested in only low and high confidence level, we loop over the values 2 and 3 only.
# For that we need to access the pix_values list which is in form of matrix
# with pix_values[i][j], with 'i' we reach the row and with 'j' we reach the column.
# after accesing the values, we apply condition values != 0 and 1.
# then we insert these new values in empty list sparse_matrix
########
# 1.2
########
pix_values = [[0, 1, 0, 3, 3, 2, 1, 2, 0, 0],
[0, 0, 0, 2, 0, 1, 0, 1, 3, 0],
[2, 3, 0, 0, 0, 3, 1, 0, 3, 0],
[0, 1, 0, 0, 0, 2, 3, 3, 0, 3],
[1, 0, 0, 1, 0, 3, 1, 1, 1, 2],
[0, 0, 2, 3, 0, 2, 3, 0, 0, 0],
[1, 3, 3, 0, 0, 1, 3, 0, 0, 1],
[2, 0, 1, 2, 0, 2, 0, 0, 0, 1],
[3, 2, 3, 0, 2, 0, 3, 2, 2, 0]]
rows = 9
column = 10
sparse_matrix = []
for i in range(rows):
for j in range(column):
if pix_values[i][j]>1:
sparse_matrix.append(pix_values[i][j])
print("Low and high values==",sparse_matrix)
###########
# 1.3
###########
rows = 9
column = 10
low_confidence = []
High_confidence = []
for i in range(rows):
for j in range(column):
if pix_values[i][j] == 2:
low_confidence.append(pix_values[i][j])
elif pix_values[i][j] == 3:
High_confidence.append(pix_values[i][j])
print("low_confidence==", low_confidence)
print("High_confidence==", High_confidence)
#######################################################################################################################
#