美文网首页
numpy.transpose

numpy.transpose

作者: SnorlaxSE | 来源:发表于2019-10-07 18:54 被阅读0次
    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)
      

    相关文章

      网友评论

          本文标题:numpy.transpose

          本文链接:https://www.haomeiwen.com/subject/mnimpctx.html