Show HN: Simple algorithm and color space to generate diverse skin tones

(toneyalexander.github.io)

196 points | by automatoney 2 hours ago

27 comments

  • richard_chase 0 minutes ago
    Why do you need diverse skin tones for your art? It's your art, you can choose whatever skin tones you wish. Are you trying to be so PC that you've relinquished creative control over your own art?
  • s1mon 3 minutes ago
    It's always entertaining to try to understand these things from first principles. Color and skin color in particular are very complex things to measure and model. It's not just a physical quantity, it's also a matter of human perception based on lighting and a host of factors.

    It seems like some work was done to research existing approaches, but I don't see any reference to Pantone Skin Tones [0]. Without intending to, I've worked on 3 different projects which involved measuring skin tones for makeup applications. The Pantone range is not 100% perfect, but it's pretty well done and easy to understand. There are two axes: a light/dark one, and red-yellow one [1].

    [0] https://www.pantone.com/na/en-us/skintone

    [1] https://cosmeticsbusiness.com/pantone-skintone-guide-80945

  • vermarish 1 hour ago
    This is beautiful work! First, I thought this would involve using PCA to go from 3D to 2D, which would result in an easier selector to use, but at the expense of representing every person.

    Then, I thought this would stop at using the U-space vectors (the ones that form the basis of the PCA image) and their corresponding ellipse to form our color space, but no, the function fitting is a very slick idea, even if it was executed by hand.

    Lastly, I love the presentation of sampling from different r values. Whether you sample from a fixed r value or a range of r values, I bet this has great applications in game design or animation.

    I still don't quite get the manual data labeling process at the beginning? It seems like it would encode some bias, but the consistency of the first point cloud and the results certainly speak for themselves.

    • dr_scully 1 hour ago
      If you look at my doctoral thesis, in fact skin colour can be parametrised using melanin and haemoglobin concentration; which it means it is indeed (roughly) two dimensional. This allows you to invert the colour of a pixel and identify someone’s chromophore concentration. This is based on previous work of others cited in the thesis.

      https://discovery.ucl.ac.uk/id/eprint/10093345/

      • dTal 53 minutes ago
        Oh goody, an expert in a question I've always wanted to ask.

        Once upon a time, I encountered a sort of interactive museum book called "Earthsearch". One of its "exhibits" was a color wheel, made of two spinnable pieces of tinted acetate, that purported to be able to generate any skin tone. I suppose this is three degrees of freedom, since for any position of the two wheels you could access a range of colors around the edge - but the printed page underneath was simply a grayscale gradient, so one degree of freedom was simply luminance.

        The book was released in 1994, and was very confident. It even went as far as to encourage the reader to see a doctor, should their skin tone not be achievable! What color model were they using?

        • dr_scully 13 minutes ago
          That’s sounds very interesting. I’m not sure. In the thesis, I generated spectral curves and transformed them using the light and camera sensitivity curves. So, in theory it could be used in any color space.

          But I can’t vouch for the accuracy of the book, but I suspect it was an approximation.

          The haemoglobin and melanin are roughly in separate layers of the skin. There is an approximation known as Beer-Lambert that models the skin as two semi-transparent layers. This ignores subsurface scattering, but is roughly correct.

          So, in theory two acetate sheets might replicate this. That’s my intuitive opinion. It has been many years since I did this work.

        • mhink 27 minutes ago
          Oh man, that's a blast from the past, I think I had that book! Was that the one with an aluminum cover?
          • dTal 3 minutes ago
            That's it! They (rather dubiously) claimed it came from a recycled Russian coke can, if I recall.
      • GolDDranks 1 hour ago
        I've heard that the so-called "yellowish" skin color that non-tanned East Asians tend to have, is due to relative abundance of subcutaneous fat. If that's true, is that captured by the haemoglobin dimension or is it a yet another degree of freedom?
        • dr_scully 26 minutes ago
          We used the approximation that the hypodermis was a perfectly white reflector; so the thickness wouldn’t matter. The collagen fibrills scatter light in such a way to create a yellower tint. So a person’s skin might appear this way in the absence of melanin and haemoglobin. I’m not an expert on population statistics, and so cannot give an opinion on specific skin types. Everything was based on ranges.

          There is a separate effect of increased bilirubin content, that would appear if someone was ill.

        • Joel_Mckay 37 minutes ago
          All skin is slightly translucent, and color/tones forms a gradient across the surface of the skin. Your upper cheeks and forehead are usually slightly reddish, and the chin/neck are slightly bluish.

          People only turn yellow if they have kidney or liver damage. However, some distinctive features like Lucy Liu's natural freckles are tough to draw right.

          We looked around a lot for a procedural texture/shader to help make the project characters look less sickly, and please also consider supporting the persons work if you are able:

          https://kuhantilope.gumroad.com/l/ultimate-skin

          Best of luck =3

          • iwontberude 2 minutes ago
            Or they have Gilbert's Syndrome which is a fairly common metabolic abnormality where the bilirubin from dead blood cells are conjugated slower than the baseline patient leading to yellowing of the skin.
        • skydhash 45 minutes ago
          Not an expert, but when I was learning 3d modeling, there was a good chapter on subsurface scattering which affect the human skin rendering. It’s what give it liveness instead of looking like a doll.
    • automatoney 1 hour ago
      Thank you! I call out the manual labeling bias and also that a future work improvement would be to be scientific about that labeling process (multiple labelers, expert labelers), and then to feed that into the equation generation steps. Part of where the "good enough" naming comes from - I was hoping that using my art brain and keeping a bunch of reference images in mind (shout out to the Humanae project) would maybe offset the bias a bit. But 100% right on the bias being there.
  • mbo 44 minutes ago
    Love it!

    I was looking at this a little while ago, and used some of The Pudding's data on makeup/foundation shades (https://pudding.cool/2018/06/makeup-shades/) and plotted it into the Oklab colorspace (https://observablehq.com/@55th/foundation-shades). The shades form themselves into that same crescent as seen in the article.

    • automatoney 41 minutes ago
      Woah I LOVE both of these! When I get a chance these are 100% getting linked from the writeup.
  • andai 1 hour ago
    Nice. Most of these colors look right to me, but I'm also seeing green, blue and purple? If you're curating colors from the space manually then it's not a problem.

    "Only realistic colors" would be a different problem. And I'm not sure if there's a way to solve that problem without excluding some real colors too.

    (Maybe if the colour selector was a different shape? I don't know much about color spaces.)

    • automatoney 1 hour ago
      Yes absolutely right on - I mention much deeper in the page that in a picker UI you can use a bigger range, but that in a generation context you might want to be a bit more selective. I go into it a bit more when I explain what R^2 is.

      "not sure if there's a way to solve that problem without excluding some real colors too" - 100% right on that too. A big part of this work was to define a way to tweak/improve the equations in order to approach a solution to these issues - part of my hope in sharing is to get more eyes and brains thinking about this and proposing improvements!

      • compass_copium 1 hour ago
        I would have "show sphere" on by default--this kind of threw me at first, too.

        This is a really nice project. Great work and a great write-up. Thanks for sharing.

    • richiebful1 1 hour ago
      Reducing the R^2 value to ~1.5 excludes skin colors that are extremely blue, green and purple. That seems to be a happy medium between including real outliers and excluding colors like green.
    • wongarsu 1 hour ago
      If you drag the bottom slider all the way to the right you only have plausible skin tones. Drag it all the way to the right and you can match skin tones for orcs, Na'vi and djinn
  • stephantul 1 hour ago
    Love it. I especially thought the introspective “aside” section on related resources was great, and I wish more people would show this kind of reflection.
    • automatoney 1 hour ago
      Thanks! I hope to send lots of love those ways, they're basically all things that I found outside of this work that I liked enough to remember (I think Humanae was the one that I found while doing this).
      • E-Reverance 8 minutes ago
        I definitely don't speak for all non-white people when I say this, but personally I find people obsessing over it disturbing/offensive independent of whether their intentions are racist or anti-racist. I did find modeling/data-driven perspective cool though
  • manoDev 44 minutes ago
    Skin tones are particularly difficult to pin down, besides the pigmentation there are two effects at play: 1) sub surface scattering (light goes thru and bounces under the skin a bit) and 2) some infra-red emission (the responsible for making some people appear magenta on digital photography)

    So even when you get the palette right, to paint it like a believable material in a convincing way is still super hard!

  • xp84 45 minutes ago
    This part ( https://toneyalexander.github.io/inclusive-color-space/#pick... ) is especially cool.

    Would love to see this 3-D picker ability in the many character designers out there, instead of the lame 8 swatches or whatever.

  • dofm 57 minutes ago
    Interesting though that the 1.5 setting (at least on my older iPhone) doesn’t really ever seem to cover the range of skin tones of indigenous Australians (“aboriginal” and Torres Strait Islanders), who apparently get their skin tones from a somewhat different expression of genes than other peoples with darker skin.

    The 2.0 “outliers” cover those skin tones.

    Masai and some Somali skin tones, similarly, look better represented by the outliers.

    The full range of possible human skin tones is perhaps a bit of a challenge for technical colour representation, partly because diffuse reflectance seems to vary so much and that is hard to approximate on screen (e.g. as any website designer could attest, the difference between representing silver and grey is the use of highlights), though the representation of skin tones is a lot better than the early colour film era.

    • automatoney 52 minutes ago
      Yes, 2.0 is the value I tuned the equations around - but I think there's definitely room for improvement in terms of squashing the space along the fair/deep axis in order to get better results at lower R^2.

      The issue I ran into was what happens when the space moves beyond RGB, but I think the fix is to just add clamps to the end R, G, B values.

  • PullJosh 1 hour ago
    I love this! Such a beautiful use of some real nerdy math to benefit humans in a way non-nerds would appreciate.
  • rrradical 1 hour ago
    Very neat project. Could I use this code to generate skin tones in my own project? Or more meant to just be educational/inspirational? I guess I'm wondering if you've considered adding a license.
  • m_w_ 1 hour ago
    This is super cool! I have always loved projects that try to categorize color space. Usually my work has gone in the other direction - isGray, isCloseToWhite, isPastel - but it's the same insofar as it's defining shapes like your matplot visual.

    Wish I had this on hand like this three or four years ago when I was working on VR avatar software - we had hard-coded skin tone options at the time - would have been a cool addition!

    • automatoney 1 hour ago
      In sharing this around I've found more people than I thought who've done things to semantically chop up the color space - definitely a more interesting area than I first thought of when working on my narrow use case. Feels like it'd be fun to play with something that has a whole bunch of different regions of color space labeled - like "here's where IsPastel overlaps with IsGreen".

      But absolutely the hope is that this is a tool that stays accessible to people for whatever they're building and everyone can slow down on reinventing the wheel here for every character creator/digital art application.

  • ptsneves 1 hour ago
    On the movie Dolemite by Eddy Murphy, they go over the fact that black people absorb light and white people reflect, and how that changes the motion picture shooting process totally. Also how one size does not fit all. Cool project! I am not much into the humanities part of the project. For me this is as natural as having a localization framework, just in this case for skin tones.
  • efitz 54 minutes ago
    Never seen anyone #E6FFF8 (bottom right corner).

    An albino that consumed too much colloidal silver for years?

  • hluska 1 hour ago
    This is excellent work! You’ve got a 49 year old and a 10 year old equally into it. That’s impressive - nice work.
  • aaroninsf 30 minutes ago
    Not my domain though I followed the data science enough to nod as if I really followed it,

    but this is just lovely and inspirational work. A unique marriage of hacking in the celebratory sense, thoughtfulness, and meaningful contribution. Outstanding.

    • automatoney 20 minutes ago
      Wow what a touching compliment, thank you so much!!
  • RIMR 1 hour ago
    For anyone confused, turn off your dark mode extension. :)
    • automatoney 1 hour ago
      Oh wow, didn't even think of how that sort of thing might affect the page.
  • Abh1Works 1 hour ago
    Cool work!
  • ralusek 31 minutes ago
    If you're ##CCFFFF please go to the hospital
  • bellowsgulch 1 hour ago
    Skin is so interesting as a surface to think about how light passes through and bounces off of.

    There is at least one article published by a technical artist at Pixar who describes modeling a skull within a human scan so that subsurface lighting is more accurately rendered.

    I suspect you could combine this with dr_scully’s comment and GolDDranks’ to reach the nuance involved in long tail realism details.

    • automatoney 48 minutes ago
      There's a lot of really good research papers that touch on this area from what I saw - would definitely be cool to see if that extra nuance could be added without dramatically increasing the math complexity; in its current state, the code could be used in any programming language without a library.
  • tyromaniac 1 hour ago
    [dead]
  • noobahoi 44 minutes ago
    [flagged]
  • moralestapia 1 hour ago
    Interesting.

    It might be a bit biased though, as there's much more variation on fairer skin tones than on dark ones (there's only one that looks like the colloquial "black").

    This contradicts all research and social media from the past decade.

    • Tossrock 1 hour ago
      ...Did you read the article, or use the picker? It's a continuous (up to the limits of RGB quantization) space which includes thousands upon thousands of shades of black. The selected tones at the top of the article are random and change continuously.
  • 383toast 1 hour ago
    Seems to underrepresent pale skin tone variety
    • LocalH 1 hour ago
      Turn off your dark mode reader extension
  • hneqy2wqls 46 minutes ago
    This hits different after a long week
  • drnick1 21 minutes ago
    The last thing we need is more "diversity" shoved down our throats.