-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharea_measurement.py
More file actions
50 lines (46 loc) · 978 Bytes
/
area_measurement.py
File metadata and controls
50 lines (46 loc) · 978 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
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 16 23:37:22 2022
@author: Souvik Bhattacharya
"""
import scipy.misc
import imageio
from PIL import Image
import random
import numpy as np
img = Image.open('./static/westbengal.png')
rgb_img = img.convert('RGB')
count_in = 0
count_wb = 0
count = 0
while(count<=1000000):
x = random.randint(0,1049)
y = random.randint(0,1205)
z = 0
r,g,b = rgb_img.getpixel((x,y))
if(r == 136):
count_in += 1
count += 1
elif(r == 5):
count_wb += 1
count += 1
area_wb = (count_wb/count_in)*3287263
print(area_wb)
'''
img = imageio.imread("./static/westbengal.png")
count_in = 0
count_wb = 0
count = 0
while(count<=100000):
x = random.randint(0,1205)
y = random.randint(0,1049)
z = 0
if(img[x][y][z] == 80):
count_in += 1
count += 1
elif(img[x][y][z] == 60):
count_wb += 1
count += 1
area_wb = (count_wb/count_in)*3287263
print(area_wb)
'''