Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!portal!cup.portal.com!dhelrod From: dhelrod@cup.portal.com (David Hunter Elrod) Newsgroups: comp.graphics Subject: Re: How to map 24-bit RGB to best EGA/VGA palette? Message-ID: <21898@cup.portal.com> Date: 5 Sep 89 19:21:53 GMT References: <4379@cps3xx.UUCP> <126@vsserv.scri.fsu.edu> <3129@cbnewsm.ATT.COM> <7743@cbmvax.UUCP> <13319@well.UUCP> <586@celit.com> <4862@eos.UUCP> <13381@well.UUCP> <9464@venera.isi.edu> <9473@venera.isi.edu> Organization: The Portal System (TM) Lines: 72 There has been occasoinal mention of performing calculations in HSV space, or selecting colors in HSV instead of RGB. I'm curious why the CIE-LUV color space isn't used. Converting back and forth from RGB to HSV is NOT a 1:1 mapping. Even with perfect math, it is possible to go from HSV to RGB and back and have a DIFFERENT value than the one you started with. The CIE (Commission Internationale de l'Eclairage (International Commission on Illumination)) defined a color space in 1931. This color space is used throughout the world for specifying a specific color in a device independent way. In all three CIE color spaces (CIE-1931(or CIE-xyY), CIE-LUV, and CIE-LAB) the color indicies range from 0.0 to 1.0. Although only a portion of this space is valid. A problem with the original CIE color space is that equal distances in the color space represented UNequal distances in human visual spaces. For example, moving from (0.1,0.6) to (0.1,0.7) is a small change from one green to a similar green. While moving from (0.5,0.3) to (0.5,0.4) is a change from red to orange. This problem was somewhat solved by the CIE-LUV space in 1976. The LUV color space was a compromise between a space where equal distances represented equal percieved color changes, and it wasn't too complex to translate to/from that space. Another space, CIE-LAB, is a more linear space, but requires cubes and cube roots to convert from a color cube and back. So, why all the above?? Well, CIE-LUV isn't that hard to convert to/from RGB, and it IS a space where equal sized chunks of color space represent approximately equal sized portions of what the "CIE standard observer" can see. Seems to me that this should be the space to put the histogram bins in. Especially if each bin represents several colors. All colors falling in a single bin would be percieved as being very similar. When I was studying color, I looked at a lot of the available literature. This included several of the newer books that have come out discussing color. I found the following two to be the best for what I was doing (which was looking at lighting and shading, "true" color representation in a device independent way, and color space transformations for high end graphics accelerators). References: Procedural Elements For Computer Graphics by David F. Rogers McGraw-Hill Book Company ISBN 0-07-053534-5 Copyright 1985 This book was the best of all that I looked at for explaining what was going on and giving sample code that you could play with to make sure you REALLY understood. It still leaves some stuff to the reader... Color Science: Concepts and Methods, Quantitative Data and Formulae Second Edition by Gunter Wyszecki W.S. Stiles John Wiley & Sons ISBN 0-471-02106-7 Copyright 1982 This is "THE" book on color. It is a huge book that covers more than I ever wanted to know about color. A GREAT reference book. It also has a lot of the facts figures and values needed for some types of calculations in the appendicies. =============================== David Elrod Rivendell dhelrod@cup.portal.com