Programmatically determine the average greyscale

-hh hh at
Thu Feb 18 19:46:58 EST 2016


I now saw, late -- sorry, that you are using button's showName, that is, the text colour has to be adjusted, not the pattern.

Then using a text field instead of 'showName' and setting the field's ink to "notSrcAndReverse" should do what you want (incl. nice effects).


Here's a formula for a weighted mean close to that some professional apps use when converting an image to grayLevel.

This is derived from "perception" values (note: .6 is close to goldenRatio) of the human eye:

## g = (1*r + 6*g + 3*b) div 10 for each r,g,b-pixel
used for fully opaque pixels.


More information about the Use-livecode mailing list