-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.py
More file actions
67 lines (51 loc) · 1.87 KB
/
main.py
File metadata and controls
67 lines (51 loc) · 1.87 KB
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
import cv2
import numpy as np
from matplotlib import pyplot as plt
from methods import Bilinear, HQL, HA
from methods import GBTF, DLMMSE
from methods import RI, IRI, MLRI
def metrics(raw_img, new_img):
result = []
for c in range(0, 3):
mse = np.mean(np.power((raw_img[5:-5, 5:-5, c] - new_img[5:-5, 5:-5, c]), 2))
if mse == 0:
result.append('perfect!!')
else:
result.append(10 * np.log10(255*255/mse))
return result
def make_bayer(img):
new_img = np.zeros_like(img)
new_img[0::2, 0::2, 0] = img[0::2, 0::2, 0]
new_img[0::2, 1::2, 1] = img[0::2, 1::2, 1]
new_img[1::2, 0::2, 1] = img[1::2, 0::2, 1]
new_img[1::2, 1::2, 2] = img[1::2, 1::2, 2]
return new_img
for picname in ['./kodim19.png']:
src_img = cv2.imread(picname)
src_img = cv2.cvtColor(src_img, cv2.COLOR_BGR2RGB)
bayer_img = make_bayer(src_img)
plt.imshow(bayer_img), plt.show()
bilinear_img = Bilinear.run(bayer_img)
plt.imshow(bilinear_img), plt.show()
print('Bilinear: ', metrics(src_img, bilinear_img))
hql_img = HQL.run(bayer_img)
plt.imshow(hql_img), plt.show()
print('HQL: ', metrics(src_img, hql_img))
ha_img = HA.run(bayer_img)
plt.imshow(ha_img), plt.show()
print('HA: ', metrics(src_img, ha_img))
dlmmse_img = DLMMSE.run(bayer_img)
plt.imshow(dlmmse_img), plt.show()
print('DLMMSE: ', metrics(src_img, dlmmse_img))
gbtf_img = GBTF.run(bayer_img)
plt.imshow(gbtf_img), plt.show()
print('GBTF: ', metrics(src_img, gbtf_img))
ri_img = RI.run(bayer_img)
plt.imshow(ri_img), plt.show()
print('RI: ', metrics(src_img, ri_img))
mlri_img = MLRI.run(bayer_img)
plt.imshow(mlri_img), plt.show()
print('MLRI: ', metrics(src_img, mlri_img))
iri_img = IRI.run(bayer_img)
plt.imshow(iri_img), plt.show()
print('IRI: ', metrics(src_img, iri_img))