Python学习记录(七):numpy学习

  • np.tofile
  • np.fromfile
  • np.random.random
  • np默认数据类型

常用的切片操作

  • 反转数组
# CHW --> HWC, torch.tensor --> np.ndarray, RGB --> BGR
image = image.permute(1, 2, 0).numpy()[:, :, ::-1]

功能:(C, H, W) --> (H, W, C) 和 RGB2BGR

  • 下采样,即间隔取值
image = image[::4, ::4, :]
posted @ 2024-05-04 11:47  梦一场6688  阅读(19)  评论(0)    收藏  举报