BBOURBIN@UMDD.BITNET (Brett S Bourbin) (05/27/88)
Does anyone out there know of a formula for converting a RGB (red green blue) color value, into a HSV (hue saturation value) one? I think it is some sort or ratio but I would like to know the "correct" method. (Dan Silva, are you out there? 8^) ) Brett S Bourbin Instructional Computer Programs - University of Maryland, College Park BITNET: bbourbin@umdd.BITNET E-MAIL: brett@rover.umd.edu
dpelland@hawk.ulowell.edu (David Pelland) (05/28/88)
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 ((good) (luck) (with) (the) (parenthesis))
papa@pollux.usc.edu (Marco Papa) (05/28/88)
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? | |I think it is some sort or ratio but I would like to know the "correct" |method. (Dan Silva, are you out there? 8^) ) Get hold of a copy of "Procedural Elements for Computer Graphics", by David F. Rogers, McGraw-Hill Book Co., 1985. On page 401 through 406 you will find pseudo-pascal code for HSV->RGB, RGB->HSV, HLS->RGB, and RGB->HLS conversions. It took me about an hour to transform them in C, and all the algorithms DO work. This book is in my opinion one of the BEST computer graphics books. This is David's second book (the first one was Mathematical Elements for Computer Graphics). I hear that a third book is or will soon be published. -- Marco Papa 'Doc' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= uucp:...!pollux!papa BIX:papa ARPAnet:pollux!papa@oberon.usc.edu "There's Alpha, Beta, Gamma and Diga!" -- Leo Schwab [quoting Rick Unland] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
kodiak@amiga.UUCP (Robert R. Burns) (05/31/88)
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"\_________