I have a function that is supposed to take a 1D array of integers and shapes it into a 2D array of 1x3 arrays. It then is supposed to take each 1x3 array and shift it into a 3x1 array. The result is supposed to be a 2D array of 3x1 arrays. Here is my function
def RGBtoLMS(rgbValues, rgbLength): #Method to convert from RGB to LMS
print rgbValues
lmsValues = rgbValues.reshape(-1, 3)
print lmsValues
for i in xrange(len(lmsValues)):
lmsValues[i] = lmsValues[i].reshape(3, 1)
return lmsValues
The issue rises when I try to change the 1x3 arrays to 3x1 arrays. I get the following output assuming rgbValues = [14, 25, 19, 24, 25, 28, 58, 87, 43]
[14 25 19 ..., 58 87 43]
[[14 25 19]
[24, 25, 28]
[58 87 43]]
ValueError [on line lmsValues[i] = lmsValues[i].reshape(3, 1)]: could not broadcast input array from shape (3,1) into shape (3)
How can I avoid this error?