Slashdot Mirror


Determining Color Difference Using the CIELAB Model?

Colour Blind asks: "I am working for a not-for-profit organization developing a website for kids. I am attempting to develop a method for testing if two colours (as defined by R, G, and B values [0-255]) are adequately different to be visible on top of each other. So far I have tried many things but this is the one that, by all accounts, should work: I have converted from RGB to (CIE)XYZ using a 3x3 matrix transformation. From here I have used three more equations to convert to CIELAB colour. I have then calculated the distance between the two colours in question in CIELAB colour space. The results are not correct: there are pairs of colours that are quite far from visible that yield the same difference as colours that are plainly acceptable for visibility. Any suggestions?"

18 of 199 comments (clear)

  1. Color Blind! by hkhanna · · Score: 1, Interesting
    This is an interesting experiment, and it could even have implications in the game programming world. I used to experiment with that kind of stuff (RGB palettes, etc...) but then stopped after I couldn't tell the differences between any of the colors.

    I went to the doctor only to find out I was color blind and that explained why I could only see three colors on a rainbow. It's sad, I know, but true.

    --

    Think nothing is impossible? Try slamming a revolving door.
  2. Try the Value in HSV instead by "Zow" · · Score: 4, Interesting

    I think the key in picking colours for any website is that they have have a difference of at least X in brightness (the V in Hue-Saturation-Value unless I'm sadly mistaken - I'm not an expert in this area), where you should be able to determine X experimentally. Any decent color picker (such as those in Gimp or Photoshop) will allow you to jump between RGB or HSV. The reason I think this is the way to go is that a decently large percentage of the population (at any age) is colour blind, so while you or I may easily be able to see the difference between a blue and green, or a green and red, at the same brightness, some people (particularly males), just can't.

    That should take care of you for making the site usable. At that point, the choice of which light or dark colors you use for what becomes purely stylistic (again, I'm just a stupid computer scientist - I'm sure someone with a stronger HUI, marketing, or fine arts background might have a stronger opinion on what colors are used for what).

    -"Zow"

    1. Re:Try the Value in HSV instead by keesh · · Score: 3, Interesting

      That works quite well, but only at higher saturations. At lower saturations involving too many greys, the rule quite often fails. Having one high and one low saturation is also pretty good. The advantage of this is that it almost totally avoids the colour blindness problem if you stick to one hue.

      The HSL colour space isn't a very good mapping, though. Things like CIE are better representations of how we really see things.

    2. Re:Try the Value in HSV instead by sfraggle · · Score: 5, Interesting

      I have to agree with this. I am the author of Text Mode Doom and I hit a problem along these lines during development: the RGB value itself is not particularly useful when trying to find a numerical value for a particular "colour" that the human eye perceives. In text mode doom I was faced with the problem of mapping the particular colour value to a corresponding text colour, of which I was limited to a small value (under 16). I solved the problem by converting the RGB values into HSV and then assigning text colours to the real colours based on their hue. The results I found with this were quite impressive

      --
      were you expecting to see a sig here? perhaps you'd rather see the inside of an ambulance!
    3. Re:Try the Value in HSV instead by Anonymous Coward · · Score: 1, Interesting

      I wrote a little tool to generate bg and fg colours for terms and text edit windows( gvim) from a desktop background xpm. I found that hsv worked for a limited volume of its colour space, but not its entire volume. The problemn is that the HSV space is not a very good mapping. In fact I am rather suprised that it even exista. I have thought about converting to CIELAB, but it is actualy better suited for print ( i.e. converting back to CMYK). Lets face it, CRTs are just plain obnoxious. Colour pairs that should work don't and pairs that should not sometimes do. The fault is not with RGB, but the mechanics of the monitor. BTW I was getting ready to work on an alternative mapping to HSV that would more acuratly map the responce of the eye. The problem is that what I have done so far does not yeild three 0 to FF numbers. My colour theory book was written by a guy named Kuhn ( I think) he is one of the leading experts in this field. It might be well worth reaserching what he has published resently.

    4. Re:Try the Value in HSV instead by mystran · · Score: 2, Interesting
      Maybe something like:

      Take the H, S, and V values of both colors. Then calculate a difference for each of them like: |h2 - h1| and |s2-s1| and |v2-v1|

      Use Hue so that the min-value and max-value are the same (effectively to create a circle and find the smaller arc between the points on in) Then do something like dH*dS*dV possibly with some constant weights and the result shoul should be larger when the difference is larger.

      For this to give useful numbers H, S and V should probably be a float between 0 and 1.

      --
      Software should be free as in speech, but if we also get some free beer, all the better.
  3. Think this through... by Anonymous Coward · · Score: 2, Interesting

    Have you been able to demonstrate that the small difference seen between two contrasting colors is due to a flaw in the CIELAB model? If so, perhaps you can publish a paper on the subject. Otherwise, what evidence do you have that your program is actually doing the right thing? For example, CIELAB appears to use polar coordinates. Are you sure that you are treating 0 and 2*PI as being the same value?

    Also, you have not demonstrated a need for such an evaluation function to exist. Is this because the site designers have a problem being able to choose readable colors? Perhaps if these people cannot select a good color scheme, you need new designers.

  4. It depends on the difference and how it's approach by Anonymous Coward · · Score: 2, Interesting

    Note, IAANR (I am a neurobiology researcher), but I deal mainly with ion channels so take this with an appropriately sized grain of salt:

    Your ability to tell the difference between two colors (or light intensities to bring back the classic experiments) depends on how you approach the limit of perception (or differentiation in this case). Classically, if you start where you can not perceive a difference between to intensities, and increase the difference, your threshold for difference will be lower than had you started when you could tell the difference between the two intensities and gradually decreased this difference. It seems that color differences should follow the same rules as light intensities. Also keep in mind that we're more sensitive to differences in shades of blue, IIRC, due to overlaps in the sensitivity ranges of long, medium and short cones. So, these are probably among the causes for you observations.

  5. Re:This is relevant why? by keesh · · Score: 3, Interesting

    Automated colour scheme generation. Let's face it, most people (myself included) can't generate a decent colour scheme to save themselves. Having a program create scheme suggestions automatically is extremely useful (blatant plug: check my sig for my own attempt at doing this) for non-artists.

    There are a load of tricks for generating colours which usually work well together; however, the hue rotations trick sometimes generates totally unreadable combinations (mainly with bright colours). Having an additional check would be extremely useful.

    Anyway, it could be that you're good at graphics, in which case good for you. Just give the rest of us time to catch up :)

  6. Land's Two Color visual perception work by mbone · · Score: 4, Interesting

    Edwin Land (yes, the founder of Polaroid) did work in human color perception, where he showed that two colors could used to create an apparent full color image.

    The important things are our visual expectations, as well as the relative intensity of parts of the scene. I can remember a demo from Land where two projectors sufficed to give a full color scene. If part of the image was abstracted, it appeared to be black and white ! This implies that a combination of two colors can, under certain circumstances, appear to be the same as a different combination of three colors. I would suspect that this effect would have to be considered in the vision tests described in the original posts.

    A Michigan State U. report on the Land work is available, as is a lot of more recent work, such as this paper by Kobus Barnard.

  7. Complex issue by wex · · Score: 3, Interesting

    There are a number of critical factors in this process that you haven't told us. The issues of display devices, gamma, and implementation details all play an important role in your ability to visibly distinguish between two colors.

    What sort of monitor are you using? Have you correctly callibrated the display? What software are you using to display the colors? How does this software deal with display gamma? Other important details include the brightness of the surrounding environment, other windows and such on the screen which can distract the eye and interfere with your visual processing of the colors.

    If you haven't already read the books and web pages by Charles Poynton, they cover all the details. Color issues always seem simple, but actually this is an extremely complex and subtle issue. Also, people's ability to visually distinguish color varies quite a bit. A surprisingly large percentage of the population is color blind to at least some portion of the spectrum. Also, display devices vary widely in their ability to correctly display different colors.

    Anyway, to sum it all up, I'd be really surprised if you can use any sort of theory to predict whether you can visually distinguish between different colors. Even with correctly callibrated equipment, and experienced researchers, I doubt that your problem is easily answered!

    Best of luck,

    Daniel Wexler
    www.flarg.com

  8. Re:Land's Two Color visual perception work by SkywalkerOS8 · · Score: 2, Interesting

    I did work on this in college for a physics of light and color class. His experiment worked best when he used cyan and red filters for the projectors/cameras. Cyan is the light equivalent of combining blue and green. So in effect, you get RGB, with only taking two black and white samples of a scene.
    This is also how 2-chip DLP works. 1-chip DLP uses a color wheel containing RGB, and alterately projects an image of each color, the chip is, in essence, the black and white sample. 2-chip DLP uses a cyan filter on one of the projector's chips, and a red filter on the other, in effect, reproducing Land's experiment! 3-chip DLP uses a chip for each of RGB.

  9. Many possibilities by vektor_sigma · · Score: 3, Interesting

    I would recommend making sure you are accounting for the gamma of your monitor in your matricies. That is, your transforms should be, R'G'B'->RGB->XYZ->L*a*b* and then compare. You can also try making comparitions in L*u'v' space, which is also supposed to be "perceptually uniform". You should also generate some gradients in L*a*b* space and see if they match some you might find on the web.

    That said, both of these colour spaces are really only approximations, and I think they'll be weighted towards uniformity in pure colours. Maybe a colour that pulls from a wider range of the spectrum like orange or gold might be smaller than the green or blue areas. I'm going to try and generate some test images to verify this either way.

  10. Why not ask the kids? by MarkusQ · · Score: 4, Interesting
    Why not ask the kids? Make it a game of some sort (details depending on age) where they have to find and click on some target word or image. Track how often (or how quickly) each combination is picked, and you'll have all the data you need to answer your question. To keep from wasting time in the parts of colour space where you know the answers (yes, navy blue text shows up well on a pale pink background) have the game advance through levels (each level having less distinction than the one before) until they have three wrong clicks/timeouts. Then start over with another base colour pair.

    -- MarkusQ

  11. Re:Color blindness by BWJones · · Score: 4, Interesting

    Yeah so this was interesting as there have been tetrachromats discovered in other primates (monkeys other than humans), so it was reasoned that it might be possible to find tetrachromacy in humans.

    The advantage that hyperdimensional color perception has over traditional trichromacy it a better ability to discriminate hues or different colors. Therefore a tetrachromat could be considered to be at a certain advantage when it comes to color discrimination. This obviously has not been important to our evolution but it is for some species as birds and turtles see a world we can only imagine with some birds seeing from ultraviolet into the visible spectrum and turtles seeing a world rich with color. For instance, if you were to imagine a turtle sitting in a pond with the water as still as glass and the sun setting on the horizon making everything (the sky, land and water) red and orange and yellow, the turtle sitting in the water would be able to pick out a frog sitting on a log with discrimination that we could never hope to approach.

    --
    Visit Jonesblog and say hello.
  12. Also.. by thecarson · · Score: 2, Interesting

    As a sidenote, I'd like to point out that the color yellow can cause sick people to become more ill. Just as red/orange makes someone hungry, bright yellows make someone sick. it can even induce epileptic shock. True! That's why hospitals are always lavender and purple.

  13. Damn the monitor, shift to R Theta color wheel. by Erris · · Score: 3, Interesting
    I'm not sure about all the technical limitions of various monitors, but the color wheel sitting on my desk looks like the answer. It has complementary colors 180 degrees apart. So Red is opposite of green, blue from orange, purple from gold etc. These are all optimal contrasts, except for people who are red green color blind. Combinations that are close with respect to angle, like red and red-violet do not contrast much.

    Try using the color sum, R+B+G for radius and the ratio of colors for angle. The outside would be white, the center black and a mean radius would have R+B+G = 256 and so contain the pure colors. Limits of acceptable difference could be set to accomodate for any crappy old monitor.

    If no one else has come up with this rather obvious aproach to digital color, I hearby delcare first art and grant anyone and everyone the right to use this basic IDEA without further consultation. You'll have to do some work to make that idea practical, but the basic idea seems to have been working for designers, graphic artists, archetects and plain old painters for a long time.

    --
    DMCA, Hollings, Palladium. What might have sounded like paranoia is now common sense.
  14. Did this a couple of years ago by UnknownSoldier · · Score: 3, Interesting

    I wrote an image recognition system for the lumber industry a few years back.

    People (graders) using neon chalk would write on boards (The marks would designate the board quality, and where to cut the bad pieces off.) The boards and chalk would go under a housing with UV light, which had a photosensitive trigger. The trigger would signal the computer, to capture the image. The computer would analyze the image, and send out appropiate bits to a PLC which controlled the saws and sorting.

    As you have found out, RGB does *not* uniquely identify colors. We worked around that problem in 2 ways:

    1) carefully choosing our chalk color.
    2) I then converted the colors over to HSB and used a relative error of Hue to determine if 2 colors were "close enough."

    It wasn't perfect, but it was close enough and extremely fast.

    I doubt HSB will be sufficient for your domain, but see if you can "change the problem" to make it more computer friendly :-)