-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (26 loc) · 895 Bytes
/
main.py
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
import numpy as np
from PIL import Image
from Compression import compression
from Gridding import gridding
from Instruction import create_instr
from Recovery import recovery
# import image
image = Image.open("images\\svt.png")
image = image.convert('L')
start_data = np.asarray(image)
del image
# global variables
WIN_SIZE = len(start_data)
SQUARES_SIZE = 5
# compression
instruction, deviations = create_instr(start_data, SQUARES_SIZE)
del start_data
# recovery
RECOVERY_SIZE = WIN_SIZE * 2
recovered = np.asarray(Image.open("images\white.png").convert('L'))
for i in range(10):
big_grid = compression(
gridding(recovered, SQUARES_SIZE * 2 * RECOVERY_SIZE//WIN_SIZE), 2)
recovered = recovery(instruction, deviations,
big_grid, RECOVERY_SIZE, SQUARES_SIZE * RECOVERY_SIZE//WIN_SIZE)
Image.fromarray(recovered).convert('RGB').save("result.png")