-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.py
72 lines (49 loc) · 1.55 KB
/
test.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# # # import numpy as np
# # # # a = np.zeros((5,5))
# # # # print a
# # # # print a[0:3, 1:3]
# # # component_transformation_matrix = np.array([[0.2999, 0.587, 0.114],
# # # [-0.16875, -0.33126, 0.5],[0.5, -0.41869, -0.08131]])
# # # a = np.array([[1], [2], [3]])
# # # print a.shape
# # # print component_transformation_matrix.shape
# # # print np.matmul(component_transformation_matrix, a)
# # # # print component_transformation_matrix
# # # print np.zeros((3,3))
# # import numpy as np
# # # import pywt
# # # data = np.ones((4,4), dtype=np.float64)
# # # coeffs = pywt.dwt2(data, 'haar')
# # # cA, (cH, cV, cD) = coeffs
# # # print cA
# # a = np.ones((4, 4, 3))
# # print np.zeros_like(a)
# # # img = decoder.decode(openjpeg.IMAGE_EIT)
# # import math
# # print math.floor(0.5)
# import numpy as np
# import math
# def quantization(img):
# step = 1.0/2
# (h, w, _) = img.shape
# quantization_img = np.empty_like(img)
# for i in range(0, w): # for every pixel:
# for j in range(0, h):
# if img[j][i] >= 0:
# sign = 1
# else:
# sign = -1
# quantization_img[j][i] = sign * math.floor(abs(img[j][i])/step)
# return quantization_img
# # a = np.zeros((4,4,1))
# # a = np.array([[4, 4, 4], [4, 4, 4], [4, 4, 4], [4, 4, 4]])
# b = np.random.randint(10, size=(4, 4, 1))
# print b[0]
# print quantization(b)[0]
from PIL import Image
import cv2
path = "data/image.jpg"
img = cv2.imread(path)
img = Image.fromarray(img, 'RGB')
# img.save('my.png')
img.show()