Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/refactoring.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 20 additions & 23 deletions filter.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
from PIL import Image
import numpy as np
img = Image.open("img2.jpg")
from PIL import Image

input_file = input()
outpit_file = input()
img = Image.open(input_file)
arr = np.array(img)
a = len(arr)
a1 = len(arr[1])
height = len(arr)
width = len(arr[1])
mosaic_size = 10;
grayscale = 50;

i = 0
while i < a - 11:
while i < height:
j = 0
while j < a1 - 11:
s = 0
for n in range(i, i + 10):
for n1 in range(j, j + 10):
n1 = arr[n][n1][0]
n2 = arr[n][n1][1]
n3 = arr[n][n1][2]
M = n1 + n2 + n3
s += M
s = int(s // 100)
for n in range(i, i + 10):
for n1 in range(j, j + 10):
arr[n][n1][0] = int(s // 50) * 50
arr[n][n1][1] = int(s // 50) * 50
arr[n][n1][2] = int(s // 50) * 50
j = j + 10
i = i + 10
while j < width:
pixel = arr[i: i + mosaic_size, j: j + mosaic_size]
pixel_color = (pixel.sum() / 3) // (100 * grayscale) * grayscale
new_pixel = np.full(300, pixel_color).reshape(10, 10, 3)
arr[i: i + mosaic_size, j: j + mosaic_size] = new_pixel
j = j + mosaic_size
i = i + mosaic_size

res = Image.fromarray(arr)
res.save('res.jpg')
res.save(outpit_file)
Binary file modified res.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.