views:

35

answers:

1

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  A: 

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.

rpetrich