Fast Algorithm to Determine Average Brightness of an Image

hh hh at hyperhh.de
Tue Sep 20 19:31:47 EDT 2016


There is still one option that uses a weighted grayLevel-mean
(I use these weights in imageJIT). This would reflect more
than simple averaging that one wants a dark/light decision.

return (0.1*byteToNum(byte 2 of iData) \
      + 0.6*byteToNum(byte 3 of iData) \
      + 0.3*byteToNum(byte 4 of iData))

Also, what will be still fast enough, you could think about 
scaling down _proportional_ to 3x2 pixels (or 12x8 pixels)
and then applying the above weighted mean on these few pixels.

p.s. I checked: The one-pixel color is by LC built from the
arithmetic mean of the color channels, nearly as fast as an external!




More information about the use-livecode mailing list