I’m using the following code in order to upscale an image.
JavaScript
x
38
38
1
import matplotlib.pyplot as plt
2
import numpy as np
3
from skimage.transform import rescale, resize
4
5
image = np.array(
6
[[[51, 153, 255],
7
[224, 224, 224],
8
[224, 224, 224],
9
[224, 224, 224]],
10
11
[[224, 224, 224],
12
[224, 224, 224],
13
[224, 224, 224],
14
[224, 224, 224]],
15
16
[[224, 224, 224],
17
[224, 224, 224],
18
[224, 224, 224],
19
[224, 224, 224]],
20
21
[[224, 224, 224],
22
[224, 224, 224],
23
[224, 224, 224],
24
[51, 255, 51]]]
25
)
26
27
# image2 = rescale(image, 40.0, anti_aliasing=True, multichannel=True).astype(np.int) # produces a black image
28
image2 = rescale(image, 40.0, anti_aliasing=True, multichannel=True) # produces a black image
29
# image2 = resize(image, (255, 255, 3)) # produces a black image
30
31
print(image2)
32
33
plt.imshow(image)
34
plt.show()
35
36
plt.imshow(image2)
37
plt.show()
38
However, this is not working as expected, as image2
becomes black. I really want to produce a new array, because I will be saving this array as an image to the file system. Specifically, I will create a gif animation from the upscaled version of these arrays. However, I want to create an upscaled version that is not blurry, but like the original, as you can see when you imshow(image)
above, i.e.
I guess I am using the API incorrectly and, meanwhile, maybe I will figure out the right way of doing what I want.