Maybe you should explain what your current approach is? For example, are you computing an average RGB over the pixels array? are you using scaling, or a shader?
Depending on you area of appliication, you might be interested in bias lighting / ambilight / the adalight – there are privous Processing projects on this, for example: