Ich möchte die HSV cone in Python erstellen.Modellierung HSV Farbraum Kegel mit Python und Matplotlib 3D
Versucht, die Lösung für MATLAB in another question gegeben anzupassen:
import numpy as np
import cv2
H = np.repeat([np.linspace(0, 179, 100)], 100, axis=0)
S = np.repeat([np.concatenate((np.linspace(0, 255, 50), np.linspace(255, 0, 50)))], 100, axis=0).transpose()
V = np.repeat([np.concatenate((np.ones(50)*255, np.linspace(255, 0, 50)))], 100, axis=0).transpose()
hsv = np.asarray(cv2.merge((H, S, V)), dtype=np.uint8)
C = cv2.cvtColor(hsv, cv2.COLOR_HSV2RGB)
theta = np.linspace(0, 2*np.pi, 100)
X = np.asarray([np.zeros(100), np.cos(theta), np.zeros(100)])
Y = np.asarray([np.zeros(100), np.sin(theta), np.zeros(100)])
Z = np.asarray([2*np.ones(100), 2*np.ones(100), np.zeros(100)])
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X, Y, Z, color=C)
bekam aber den Fehler: "Invalid rgba arg ... Länge rgba Sequenz sein sollte entweder 3 oder 4".
Versuchen C mit C.reshape(3, 100, 100)
neu zu gestalten bekam aber den Fehler: color=C
Ohne arg "Invalid rgba arg ... nur Länge-1-Arrays kann zu Python Skalare umgewandelt werden" ich dies habe:
HSV cone with ax.plot_surface(X, Y, Z)
Vielen Dank!