Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!hpfcdc!hpfcdq!jlg From: jlg@hpfcdq.HP.COM (Jeff Gerckens) Newsgroups: comp.graphics Subject: Re: RGB to Hue/Saturation/Luminence Message-ID: <390034@hpfcdq.HP.COM> Date: 28 Jun 89 00:29:41 GMT References: <2922@ukecc.engr.uky.edu> Organization: Hewlett-Packard - Fort Collins, CO Lines: 29 / hpfcdq:comp.graphics / agollum@engr.uky.edu (Kenneth Herron) / 1:51 pm Jun 25, 1989 / > I'm writing a program to convert Amiga IFF images to cross-stitch > patterns (trying to get my wife interested in the darn thing :-). > Part of the conversion requires averaging the colors of several pixels > and reducing the color table by averaging "close" colors. The methods > I have in mind for these steps requires the hue, saturation, & luminence > of the colors in question. Does anyone have the formulas to convert > from RGB to HSL? Or know of a good algorithm for doing these things? > (more details available on request) > > Thanx in advance, > Kenneth Herron Any good text on computer graphics will have the information. Particularly Roger's "Procedural Elements for Computer Graphics" or Foley and Van Dam's "Fundamentals of Interactive Computer Graphics". You may not want to use HSL for the averaging. HSL can produce very "unexpected" results because of its nature as a cylindrical space. RGB should give results that are "as good" in most cases. CIELUV or CIELAB will give the best results, but involve cumbersome translations. You may also experience some difficulty with translating the colors on the screen into thread colors unless oyu do some thread to screen matching. -- Jeff Gerckens, Graphics Technology Division, Hewlett-Packard