The best recognition results can only be achieved if the source image is of good quality. To ensure that users of your application receive the best possible results, you need to pay some attention to the quality of input images.
You can implement some basic quality-checking features, display tips for best image quality in the user interface and include advanced recommendations in the user's manual. If your application contains a scanning interface, you can also control the scanner settings.
Check input image quality
When your application receives an image for recognition, one of the first steps can be checking the image resolution. If the resolution is too small (lower than 150 dpi), some image details might be lost, and the recognition quality will deteriorate. If, on the other hand, the resolution is too great (greater than 600-700 dpi), loading and processing the image will take more time, while the recognition quality will not be materially improved.
In both these cases your application should display a warning to the user:
- The image resolution is too small, please re-scan with the resolution greater than 150 dpi
- The image resolution is too great, please reduce the image resolution to 600 dpi
Another important tip you can give to the user concerns documents printed in very small font sizes (less than 10 pt). If they are scanned with the common 300 dpi resolution, the result may not be recognized well:
Advise the user to increase the scanning resolution to 400-600 dpi in this case:
Next, you can implement some algorithm for estimating the image brightness. When the image, on the average, is very light, some parts of the text may be irretrievably overlighted, with "torn" characters:
When the image is very dark, some parts of the text may be obscured by dark patches, characters stuck together or distorted:
Both these defects can affect the recognition quality. Display a message to warn the user that the results may not be good enough and/or prompt them to provide another digital version of the same document.
You can also advise the user to scan their documents in grayscale, rather than in black-and-white mode. They will still need to select a reasonable brightness value, but the details loss in grayscale will be less significant in any case.
Control the phone camera settings
If your application is intended for installation on mobile devices, and the images for recognition will be taken with the device's camera, you can perform some additional checks:
- It's best to turn off the flash when photographing documents. Check if the flash is turned on and display a warning to the user, or even turn it off by default when photographing from your application's interface. See the example of how the flash can damage digital document quality:
If your application will process business cards photographed with a mobile phone, see this section for specific recommendations: Photographing Business Cards with a Mobile Phone.
Control the scanner settings
If your application can receive images directly from scanner and manage the scanning operations, you need to select the best defaults for scanning. The following settings are recommended:
- set the brightness to a reasonable medium value, for example 50;
- set the resolution to 300 dpi;
- if the color of the documents is not important for the task, choose grayscale color mode: scanning in black-and-white will not always produce the best results, especially if the original document is not of very good quality.
Recommendations for inclusion into the user's manual
The user's guide to your application can include the recommendations on how to obtain good quality digital versions of their documents. Here are our suggestions for taking pictures of documents with a digital camera:
Minimum Camera Requirements
- 2-megapixel sensor
- Variable focus lens (fixed-focus cameras, common in cell phones and hand-held devices, will usually produce images unsuitable for OCR)
Recommended Camera Requirements
- 5-megapixel sensor
- Flash disable feature
- Manual aperture control or aperture priority mode
- Manual focusing
- An anti-shake system, otherwise the use of a tripod is recommended
- Optical zoom
Before taking a picture
- Make sure that the page fits entirely within the frame.
- Make sure there is enough light (preferably daylight). In artificial lighting, use two light sources positioned so as to avoid shadows.
Turn off the flash to avoid glare.
- Position the lens parallel to the plane of the document and point it toward the center of the text. At full optical zoom, the distance between the camera and the document must be sufficient to fit the entire document into the frame. Usually this distance will be 50-60 cm.
- If possible, use a tripod to avoid shaking.
Enable the anti-shake system, if available.
Use auto release to prevent the shaking of the camera caused by pressing the shutter release button (even when using a tripod).
- If your camera allows, use a white sheet of paper to set white balance. Otherwise, select the white balance mode which best suits the current lighting conditions. Below you can see an example of wrong white balance (on the left) and correct white balance (on the right):
What do I do if...
- There is not enough light?
Try the following:
- Select a greater aperture value
- Select a greater ISO value for sensitivity
- Use manual focusing if the camera cannot lock the focus automatically
- The picture is not sharp enough?
Auto focus may not work properly in poor lighting or when photographing at a close distance.
- In poor lighting conditions, try using an additional light source.
- When photographing a document up close, try using the Macro (or Close-Up) mode. Otherwise, if possible, focus the camera manually.
- If only a part of the picture is blurred, try reducing the aperture value. Increase the distance between the document and the camera and use maximum zoom. Focus on a point anywhere between the center and a border of the image.
- In poor lighting conditions, when shooting in auto mode, the camera will use slower shutter speeds, which makes the resulting photo less sharp. Enable the anti-shake system or use a tripod.