您确定RGB值介于0和1之间吗?使用你的代码,我做了这个例子:
import matplotlib.pyplot as plt
import numpy as np
n_points = 100
a = np.linspace(0, 1, n_points)
b,c = np.meshgrid(a,a)
image = (b+c)/2
a_third = n_points/3.
I = np.dstack([image, image, image])#
I[a_third:2*a_third, a_third:2*a_third, :] = [1 , 0 , 0]
plt.figure()
plt.imshow(I, interpolation='nearest')
![Resulting picture with the centre in red](https://i.stack.imgur.com/kTwJ6.png)
但是,如果我改变上面的例子中使用0到255之间的值(你似乎那些点设置为[200, 0, 0]
时做):
import matplotlib.pyplot as plt
import numpy as np
n_points = 100
a = np.linspace(0, 255, n_points)
b,c = np.meshgrid(a,a)
image = (b+c)/2
a_third = n_points/3.
I = np.dstack([image, image, image])#
I[a_third:2*a_third, a_third:2*a_third, :] = [255 , 0 , 0]
plt.figure()
plt.imshow(I, interpolation='nearest')
![enter image description here](https://i.stack.imgur.com/VUNKy.png)
给出的值大于1时,只会考虑其剩余W¯¯当我认为母鸡除以1(你可以在最后一个例子中通过更改image = ((b+c)/2)%1
行来检查,并验证你获得了相同的图像)。
红色区域'NaN'的值是? – berna1111
这只是一个例子,它不是代码中我的形象。否红色区域内的值不是NaN的 –
您想要着色的方法或基础是什么?对于渐变映射,您需要处理最小值和最大值,在某些情况下还需要处理值分布(以便您可以选择线性映射或非线性映射)。 – Spektre