title: Determine image overall lightness
body: <p>I need to overlay some texts on an image; this text should be lighter or darker based on the overall image lightness.
  How to compute the overall (perceived) lightness of an image?</p>
  
  <p>Found something interesting for single pixel:
  <a href="https://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color">Formula to determine brightness of RGB color</a></p>