-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathareaEstimation.py
More file actions
43 lines (37 loc) · 949 Bytes
/
areaEstimation.py
File metadata and controls
43 lines (37 loc) · 949 Bytes
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
########################################
## Area Calculation by estimation in Py
########################################
import numpy as np
import scipy.misc
from PIL import image
import random
'''
#Image ht and width
width=5
height=4
#Image array
array=np.zeroes([height,width,3],dtype=np.uint8)
img=Image.fromarray(array)
img.save('test.png')
'''
scipy.misc.imread("map-01.png")
count_Punjab=0
count_India=0
count=0
areaIndia=3287263
while(count<=100000):
#See dimension of map-01.png
#X is taken as depth and Y is taken as length (Python is reverse)
x=random.randint(0,2735)
y=random.randint(0,2480)
#map-01 is 2D
z=0
if(img[x][y][z]==60):#India
count_India=count_India+1
count=count+1
else:
if(img[x][y][z]==80):#Punjab
count_Punjab=count_Punjab+1
count=count+1
areaPunjab=(count_Punjab/count_India)*areaIndia
print("Estimated area of Punjab is :",areaPunjab," sq km")