1. Gray Image (for the pixel intensity from 0 to 255)
import numpy as np
import matplotlib.pyplot as plt
w = 1h = 1
imgArray = np.zeros([h, w, 3],dtype = np.uint8)
for i in range(1,256):
plt.subplot(16,16,i)
plt.axis('off')
imgArray[:, :] = [i - 1]
print(str(i) + ' >>> ' + str(imgArray))
plt.imshow(imgArray)
plt.show()
Output
1 >>> [[[0 0 0]]]
2 >>> [[[1 1 1]]]
3 >>> [[[2 2 2]]]
4 >>> [[[3 3 3]]]
5 >>> [[[4 4 4]]]
6 >>> [[[5 5 5]]]
7 >>> [[[6 6 6]]]
8 >>> [[[7 7 7]]]
9 >>> [[[8 8 8]]]
10 >>> [[[9 9 9]]]
11 >>> [[[10 10 10]]]
12 >>> [[[11 11 11]]]
...
256 >>> [[[255 255 255]]]
2. RGB Image (for the pixel intensity from 0 to 255)
import numpy as np
import matplotlib.pyplot as plt
w = 1h = 1
imgArray = np.zeros([h, w, 3],dtype = np.uint8)
for i in range(1,256):
plt.subplot(16,16,i)
plt.axis('off')
imgArray[:, :] = [255, 128, i - 1]
print(str(i) + ' >>> ' + str(imgArray))
plt.imshow(imgArray)
plt.show()
Output
1 >>> [[[255 128 0]]]
2 >>> [[[255 128 1]]]
3 >>> [[[255 128 2]]]
4 >>> [[[255 128 3]]]
5 >>> [[[255 128 4]]]
6 >>> [[[255 128 5]]]
7 >>> [[[255 128 6]]]
8 >>> [[[255 128 7]]]
9 >>> [[[255 128 8]]]
10 >>> [[[255 128 9]]]
11 >>> [[[255 128 10]]]
12 >>> [[[255 128 11]]]
...
256 >>> [[[255 128 255]]]
No comments:
Post a Comment