-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEx5.py
69 lines (51 loc) · 1.47 KB
/
Ex5.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
#packages
exec(open('packages.py').read())
#Parameters
S = 2
NImages = 9
dx, dy = random_coor(NImages)
print(dx, dy)
NoiseStd = 2/255
K = gkern(2.5)
K = np.array(K)
#[[1, 2, 1], [2, 4, 2], [1, 2, 1]]/16
parameters = {}
parameters['S'] = S
parameters['NImages'] = NImages
parameters['dx'] = dx
parameters['dy'] = dy
parameters['NoiseStd'] = NoiseStd
parameters['K'] = K
# Importing an HR ground-truth image, and simulating the LR observations
#----------------------------------------------------------------
img = io.imread('Dataset/image.jpg', as_gray=True)
img = rescale(img, 0.25, anti_aliasing=False)
# Create a Set of LR images
set_img, img = set_img_lr(img, parameters)
H, W = img.shape
h, w = set_img[0].shape
Fusion_img = np.zeros((H, W))
for k in range(NImages):
LR_img = set_img[k]
for i in range(h):
for j in range(w):
px = i*S + dx[k]
py = j*S + dy[k]
Fusion_img[px][py] = LR_img[i][j]
# SR_img = richardson_lucy(Fusion_img, K, num_iter=50)
SR_img = deconv2DTV(Fusion_img, K)
_, ax = plt.subplots(nrows = 2, ncols=3)
ax[0][0].imshow(img, cmap = 'gray')
ax[0][0].axis('off')
ax[0][0].set_title('Original')
ax[0][1].imshow(SR_img, cmap = 'gray')
ax[0][1].axis('off')
ax[0][1].set_title("SR")
ax[0][2].imshow(Fusion_img, cmap = 'gray')
ax[0][2].axis('off')
ax[0][2].set_title("Fusion")
for k in range(3):
ax[1][k].imshow(set_img[k], cmap = 'gray')
ax[1][k].axis('off')
ax[1][k].set_title("LR " + str(k+1))
plt.show()