forked from IritRTF/refactoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilter.py
More file actions
30 lines (28 loc) · 810 Bytes
/
filter.py
File metadata and controls
30 lines (28 loc) · 810 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
from PIL import Image
import numpy as np
np.setter(over='ignore')
img = Image.open("img2.jpg")
arr = np.array(img)
a, a1 = len(arr), len(arr[1])
i = 0
while i < a:
j = 0
while j < a1:
s = 0
for x in range(i, i + 10):
for y in range(j, j + 10):
n1 = arr[x][y][0] / 3
n2 = arr[x][y][1] / 3
n3 = arr[x][y][2] / 3
M = n1 + n2 + n3
s += M
s = int(s // 100)
for x in range(i, i + 10):
for y in range(j, j + 10):
arr[x][y][0] = int(s // 50) * 50
arr[x][y][1] = int(s // 50) * 50
arr[x][y][2] = int(s // 50) * 50
j = j + 10
i = i + 10
res = Image.fromarray(arr)
res.save('res.jpg')