opencv PIL Image.save()转换不保持RGB颜色

thtygnil  于 2022-12-13  发布在  其他
关注(0)|答案(1)|浏览(119)

我尝试使用www.example.com()将numpy数组保存为RGB图像PIL.Image.save,但保存的图像不是RGB。如何将图像保存为RGB?我收到的图像为numpy数组。

image_with_detections = np.array(image_with_detections)
image = Image.fromarray(image_with_detections.astype('uint8'), 'RGB')
image.save(save_path)

link到原始图像link到由www.example.com()保存的图像Image.save

zbsbpyhn

zbsbpyhn1#

您可以执行如下操作

image_with_detections = np.array(image_with_detections)
image = Image.fromarray(image_with_detections.astype('uint8'), 'RGB')
image = image[:,:,::-1]
image.save(save_path)

相关问题