Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

468
Visualizações
how to fill the values in numpy to create a Spectrum

I have done the following code but do not understand properly what is going on there. Can anyone explain how to fill colors in Numpy?

Also I want to set in values in a way from 1 to 0 to give spectrum an intensity. E.g-: 0 means low intensity, 1 means high intensity

import numpy as np
import matplotlib.pyplot as plt 

a= np.zeros([256*6,256*6, 3], dtype=np.uint8) # init the array
# fill the array with rgb values to create the spectrum without the use of loops

#red
a[:,:,0] = np.concatenate(([255]*256, np.linspace(255,0,256), [0]*256, [0]*256, np.linspace(0,255,256), [255]*256))

#green
a[:,:,1] = np.concatenate((np.linspace(0,255,256), [255]*256, [255]*256, np.linspace(255,0,256), [0]*256,[0]*256))

#blue
a[:,:,2] = np.concatenate(([0]*256, [0]*256,np.linspace(0,255,256),[255]*256, [255]*256, np.linspace(255,0,256)))


plt.imshow(a)  # this is different than what I am looking for

Expected Output-:

Expected Output

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0


res=256
op=np.zeros([res,res, 3]) # init the array

#RGB

op[:,:,0]= np.linspace(0,1,res)

op[:,:,1]=np.linspace(0,1,res).reshape (256, 1)

op[:,:,2]= np.linspace(1,0,res)

plt.imshow(op)


it will give the exact thing that you are looking for!

let me know if it does not work

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda