我是 Python + OpenCV 的新手,所以這對你們大多數人來說可能是一個基本問題,因為我在網上找不到一個好的/令人滿意的解決方案。所以我試圖通過單獨創建 RGB 層R - 0s層 G - 255s層 B - 255* 標識矩陣層來創建圖像import cv2 as cvimport numpy as npimport matplotlib.pyplot as pltRed = np.zeros([6, 6], dtype = np.uint8)plt.imshow(Red) # it is just the red layer which is actually all blackplt.show()Green = np.ones([6, 6], dtype = np.uint8) * 255plt.imshow(Green) # it is just the Green layer which is actually all whiteplt.show()Blue = np.eye(6, dtype = int) * 255plt.imshow(Blue) # it is just the Blue layer which is actually black with white diagplt.show()但我實際上得到的是紫色或紫色和黃色的組合。有人可以解釋發生了什么和/或如何解決它嗎?
1 回答

繁花不似錦
TA貢獻1851條經驗 獲得超4個贊
嘗試使用
Blue = np.eye(6, dtype = int) * 255
plt.imshow(Blue, cmap='gray', vmin=0, vmax=255)
plt.show()
更多參考這個答案
添加回答
舉報
0/150
提交
取消