Good way to calculate 'brightness' of UIImage?

▼魔方 西西 提交于 2019-11-30 16:18:34

问题


I'm writing an app that will offer OCR of an image captured by the iPhone camera. I want to test the image before I perform the OCR analysis to see if there is sufficient lighting. Anyone have any ideas?


回答1:


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.



来源:https://stackoverflow.com/questions/3992790/good-way-to-calculate-brightness-of-uiimage

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