簡體   English   中英

PIL Image.save() 轉換不保持 RGB 顏色

[英]PIL Image.save() convert does'nt maintain RGB color

我正在嘗試使用 PIL.Image.save() 將 numpy 數組保存為 RGB 圖像,但保存的圖像不是 RGB。 如何將圖像保存為 RGB? 我收到的圖像是 numpy 陣列。

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

原始圖像的鏈接Image.save() 保存的圖像的鏈接

您可以執行以下操作

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM