RGB -> HSV
-
Hallo,
ich hab bei Wikipedia die Formeln zur Umrechnung von RGB in HSV gefunden:
http://de.wikipedia.org/wiki/HSV-FarbraumOder gibt es irgendwo was fertiges ?
Ernst
-
Ich hab mal das hier gefunden. Das kannst du ja benutzen, wenn du willst. Ansonsten gibt es sicher auch andere Lösungen.
#define RETURN_RGB(r, g, b) {RGB.R = r; RGB.G = g; RGB.B = b; return RGB;} RGBType HSVtoRGB( HSVType HSV ) { // H is given on [0, 6] or UNDEFINED. S and V are given on [0, 1]. // RGB are each returned on [0, 1]. float h = HSV.H, s = HSV.S, v = HSV.V, m, n, f; int i; RGBType RGB; RGB.R=RGB.G=RGB.B=0; //Anti-Warning-Maßnahme... if (h == UNDEFINED) RETURN_RGB(v, v, v); i = (int)floor(h); f = h - i; if ( !(i&1) ) f = 1 - f; // if i is even m = v * (1 - s); n = v * (1 - s * f); switch (i) { case 6: case 0: RETURN_RGB(v, n, m); case 1: RETURN_RGB(n, v, m); case 2: RETURN_RGB(m, v, n); case 3: RETURN_RGB(m, n, v); case 4: RETURN_RGB(n, m, v); case 5: RETURN_RGB(v, m, n); } ASSERT(0); //Anti-Warning-Maßnahme... return RGB; // }
-
was fertiges gibts glaub ich nicht, aber hier gibts irgendwo ne RGB2HSV Funktion im Forum -> Suche
greetz KN4CK3R
-
Hier mal ein Link für RGB2HLS (ähnlich aber nicht identisch mit HSV)
http://www.c-plusplus.net/forum/viewtopic-var-t-is-115882-and-postdays-is-0-and-postorder-is-asc-and-highlight-is-hls-and-start-is-10.html
-
http://www.c-plusplus.net/forum/viewtopic-var-t-is-222696.html
Sind sogar jede Menge Premature Optimizations drin