我不知道为什么,但不管用。
我尝试了以下代码:
matplotlib.colors.hsv_to_rgb([[[220 / 255, 255 / 255, 255 / 255]]])
matplotlib.colors.hsv_to_rgb([[[(220 % 360) / 255, 255 / 255, 255 / 255]]])
matplotlib.colors.hsv_to_rgb([[[220, 255, 255]]])
# same with
cv2.cvtColor(np.uint8([[[120, 255, 255]]]), cv2.COLOR_HSV2RGB)但当我策划的时候:
import matplotlib.pyplot as plt
plt.imshow(converted_color)
plt.show()它显示了一些随机的东西
从GIMP获取值

最终结果
h, s, v = 270, 100, 100
r, g, b = np.multiply((colorsys.hsv_to_rgb(h/360, s/100, v/100)), 255)
crop[mask == 0] = [r, g, b]ex e e t!
这里是固定的cv2解决方案。最多有180次。opencv像往常一样在自己的路上做事..。-_
h, s, v = 270, 100, 100
r, g, b = cv2.cvtColor(np.uint8([[[h / 2, (s/100)*255, (v/100)*255]]]), cv2.COLOR_HSV2RGB)[0][0]
crop[mask == 0] = [r, g, b]发布于 2020-07-24 05:14:23
尝试使用颜色:
import colorsys
colorsys.hsv_to_rgb(0.5, 0.5, 0.4)输出:
(0.2, 0.4, 0.4)编辑
一个例子可以是:
import matplotlib
import matplotlib.pyplot as plt
import colorsys
h, s, v = 0.83, 1.0, 0.50
#RGB from 0 to 1 NO from 0 to 255
r, g, b = colorsys.hsv_to_rgb(h, s, v)
print(r, g, b)
rect1 = matplotlib.patches.Rectangle((-200, -100), 400, 200, color=[r, g, b])
plt.axes().add_patch(rect1)
plt.show()

若要了解使用imshow显示颜色可能遇到问题的原因,请参阅:Printing one color using imshow
https://stackoverflow.com/questions/63066842
复制相似问题