1.I use cv2.imread
to read a big image in numpy array (1234*1624*3)
2.I use cv2.dnn.blobFromImage
to transform it to (1,3,1234,1624) numpy array
3.I use tolist()
to transform it to a 4D list in lists
My Problem:
How to transpose this list's axis
from (1,3,1234,1624) to (1,1234,1624,3)?
I tried np.transpose(image, (0, 2, 3, 1))
first then do the tolist()
, but it appears to be very slow. Therefore, I want to transpose in the list form.
I've checked the question below it seems fast but can only transpose 2D list Transpose list of lists
Much appreciated!!
Update:
I have a list named temp.
len(temp)=1
len(temp[0])=3
len(temp[0][0])=1234
len(temp[0][0][0])=1624
and I want to transpose its axis to
len(temp)=1
len(temp[0])=1234
len(temp[0][0])=1624
len(temp[0][0][0])=3
How to do with temp1=list(map(list, zip(*temp))
?