fascinating. Though what is bright not bright, is, as you say, "not sharp"
Images that return a value > 100 still seem bright enough to warrant darker
and of course you may have e.g. very dark stone mountains (taking up 1/3 of the
composition space at the bottom half of the image) with a very bright, blue
So "average brightness" has only so much utility in terms of choosing a color
brightness for an overlay.
But, this is still very useful function. Thank you!
On 9/20/16, 10:14 AM, "use-livecode on behalf of hh"
<use-livecode-boun...@lists.runrev.com on behalf of h...@hyperhh.de> wrote:
You could try the following function. It is "dirty" (the definition
of 'brightness' is also unsharp!), but it is very fast.
-- uses the average color intensity of the pixel
-- resulting from scaling down to a 1x1 image
function avgBrightness theImage
lock screen; lock messages
if there is no img ii then create img ii
set resizeQuality of img ii to "best"
set width of img ii to the width of img 1
set height of img ii to the height of img 1
set imagedata of img ii to the imagedata of theImage
set width of img ii to 1
set height of img ii to 1
put the imagedata of img ii into iData
delete img ii
return avg (byteToNum(byte 2 of iData), \
byteToNum(byte 3 of iData), \
byteToNum(byte 4 of iData))
unlock screen; unlock messages
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your subscription