如何使用Numpy Python修复Spectrum的颜色

huangapple go评论72阅读模式
英文:

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:

Required spectrum

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()

如何使用Numpy Python修复Spectrum的颜色

英文:

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()

如何使用Numpy Python修复Spectrum的颜色

huangapple
  • 本文由 发表于 2023年5月8日 00:05:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76194967.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定