I have an OCR based iPhone app that takes in grayscale images and thresholds them to black and white to find the text (using opencv). This works fine for images with black text on a white background. I am having an issue with automatically switching to an inverse threshold when the image is white text on a black background. Is there a widely used algorithm for checking the image to determine if it is light text on a dark background or vice versa? Can anyone recommend a clean working method? Keep in mind, I am only working with the grayscale image from the iPhone camera.
Thanks a lot.
Since I am dealing with a grayscale
IplImageat this point, I could not count black or white pixels but had to count the number of pixels above a given “brightness” threshold. I just used the border pixels as this is less expensive and still gives me enough information to make a sound decision.