LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Properly recognize inverted text regions for OCR
#1
Posted
:
Wednesday, July 10, 2019 1:42:56 PM(UTC)
Groups: Registered, Manager, Tech Support, Administrators
Posts: 107
Was thanked: 9 time(s) in 9 post(s)
Why are my inverted regions not being recognized correctly?LEADTOOLS OCR provides you with the ability to recognize text in a variety of scenarios. Generally text that is to be OCR'd is black text on a white background. There are exceptions to this rule and the LEAD OCR Engine has settings that allows the user to adjust the engine for a variety of different images. One such exception to the rule could be a document that contains black text on a white background as well as white text on a black background. During this scenario, the OCR engine will not, by default, attempt to recognize one of the zones since it is expecting a uniformity with the background and foreground colors. Below is the example of such an image
As you can see in the following picture, when running the input image through the OCR Demo, only 1 of the 2 words is recognized by the OCR engine. The other is just recognized as a graphics zone which means the OCR engine skips that zone during the recognition process:
How can I fix this?You'll want to use the
IOcrSettingManager Interface and add the following code after you start the OCR Engine.
Here is one way you can do this:
Code:
ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir); // starts the OCR Engine
IOcrSettingManager settingManager = ocrEngine.SettingManager;
settingManager.SetBooleanValue("Recognition.Preprocess.RemoveInvertedTextRegionsFromProcessImage", true);
Here is how you can test it out and enable it in the OCR Demo:
Doing this changes the result when reattempting to recognize the original PNG image. You can see in the following screenshot, when enabling this setting and re-running the recognition, both words are recognized and both zones are text-zones.
For convenience, I have attached a sample application below which can be used to showcase this. If you have any additional questions regarding this forum post, or of anything else not covered please email us at
support@leadtools.com.
Marcus Andra
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Properly recognize inverted text regions for OCR
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.