Good way to calculate 'brightness' of UIImage?

十年热恋 提交于 2019-11-30 16:33:43

The most flexible way is to generate a histogram for the red green and blue color channels, and then use it to determine the average lightness, median lightness, black/white points, contrast or other custom functions.

Use CGBitmapContextCreate to create a bitmap context backed by a buffer of your creation, draw your image into it, then loop through each pixel in the buffer to populate the histograms.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!