python 图片维度转换

opencv读取出来的图片是(w,h,c),但是我想获取(c,w,h)的图片,可以使用矩阵变换函数print(img.shape)img = img.tran
  • opencv读取出来的图片是(w,h,c),但是我想获取(c,w,h)的图片,可以使用矩阵变换函数
    print(img.shape)
    img = img.transpose(2,0,1)
    print(img.shape)
    
    在这里插入图片描述