numpy.transpose
2019-10-07 本文已影响0人
SnorlaxSE
import numpy as np
from PIL import Image
img = Image.open('snorlax.jpeg')
img.show()
snorlax.jpeg
convert_img = Image.fromarray(convert)
convert_img.show()
# convert_img.save('snorlax_transpose.jpeg'')
snorlax_transpose.jpeg
即,将图像向左旋转90°
-
Origin
data = np.asarray(img, dtype='uint8') print(data.shape) # Outputs: (959, 959, 3)
-
convert
convert = data.transpose(1,0,2) # 交换第一维\第二维数据 print(convert.shape) # Outputs: (959, 959, 3)
-
convert_1
convert_1 = data.transpose(2,0,1) print(convert_1.shape) # Outputs: (3, 959, 959)