i have an array (320x240) of temperature values and I want it to convert to rgb values that I specified for example:
blueRGBValue = (0,0,128)
temperatureArray =(24.532, 24.213, 24.1234, ...)
for i in range(len(temperatureArray)):
if (temperatureArray[i] > 25 and temperatureArray[i]<=30):
imageArray.append(blueRGBValue)
...
like this for all temperatureArray but i cannot assign rgb codes as tuples to imageArray. How can i do that? I imageArray should be initiate as numpy.zeros first to be ndarray
Thanks for advices.
CodePudding user response:
To store that rgb tuple into your np array you have to initialise your imageArray as follows:
imageArray = np.zeros((size), dtype=(float,3))
Note the dtype, you are storing 3 numbers of type float into your tuple.
Then you can add your rgb values with imageArray[0] = rgb