今天测试了一下这个matplotlib的如何通过数组来造出一张图片
example1
bash
import matplotlib.pyplot as plt
import numpy as np
arr = np.zeros((25741, 25205, 4))
arr[:,:]=[255,0,0,255]
plt.imshow(arr)
注意这个地方像素的取值,这个使用整数其实是没什么问题的,但是看下面的结果
example2
bash
import matplotlib.pyplot as plt
import numpy as np
arr = np.zeros((25741, 25205, 4))
arr[:,:]=[200,220,250,255]
plt.imshow(arr)
example 3
bash
import matplotlib.pyplot as plt
import numpy as np
arr = np.zeros((25741, 25205, 4))
arr[:,:]=[200/255.0,220/255.0,250/255.0,255/255.0]
plt.imshow(arr)
example4
bash
import matplotlib.pyplot as plt
import numpy as np
arr = np.zeros((25741, 25205, 4))
arr[:,:]=[94/255.0,46/255.0,127/255.0,255/255.0]
plt.imshow(arr)
也就说说这个数组需要是小数形式的,这样的才能显示正常的颜色