Find average brightness of an image

  • If I have a material with a coloured image node, is there anyway I can extract the average brightness, say on a scale of 0 to 1 or o to 255 etc, either programmatically or via nodes?

    The reason I want to know this, in case there is a better way of doing it, is to control the balance between diffuse and translucency for a hair material. This is because light colours, blonde's reds etc are more translucent than dark browns / blacks. If this could be done with python I could extract the value as I am creating a particular shader, whereas if it were via nodes it might add to computational time during render, the latter though would allow swapping the colour map for a darker one and automatically have the balance adjusted.

  • @amethystpendant not sure about images, where you'd really need to compare each individual pixel. With colour chips, though, I've resorted to changing the colour picker to Grayscale and comparatively deciding which looks brighter side-by-side as I adjust the brightness value.

    Doing something like that can work for individual colour components, once you have relative brightness values for R, G & B... see the link below for some relative component values, but beware, they differ depending on Gamma correction.

    The options are a mess to sort out formula to determine brightness of RGB colour. This image based solution generate a value to reflect the average brightness of an image relies on ImageMagick, which is a Python module, so could be added to Poser Python.

  • Thanks, @anomalaus I guess that's a bust then, which in all honesty I thought it probably would be. I'll just go with giving the user the choice, I'd gone with 80 20 diffuse / translucent while building but that might change as I get into more testing. I looked at that article you mentioned in the other thread to see if I could see anything that would give me a clue (e.g. it's 15% light is subsurfed, but it was way above my maths level ;o)

  • This appears to be the most used way of doing what your after.

    def brightness( im_file ):
    im =
    stat = ImageStat.Stat(im)
    r,g,b = stat.rms
    return math.sqrt(0.241*(r2) + 0.691(g2) + 0.068(b**2))