-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharraytest.py
68 lines (45 loc) · 1.34 KB
/
arraytest.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
import numpy as np
X = np.arange(27).reshape((3, 3, 3))
# print (X)
Y = X.reshape(int(27/ 3) , 3)
# print (Y)
select = np.array([0, 0, 0, 1, 1, 1, 2, 2, 2]) + np.arange(9)
select = select * 9
a = [4, 3, 5]
b = np.array(a)
import matplotlib.pyplot as plt
from skimage import data, color
from skimage.transform import rescale, resize, downscale_local_mean
image1 = color.rgb2gray(data.astronaut())
image1 = data.astronaut()
image = []
image1 = rescale(image1, 1.0 / 64.0)
image1 = np.array([[[1.0,0.0,0.0], [0.0,0.9,0.0]], [[0.0,0.0,0.8], [0.4,0.4,0.4]]])
image.append(image1)
image.append(image1*0.8)
image.append(image1*0.6)
image.append(image1*0.4)
image = np.array(image)
fig, axes = plt.subplots(nrows=3, ncols=2)
ax = axes.ravel()
# print (image_rescaled)
ax[0].imshow(image[0])
ax[1].imshow(image[1])
ax[2].imshow(image[2])
ax[3].imshow(image[3])
# plt.tight_layout()
# plt.show()
# arrySiz = np.prod(image[0].shape)
# select = np.ones((image[0].shape[0], image[0].shape[1]), dtype=int)
# s1 = np.trunc(np.arange(2).T/2)
# select = np.intp(np.multiply(select, s1))
# select = select * arrySiz;
select = np.array([[0,1], [2,3]])
# step = 3 * np.arange(arrySiz/3).reshape(image[0].shape[0], image[0].shape[1])
# select = select + step
select =np.intp(select)
result = image.choose(select)
# np.take
ax[4].imshow(result)
plt.tight_layout()
plt.show()