Path: utzoo!attcan!uunet!convex!killer!ames!oliveb!amiga!kodiak From: kodiak@amiga.UUCP (Robert R. Burns) Newsgroups: comp.sys.amiga Subject: Re: RGB to HSV Colors Summary: H-S-What? Message-ID: <2245@amiga.UUCP> Date: 30 May 88 18:27:49 GMT References: <8805271453.AA13503@jade.berkeley.edu> <7271@swan.ulowell.edu> Reply-To: kodiak@tooter.UUCP (Robert Burns) Organization: Commodore-Amiga Inc, Los Gatos CA Lines: 33 In article <7271@swan.ulowell.edu> dpelland@hawk.ulowell.edu (David Pelland) writes: >In article <8805271453.AA13503@jade.berkeley.edu> BBOURBIN@UMDD.BITNET (Brett S Bourbin) writes: >>Does anyone out there know of a formula for converting a RGB (red green blue) >>color value, into a HSV (hue saturation value) one? > >H = cos^-1((1/2((R-G)+(R-G)))/(((R-G)^2+(R-B)(G-B))^(1/2))) >S = 1 - ((3*(min(RGB)))/I) >I = (R+B+G)/3 I'm jumping in in the middle of this, so I don't know the original question, but this "I" seems to be that associated w/ the Tektronix double-ended cone color model. Most Amiga stuff I've seen uses the HSV cylinder, w/ black on the bottom, white in the middle at the top, and fully saturated colors around the outside of the cylinder. My favorite reference is the 1978 (?) SIGGRAPH proceedings (but I don't have them). I think of HSV as... H = [0 == 1 == red; .33 == green; .67 == blue] // that may be the one above? S = 1 - min(R, G, B); // distance from "grey" V = max(R, G, B); // non-blackness >((good) (luck) (with) (the) (parenthesis)) Different color models have different origins for the hue (e.g. 0 is red vs. blue). You can also skip the arccos and do linear interpolation in the 6 sextants (?) of the hue -- remember you've only got to get it right to 4 bits. I admit I didn't decode those parantheses :-> - Kodiak -- | / _ _|' _ |/ Bob Burns . . . . .---. . Makers of |/ (_)(_)|(_\|\ USENET: amiga!kodiak / \ |\ /| | | __ / \ the "Power |\ Kodiak \ _______/ A \| \/ |_|_|___|/ A \ System" | \ Software "Dedicated to the Science of Fun"\_________