英文:
How to fix the colours of the Spectrum with Numpy Python
问题
Here's the translated portion of your text:
到目前为止,我已经编写了一段代码,通过它我能够创建一个频谱。
这是代码:
def draw(self):
x = np.linspace(0, 1, self.resolution)
y = np.linspace(0, 1, self.resolution)
X, Y = np.meshgrid(x, y)
R = X
G = Y
B = np.ones_like(X) * 0.5
print(R,G,B)
self.output = np.stack([R, G, B], axis=-1)
return self.output.copy()
但是它生成的频谱颜色较浅:
但我想创建像这样的图像:
任何帮助将不胜感激,或者如果您可以推荐我学习如何解决这个问题的地方。
英文:
So far I have written a code that through which I was able to create a spectrum.
Here's the code:
def draw(self):
x = np.linspace(0, 1, self.resolution)
y = np.linspace(0, 1, self.resolution)
X, Y = np.meshgrid(x, y)
R = X
G = Y
B = np.ones_like(X) * 0.5
print(R,G,B)
self.output = np.stack([R, G, B], axis=-1)
return self.output.copy()
But it's giving me a spectrum with light colours:
Current spectrum
But I want to create an Image like this:
Any help would be appreciated or if you can recommend where I can learn about this fix it.
答案1
得分: 1
你在所有地方将蓝色通道增加0.5,而在目标图像中,蓝色从左到右逐渐减少。
def draw(self):
x = np.linspace(0, 1, self.resolution)
y = np.linspace(0, 1, self.resolution)
X, Y = np.meshgrid(x, y)
R = X
G = Y
B = X[:, ::-1]
print(R, G, B)
self.output = np.stack([R, G, B], axis=-1)
return self.output.copy()
英文:
You add 0.5 to the blue color channel everywhere, while in your target image the amount of blue fades from left to right.
def draw(self):
x = np.linspace(0, 1, self.resolution)
y = np.linspace(0, 1, self.resolution)
X, Y = np.meshgrid(x, y)
R = X
G = Y
B = X[:, ::-1]
print(R,G,B)
self.output = np.stack([R, G, B], axis=-1)
return self.output.copy()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论